[all-commits] [llvm/llvm-project] 31dd29: [X86, lld] Handle relocation R_X86_64_REX2_GOTPCREL...

Shengchen Kan via All-commits all-commits at lists.llvm.org
Sat Sep 28 21:52:57 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 31dd29cfb37ef3e52d7cb6ed28fbb976338b30aa
      https://github.com/llvm/llvm-project/commit/31dd29cfb37ef3e52d7cb6ed28fbb976338b30aa
  Author: Shengchen Kan <shengchen.kan at intel.com>
  Date:   2024-09-29 (Sun, 29 Sep 2024)

  Changed paths:
    M lld/ELF/Arch/X86_64.cpp
    M lld/test/ELF/x86-64-gotpc-no-relax-err.s
    M lld/test/ELF/x86-64-gotpc-relax-nopic.s
    M lld/test/ELF/x86-64-gotpc-relax.s

  Log Message:
  -----------
  [X86,lld] Handle relocation R_X86_64_REX2_GOTPCRELX (#109783)

For

	mov        name at GOTPCREL(%rip), %reg
	test       %reg, name at GOTPCREL(%rip)
	binop      name at GOTPCREL(%rip), %reg

where binop is one of adc, add, and, cmp, or, sbb, sub, xor
instructions, we added

 R_X86_64_REX2_GOTPCRELX = 43

in #106681.

Linker can treat R_X86_64_REX2_GOTPCRELX as R_X86_64_GOTPCREL or convert
the above instructions to

	lea	name(%rip), %reg
	mov	$name, %reg
	test	$name, %reg
	binop	$name, %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/3d5a60de52556f6a53d71d7e607c6696450ae3e4
Binutils mailthread:
https://sourceware.org/pipermail/binutils/2023-December/131462.html
ABI discussion: https://groups.google.com/g/x86-64-abi/c/KbzaNHRB6QU
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