[compiler-rt] [win/asan] AllocateMemoryForTrampoline within 2 GB of the module's base address (PR #108822)
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 16 13:55:05 PDT 2024
================
@@ -385,7 +386,29 @@ void TestOnlyReleaseTrampolineRegions() {
}
}
-static uptr AllocateMemoryForTrampoline(uptr image_address, size_t size) {
+static uptr AllocateMemoryForTrampoline(uptr func_address, size_t size) {
+ uptr image_address = func_address;
+
+#if SANITIZER_WINDOWS64
+ // Since we may copy code to the trampoline which could reference data
----------------
rnk wrote:
This is a long comment. For clarity, I would lead by describing what we're trying to do, which is to:
Allocate trampoline memory after the DLL, but within 2GiB of the start of the DLL, so that any address in the DLL can be referenced with PC-relative operands.
It would be more complicated, but potentially less subtle, to generalize this to be an interval comparison of abs([image_base, image_end) - [next_address, next_address+size)) < [2GiB, 2GiB)
(not sure if that's the right pseudocode...)
https://github.com/llvm/llvm-project/pull/108822
More information about the llvm-commits
mailing list