llvm-project
957aee8a - [llvm-profgen] Unify base address derivation to support arbitrary OS page sizes (#217887)

Commit
80 days ago
[llvm-profgen] Unify base address derivation to support arbitrary OS page sizes (#217887) `setPreferredTextSegmentAddresses()` uses a 4 KiB alignment when calculating text segment offsets. On systems with larger runtime pages (e.g., 64 KiB on AArch64), the kernel rounds down the mmap file offset to the page boundary. Consequently, perf may report an executable mmap starting before the recorded text segment offset. This caused llvm-profgen to fail with "File offset not found". This patch simplifies and unifies the logic by deriving the exact base addresses: - Static Preferred Base: Derived via `Phdr.p_vaddr - Phdr.p_offset `for the first executable segment, removing the fragile 4KiB assumption. - Runtime Base: Derived using `Event.Address - Event.Offset`. Since the OS dynamically reflects the page-aligned down offset in the perf mmap event, subtracting it from the aligned virtual address automatically recovers the absolute true image base.
Author
Parents
Loading