llvm-project/lld/ELF/Arch
Fangrui Song 589e10f858 [ELF] Don't relax R_X86_64_GOTPCRELX if addend != -4
clang may produce `movl x@GOTPCREL+4(%rip), %eax` when loading the high 32 bits
of the address of a global variable in -fpic/-fpie mode.

If assembled by GNU as, the fixup emits an R_X86_64_GOTPCRELX with an
addend != -4. The instruction loads from the GOT entry with an offset
and thus it is incorrect to relax the instruction.

If assembled by the integrated assembler, we emit R_X86_64_GOTPCREL for
relocations that definitely cannot be relaxed (D92114), so this patch is not
needed.

This patch disables the relaxation, which is compatible with the implementation in GNU ld
("Add R_X86_64_[REX_]GOTPCRELX support to gas and ld").

Reviewed By: grimar, jhenderson

Differential Revision: https://reviews.llvm.org/D91993
2020-11-30 08:30:19 -08:00
..
AArch64.cpp [ELF] Rename adjustRelaxExpr to adjustTlsExpr and delete the unused `data` parameter. NFC 2020-11-25 09:00:55 -08:00
AMDGPU.cpp [lib/Object] - Refine interface of ELFFile<ELFT>. NFCI. 2020-09-15 11:38:31 +03:00
ARM.cpp [ELF][ARM] Represent R_ARM_LDO32 as R_DTPREL instead of R_ABS 2020-07-06 09:47:53 -07:00
AVR.cpp [LLD][ELF][AVR] Implement the missing relocation types 2020-07-12 18:18:54 +02:00
Hexagon.cpp [lib/Object] - Refine interface of ELFFile<ELFT>. NFCI. 2020-09-15 11:38:31 +03:00
MSP430.cpp [ELF] Use namespace qualifiers (lld:: or elf::) instead of `namespace lld { namespace elf {` 2020-05-15 08:49:53 -07:00
Mips.cpp [lib/Object] - Refine interface of ELFFile<ELFT>. NFCI. 2020-09-15 11:38:31 +03:00
MipsArchTree.cpp [lib/Object] - Refine interface of ELFFile<ELFT>. NFCI. 2020-09-15 11:38:31 +03:00
PPC.cpp [ELF] Rename adjustRelaxExpr to adjustTlsExpr and delete the unused `data` parameter. NFC 2020-11-25 09:00:55 -08:00
PPC64.cpp [ELF] Rename adjustRelaxExpr to adjustTlsExpr and delete the unused `data` parameter. NFC 2020-11-25 09:00:55 -08:00
PPCInsns.def [LLD][PowerPC] Implement GOT to PC-Rel relaxation 2020-08-17 09:36:09 -05:00
RISCV.cpp [lib/Object] - Refine interface of ELFFile<ELFT>. NFCI. 2020-09-15 11:38:31 +03:00
SPARCV9.cpp [ELF] Use namespace qualifiers (lld:: or elf::) instead of `namespace lld { namespace elf {` 2020-05-15 08:49:53 -07:00
X86.cpp [ELF] Rename adjustRelaxExpr to adjustTlsExpr and delete the unused `data` parameter. NFC 2020-11-25 09:00:55 -08:00
X86_64.cpp [ELF] Don't relax R_X86_64_GOTPCRELX if addend != -4 2020-11-30 08:30:19 -08:00