[X86] Avoid generating invalid R_X86_64_GOTPCRELX relocations
authorHarald van Dijk <harald@gigawatt.nl>
Fri, 18 Dec 2020 23:38:38 +0000 (23:38 +0000)
committerHarald van Dijk <harald@gigawatt.nl>
Fri, 18 Dec 2020 23:38:38 +0000 (23:38 +0000)
commitadc55b5a5ae49f1fe3a04f7f79b1c08f508b4307
tree8f35226d808ae6402226e51e526421cb873f3a7d
parentf5cef870d116104354fe557c71025a9d4bfbe952
[X86] Avoid generating invalid R_X86_64_GOTPCRELX relocations

We need to make sure not to emit R_X86_64_GOTPCRELX relocations for
instructions that use a REX prefix. If a REX prefix is present, we need to
instead use a R_X86_64_REX_GOTPCRELX relocation. The existing logic for
CALL64m, JMP64m, etc. already handles this by checking the HasREX parameter
and using it to determine which relocation type to use. Do this for all
instructions that can use relaxed relocations.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D93561
lld/test/ELF/x86-64-gotpc-relax-nopic.s
llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp
llvm/test/MC/ELF/got-relaxed-rex.s [deleted file]
llvm/test/MC/X86/gotpcrelx.s