[lld] [X86][LLD] Handle R_X86_64_CODE_4_GOTPC32_TLSDESC relocation type (PR #116909)

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 24 18:01:15 PST 2024


================
@@ -486,18 +490,26 @@ void X86_64::relaxTlsGdToLe(uint8_t *loc, const Relocation &rel,
     // The original code used a pc relative relocation and so we have to
     // compensate for the -4 in had in the addend.
     write32le(loc + 8, val + 4);
-  } else if (rel.type == R_X86_64_GOTPC32_TLSDESC) {
+  } else if (rel.type == R_X86_64_GOTPC32_TLSDESC ||
+             rel.type == R_X86_64_CODE_4_GOTPC32_TLSDESC) {
     // Convert leaq x at tlsdesc(%rip), %REG to movq $x at tpoff, %REG.
     if ((loc[-3] & 0xfb) != 0x48 || loc[-2] != 0x8d ||
----------------
KanRobert wrote:

It seems you're missing some tests.  The `(loc[-3] & 0xfb) != 0x48` is used to check the X and B bit for REX prefix, it would fail for REX2 prefix.

https://github.com/llvm/llvm-project/pull/116909


More information about the llvm-commits mailing list