[lld] [X86][LLD] Handle R_X86_64_CODE_6_GOTTPOFF relocation type (PR #117675)

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 26 19:13:26 PST 2024


================
@@ -623,6 +625,26 @@ void X86_64::relaxTlsIeToLe(uint8_t *loc, const Relocation &rel,
                << "R_X86_64_CODE_4_GOTTPOFF must be used in MOVQ or ADDQ "
                   "instructions only";
     }
+  } else if (rel.type == R_X86_64_CODE_6_GOTTPOFF) {
+    if (loc[-6] != 0x62) {
+      Err(ctx) << getErrorLoc(ctx, loc - 6)
+               << "Invalid prefix with R_X86_64_CODE_6_GOTTPOFF!";
+      return;
+    }
+    if (loc[-2] == 0x3 || loc[-2] == 0x1) {
+      // "addq foo at gottpoff(%rip), %reg1, %reg2" -> "addq $foo, %reg1, %reg2"
----------------
KanRobert wrote:

This comment is incomplete. You handle several variants here but only mention ADD64rm_ND.

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


More information about the llvm-commits mailing list