[ELF] Untangle R_GOT style TLS IE and processRelocAux. NFC
authorFangrui Song <i@maskray.me>
Sun, 31 Oct 2021 19:38:36 +0000 (12:38 -0700)
committerFangrui Song <i@maskray.me>
Sun, 31 Oct 2021 19:38:36 +0000 (12:38 -0700)
lld/ELF/Relocations.cpp

index 40159dc..6c8e57a 100644 (file)
@@ -1279,9 +1279,9 @@ handleTlsRelocation(RelType type, Symbol &sym, InputSectionBase &c,
     } else if (expr != R_TLSIE_HINT) {
       if (!sym.isInGot())
         addTpOffsetGotEntry(sym);
-      // R_GOT may not be a link-time constant.
-      if (expr == R_GOT)
-        processRelocAux<ELFT>(c, expr, type, offset, sym, addend);
+      // R_GOT needs a relative relocation for PIC on i386 and Hexagon.
+      if (expr == R_GOT && config->isPic && !target->usesOnlyLowPageBits(type))
+        addRelativeReloc(&c, offset, sym, addend, expr, type);
       else
         c.relocations.push_back({expr, type, offset, addend, &sym});
     }