[compiler-rt] [win/asan] Search both higher and lower in AllocateTrampolineRegion (PR #114212)
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 09:51:03 PDT 2024
================
@@ -340,32 +347,66 @@ struct TrampolineMemoryRegion {
uptr max_size;
};
-UNUSED static const uptr kTrampolineScanLimitRange = 1ull << 31; // 2 gig
+UNUSED static const uptr kTrampolineRangeLimit = 1ull << 31; // 2 gig
static const int kMaxTrampolineRegion = 1024;
static TrampolineMemoryRegion TrampolineRegions[kMaxTrampolineRegion];
-static void *AllocateTrampolineRegion(uptr image_address, size_t granularity) {
-#if SANITIZER_WINDOWS64
- uptr address = image_address;
- uptr scanned = 0;
- while (scanned < kTrampolineScanLimitRange) {
+static void *AllocateTrampolineRegion(uptr min_addr, uptr max_addr,
----------------
rnk wrote:
I think this deserves a significant doc comment. The loop below probes the address space in a search that alternates between forward probing and backwards probing, and that makes the logic fairly hard to follow. I'd stop short of ASCII art, but a text list like this would help:
```
// This loop probes the virtual address space to find free memory in range to implement a trampoline. It alternates searching backwards and forwards, probing regions below in the order P1, P2, P3, P4, etc.
// min_addr
// ...
// P4
// P2
// func_addr
// P1
// P3
// ...
// max_addr
```
https://github.com/llvm/llvm-project/pull/114212
More information about the llvm-commits
mailing list