[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 21:52:19 PST 2024
================
@@ -623,6 +625,32 @@ 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 %reg1, foo at GOTTPOFF(%rip), %reg2" -> "addq $foo, %reg1, %reg2"
+ // "addq foo at GOTTPOFF(%rip), %reg1, %reg2" -> "addq $foo, %reg1, %reg2"
+ // "{nf} addq %reg1, foo at GOTTPOFF(%rip), %reg2"
+ // -> "{nf} addq $foo, %reg1, %reg2"
+ // "{nf} addq name at GOTTPOFF(%rip), %reg1, %reg2"
+ // -> "{nf} addq $foo, %reg1, %reg2"
+ // "{nf} addq name at GOTTPOFF(%rip), %reg" -> "{nf} addq $foo, %reg"
+ loc[-2] = 0x81;
+ // Move R bits to B bits in EVEX payloads and ModRM byte.
+ if ((loc[-5] & (1 << 7)) == 0)
+ loc[-5] = (loc[-5] | (1 << 7)) & ~(1 << 5);
+ if ((loc[-5] & (1 << 4)) == 0)
----------------
KanRobert wrote:
Should we remove the if condition at line 644 and 646?
https://github.com/llvm/llvm-project/pull/117675
More information about the llvm-commits
mailing list