[all-commits] [llvm/llvm-project] 6f76b2: [X86][MC] Add R_X86_64_CODE_4_GOTTPOFF (#116633)

Feng Zou via All-commits all-commits at lists.llvm.org
Thu Nov 21 00:13:32 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6f76b2a3c010cd25acf4efb56cbde2a678b6242c
      https://github.com/llvm/llvm-project/commit/6f76b2a3c010cd25acf4efb56cbde2a678b6242c
  Author: Feng Zou <feng.zou at intel.com>
  Date:   2024-11-21 (Thu, 21 Nov 2024)

  Changed paths:
    M llvm/include/llvm/BinaryFormat/ELFRelocs/x86_64.def
    M llvm/lib/Target/X86/MCTargetDesc/X86ELFObjectWriter.cpp
    M llvm/test/MC/ELF/relocation.s

  Log Message:
  -----------
  [X86][MC] Add R_X86_64_CODE_4_GOTTPOFF (#116633)

For

  mov name at GOTTPOFF(%rip), %reg
  add name at GOTTPOFF(%rip), %reg

add

  `R_X86_64_CODE_4_GOTTPOFF` = 44

if the instruction starts at 4 bytes before the relocation offset. It's
similar to R_X86_64_GOTTPOFF.

Linker can treat `R_X86_64_CODE_4_GOTTPOFF` as `R_X86_64_GOTTPOFF` or
convert the instructions above to

  mov $name at tpoff, %reg
  add $name at tpoff, %reg

if the first byte of the instruction at the relocation `offset - 4` is
`0xd5` (namely, encoded w/REX2 prefix) when possible.

Binutils patch:
https://github.com/bminor/binutils-gdb/commit/a533c8df598b5ef99c54a13e2b137c98b34b043c
Binutils mailthread:
https://sourceware.org/pipermail/binutils/2023-December/131463.html
ABI discussion:
https://groups.google.com/g/x86-64-abi/c/ACwD-UQXVDs/m/vrgTenKyFwAJ
Blog: https://kanrobert.github.io/rfc/All-about-APX-relocation



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list