[lld] [lld] Add target support for SystemZ (s390x) (PR #75643)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 13:11:15 PST 2024


================
@@ -1404,6 +1404,26 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
   if (expr == R_NONE)
     return;
 
+  // Like other platforms, calls to the TLS helper routine on SystemZ carry
+  // two relocations, one for the helper routine itself, and a TLS marker
+  // relocation.  When relaxing the TLS model, the helper routine is no longer
+  // needed, and its relocation should be removed.  Unlike other platforms,
+  // on SystemZ the TLS marker routine typically comes *after* the helper
+  // routine relocation, so the getTlsGdRelaxSkip mechanism used by
+  // handleTlsRelocation does not work on this platform.
+  //
+  // Instead, check for this case here: if we are building a main executable
+  // (i.e. TLS relaxation applies), and the relocation *after* the current one
+  // is a TLS call marker instruction matching the current instruction, then
+  // skip this relocation.
+  if (config->emachine == EM_S390 && !config->shared) {
----------------
MaskRay wrote:

Perhaps an alternative is to sort relocations at `Relocations.cpp:1574` `Sort relocations by offset for more efficient searching for`, similar to PPC64 and RISC-V. 
After sorting, R_390_TLS_LDCALL will come before R_390_PLT32DBL

https://github.com/llvm/llvm-project/pull/75643


More information about the llvm-commits mailing list