[PATCH] D91611: [PowerPC][LLD] Detecting and fixing missing TLS relocation on __tls_get_addr

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 9 10:16:17 PST 2020


MaskRay added inline comments.


================
Comment at: lld/ELF/InputSection.cpp:1055
     case R_RELAX_TLS_IE_TO_LE:
-      target->relaxTlsIeToLe(bufLoc, rel, targetVA);
+      if (!file->ppc64DisableTLSRelax)
+        target->relaxTlsIeToLe(bufLoc, rel, targetVA);
----------------
This is not correct. The relocation will not be handled at all. `ppc64-tls-missing-gdld.s` does not test -no-pie or -pie so you did not notice the issue.

Consider dropping the TLS part and I'll try taking a stab at it.


================
Comment at: lld/test/ELF/ppc64-call-tls-get-addr-exec.s:1
+# REQUIRES: ppc
+# RUN: split-file %s %t
----------------
Since the test now has `-shared` RUN lines. `-exec` is no longer a suitable suffix.


================
Comment at: lld/test/ELF/ppc64-tls-missing-gdld.s:4
 # RUN: llvm-mc --triple=powerpc64 %s --filetype=obj -o %t2.o
-# RUN: ld.lld --shared --fatal-warnings %t1.o -o /dev/null
-# RUN: ld.lld --shared --fatal-warnings %t2.o -o /dev/null
-
-## User code can call __tls_get_addr by specifying the tls_index parameter.
-## We need to allow R_PPC64_REL24/R_PPC64_REL24_NOTOC referencing __tls_get_addr
-## without a pairing R_PPC64_TLSGD/R_PPC64_TLSLD.
+# RUN: ld.lld --shared %t1.o --soname=t1 -o %t1.so
+# RUN: ld.lld --shared %t2.o --soname=t2 -o %t2.so
----------------
GD to IE/LE relaxation only happens for -no-pie or -pie.


================
Comment at: lld/test/ELF/ppc64-tls-missing-gdld.s:7
-
-## User code can call __tls_get_addr by specifying the tls_index parameter.
-## We need to allow R_PPC64_REL24/R_PPC64_REL24_NOTOC referencing __tls_get_addr
----------------
Can some portion of the comment be retained?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91611



More information about the llvm-commits mailing list