[PATCH] D77021: [Hexagon] R_HEX_GD_PLT_B22_PCREL cannot be relaxed.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Mar 29 11:13:18 PDT 2020


MaskRay added a comment.

Calling a STT_TLS symbol (`call a at GDPLT`) seems strange. Tthe problem here is that a STT_TLS symbol is considered absolute by `isAbsoluteValue`. It is incorrect to reference a non-preemptible (due to -Bsymbolic) with an R_PC in PIC link.

I know that you had a previous change (D74443 <https://reviews.llvm.org/D74443>) which converted the target symbol to __tls_get_addr (not STT_TLS), which may be somehow related to this hack. Can you shall a bit more context why `call a at GDPLT` is used while a is STT_TLS?



================
Comment at: lld/ELF/Relocations.cpp:1331
+  if (!sym.isPreemptible && (!sym.isGnuIFunc() || config->zIfuncNoplt) &&
+      (type != R_HEX_GD_PLT_B22_PCREL)) {
+	  if (expr == R_GOT_PC && !isAbsoluteValue(sym)) {
----------------
This can potentially break other targets.


================
Comment at: lld/ELF/Relocations.cpp:1339
         addend &= ~0x8000;
       expr = fromPlt(expr);
     }
----------------
Move the check here and check `config->emachine == EM_HEXAGON`


================
Comment at: lld/test/ELF/hexagon-tls-gd-symbolic.s:8
+
+# Prior to change affiliated with this test lld for the Hexagon target would
+# error out with something like:
----------------
`## `




================
Comment at: lld/test/ELF/hexagon-tls-gd-symbolic.s:26
+# RELOC: Relocations [
+# RELOC-NEXT:  Section (5) .rela.plt {
+# RELOC-NEXT:   0x302D4 R_HEX_JMP_SLOT - 0x0
----------------
section index is unneeded.


================
Comment at: lld/test/ELF/hexagon-tls-gd-symbolic.s:27
+# RELOC-NEXT:  Section (5) .rela.plt {
+# RELOC-NEXT:   0x302D4 R_HEX_JMP_SLOT - 0x0
+# RELOC-NEXT:   0x302D8 R_HEX_JMP_SLOT __tls_get_addr 0x0
----------------
Addresses are unneeded. Delete them


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77021





More information about the llvm-commits mailing list