[X86][LLD] Handle R_X86_64_CODE_6_GOTTPOFF relocation type (#117675)
commit636beb6a2833ee0290935f679252c1b662721b31
authorFeng Zou <feng.zou@intel.com>
Thu, 5 Dec 2024 08:26:26 +0000 (5 16:26 +0800)
committerGitHub <noreply@github.com>
Thu, 5 Dec 2024 08:26:26 +0000 (5 16:26 +0800)
tree16d5fece787e54671a1f302040a1032a861b84d5
parenta9a4a83b6132f076fd14ac31268deaa4bf1381d5
[X86][LLD] Handle R_X86_64_CODE_6_GOTTPOFF relocation type (#117675)

For

    add %reg1, name@GOTTPOFF(%rip), %reg2
    add name@GOTTPOFF(%rip), %reg1, %reg2
    {nf} add %reg1, name@GOTTPOFF(%rip), %reg2
    {nf} add name@GOTTPOFF(%rip), %reg1, %reg2
    {nf} add name@GOTTPOFF(%rip), %reg

add

    R_X86_64_CODE_6_GOTTPOFF = 50

in #117277.

Linker can treat R_X86_64_CODE_6_GOTTPOFF as R_X86_64_GOTTPOFF or
convert the instructions above to

    add $name@tpoff, %reg1, %reg2
    add $name@tpoff, %reg1, %reg2
    {nf} add $name@tpoff, %reg1, %reg2
    {nf} add $name@tpoff, %reg1, %reg2
    {nf} add $name@tpoff, %reg

if the first byte of the instruction at the relocation offset - 6 is
0x62 (namely, encoded w/EVEX prefix) when possible.

Binutils patch: bminor/binutils-gdb@5bc71c2
Binutils mailthread:
https://sourceware.org/pipermail/binutils/2024-February/132351.html
ABI discussion:
https://groups.google.com/g/x86-64-abi/c/FhEZjCtDLFw/m/VHDjN4orAgAJ
Blog: https://kanrobert.github.io/rfc/All-about-APX-relocation
lld/ELF/Arch/X86_64.cpp
lld/test/ELF/invalid/broken-relaxation-x64.test
lld/test/ELF/pack-dyn-relocs-tls-x86-64.s
lld/test/ELF/tls-opt.s
lld/test/ELF/x86-64-tls-ie-err.s [new file with mode: 0644]
lld/test/ELF/x86-64-tls-ie-local.s