[all-commits] [llvm/llvm-project] 9d6ec2: [lld/ELF] Don't relax R_X86_64_(REX_)GOTPCRELX whe...
Arthur Eubanks via All-commits
all-commits at lists.llvm.org
Wed Oct 4 13:04:19 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9d6ec280fc537b55ef8641ea85d3522426bc5766
https://github.com/llvm/llvm-project/commit/9d6ec280fc537b55ef8641ea85d3522426bc5766
Author: Arthur Eubanks <aeubanks at google.com>
Date: 2023-10-04 (Wed, 04 Oct 2023)
Changed paths:
M lld/ELF/Arch/X86_64.cpp
M lld/ELF/Relocations.cpp
M lld/ELF/Relocations.h
M lld/ELF/Writer.cpp
R lld/test/ELF/x86-64-gotpc-err.s
A lld/test/ELF/x86-64-gotpc-relax-too-far.s
M lld/test/ELF/x86-64-gotpc-relax.s
Log Message:
-----------
[lld/ELF] Don't relax R_X86_64_(REX_)GOTPCRELX when offset is too far
For each R_X86_64_(REX_)GOTPCRELX relocation, check that the offset to the symbol is representable with 2^32 signed offset. If not, add a GOT entry for it and set its expr to R_GOT_PC so that we emit the GOT load instead of the relaxed lea. Do this in finalizeAddressDependentContent() where we iteratively attempt this (e.g. RISCV uses this for relaxation, ARM uses this to insert thunks).
Decided not to do the opposite of inserting GOT entries initially and removing them when relaxable because removing GOT entries isn't simple.
One drawback of this approach is that if we see any GOTPCRELX relocation, we'll create an empty .got even if it's not required in the end.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D157020
More information about the All-commits
mailing list