[lld] [PAC][lld][AArch64][ELF] Support signed GOT (PR #113815)

Daniil Kovalev via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 1 03:41:36 PDT 2024


================
@@ -1111,7 +1125,19 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
     } else if (!sym.isTls() || ctx.arg.emachine != EM_LOONGARCH) {
       // Many LoongArch TLS relocs reuse the R_LOONGARCH_GOT type, in which
       // case the NEEDS_GOT flag shouldn't get set.
-      sym.setFlags(NEEDS_GOT);
+      bool needsGotAuth =
+          (expr == R_AARCH64_AUTH_GOT || expr == R_AARCH64_AUTH_GOT_PAGE_PC);
+      uint16_t flags = sym.flags.load(std::memory_order_relaxed);
+      if (!(flags & NEEDS_GOT)) {
+        if (needsGotAuth)
+          sym.setFlags(NEEDS_GOT | NEEDS_GOT_AUTH);
+        else
+          sym.setFlags(NEEDS_GOT);
----------------
kovdan01 wrote:

Thanks for suggestion, I've applied the approach with ternary operator, but w/o using the temp flag variable (just put the ternary inside `setFlags` invocation) - this fits one line and looks readable enough IMHO. See 262b4c6eb0e655e3b47350e5f390d4997d7d0431

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


More information about the llvm-commits mailing list