[lld] [ELF] Handle and optimize x86-64 PLTOFF64 TLS sequences (PR #216263)
Jessica Clarke via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 17 02:52:50 PDT 2026
================
@@ -778,9 +778,33 @@ void X86_64::scanSection(InputSectionBase &sec, unsigned shard) {
elf::scanSection1<X86_64, ELF32LE>(*this, sec, shard);
}
+static bool isPltOff64Tls(const uint8_t *loc) {
+ return loc[4] == 0x48 && loc[5] == 0xb8;
+}
+
void X86_64::relaxTlsGdToLe(uint8_t *loc, const Relocation &rel,
uint64_t val) const {
if (rel.type == R_X86_64_TLSGD) {
+ // TLSGD can be directly followed by MOVABS (instead of CALL):
+ // leaq x at tlsgd(%rip), %rdi # 48 8d 3d <disp32>
+ // movabsq $__tls_get_addr at pltoff, %rax # 48 b8 <imm64>,
+ // R_X86_64_PLTOFF64
----------------
jrtc27 wrote:
This is a bit odd to be shoved in the middle of the assembly sequence (especially when there's no corresponding TLSGD one)
https://github.com/llvm/llvm-project/pull/216263
More information about the llvm-commits
mailing list