[PATCH] D102862: [lld][ELF][SPARC] Support TLS GD relocations

Jessica Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 20 12:17:40 PDT 2021


jrtc27 added inline comments.


================
Comment at: lld/ELF/Arch/SPARCV9.cpp:212-217
+  case R_SPARC_TLS_GD_HI22:
+    relocateNoSym(loc, R_SPARC_HI22, val);
+    return;
+  case R_SPARC_TLS_GD_LO10:
+    relocateNoSym(loc, R_SPARC_LO10, val);
+    return;
----------------
R_SPARC_TLS_IE_HI22/LO10? This is wrong, but I guess this is a hack that kinda works because IE isn't actually implemented yet? Which probably should happen before landing GD support... LD is less clear, but also seemingly unimplemented, only basic LE.


================
Comment at: lld/ELF/Arch/SPARCV9.cpp:227
+  case R_SPARC_TLS_GD_ADD:
+    // add %r1, %r2, %r3 -> mov %g7, %r2, %r3
+    write32be(loc, (read32be(loc) & ~0x0007c000) | 0x0001c000);
----------------
Do you mean `add %g7, %r2, %r3`?


================
Comment at: lld/ELF/Driver.cpp:929
   return m == EM_AARCH64 || m == EM_AMDGPU || m == EM_HEXAGON || m == EM_PPC ||
-         m == EM_PPC64 || m == EM_RISCV || m == EM_X86_64;
+         m == EM_PPC64 || m == EM_RISCV || m == EM_X86_64 || m == EM_SPARCV9;
 }
----------------
Please keep this sorted


================
Comment at: lld/ELF/Relocations.cpp:291-294
+        // These relocations are applied on call instructions like
+        //   call __tls_get_addr, %rel(sym)
+        // If this relocation won't be relaxed we have to replace it with a
+        // PLT-relative one to __tls_get_addr.
----------------
Should this be more like hexagonNeedsTLSSymbol/hexagonTLSSymbolUpdate and combined with it, which has similar weirdness?


================
Comment at: lld/ELF/Relocations.cpp:298-299
+
+        if (!call_sym->isInGot())
+          addGotEntry(*call_sym);
+        if (!call_sym->isInPlt())
----------------
Why would it need a GOT entry? SPARC doesn't even use a .got.plt, it synthesises the addresses directly in the PLT entries, but even on .got.plt architectures calls don't use the real GOT other than MIPS abicalls.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102862/new/

https://reviews.llvm.org/D102862



More information about the llvm-commits mailing list