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

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 5 22:28:31 PST 2024


================
@@ -1090,7 +1110,18 @@ 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 RE_LOONGARCH_GOT type, in which
       // case the NEEDS_GOT flag shouldn't get set.
-      sym.setFlags(NEEDS_GOT);
+      bool needsGotAuth =
+          (expr == RE_AARCH64_AUTH_GOT || expr == RE_AARCH64_AUTH_GOT_PAGE_PC);
+      uint16_t flags = sym.flags.load(std::memory_order_relaxed);
+      if (!(flags & NEEDS_GOT)) {
----------------
MaskRay wrote:

There is a data race due to load+store being separate atomic operations.
The loaded flags can be stale (another thread has modified `flags`) when `setFlags` is called.

In addition, we should avoid diagnostics in this function that is concurrently called. The existing code doesn't have diagnostics.

```
if (expr needs AUTH) {
  sym.setFlags(NEEDS_GOT | NEEDS_GOT_AUTH);
} else {
  sym.setFlags(NEEDS_GOT);
}
```

then check the incompatibility in postScanRelocations. Yes, we will not be able to report locations.

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


More information about the llvm-commits mailing list