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

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 12 14:42:59 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) {
----------------
uweigand wrote:

This does indeed seem to work.   (However, we need to sort *before* the `scanOne` calls, not afterwards.)  Patch updated accordingly.

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


More information about the llvm-commits mailing list