llvm-project
1376d063 - [BOLT] Skip non-code relocs as function references (#215028)

Commit
6 days ago
[BOLT] Skip non-code relocs as function references (#215028) handleRelocation looked up the referenced function from the resolved "symbol + addend" address, ignoring the symbol's section. With biased array indexing the compiler folds a constant into the displacement, e.g. ``` movq const_int_rtx-0x3fe00(,%rax,8), %r14 # R_X86_64_32S const_int_rtx-0x3fe00 ``` so the unbiased displacement is not a live address (only disp + rax*8 is), yet it can land inside an unrelated function. BOLT re-anchored the relocation onto that function and dropped the addend, then during disassembly registered an interprocedural reference to a mid-instruction address, producing: ``` BOLT-WARNING: corrupted control flow detected in function ...: an external branch/call targets an invalid instruction in function ... ; ignoring both ``` With -use-old-text this causes "cannot ignore non-empty function in current mode". Observed on SPEC CPU2026 821.gcc_s built with clang15. Check `IsToCode || IsSectionReference` prior to setting a ReferencedBF. Test Plan: Added bolt/test/X86/reloc-data-symbol-negative-addend.s
Author
Parents
Loading