[lld] [lld][AArch64][ELF][PAC] Support AUTH relocations and AUTH ELF marking (PR #72714)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 10 12:03:55 PST 2024


================
@@ -1132,11 +1132,37 @@ void RelocationScanner::processAux(RelExpr expr, RelType type, uint64_t offset,
                     (isa<EhInputSection>(sec) && config->emachine != EM_MIPS));
   if (canWrite) {
     RelType rel = target->getDynRel(type);
+    if (config->emachine == EM_AARCH64 && type == R_AARCH64_AUTH_ABS64) {
+      // Assume relocations from relocatable objects are RELA.
+      assert(config->isRela);
+      std::lock_guard<std::mutex> lock(relocMutex);
+      // For a preemptible symbol, we can't use a relative relocation. For an
+      // undefined symbol, we can't compute offset at link-time and use a
+      // relative relocation. Use a symbolic relocation instead.
+      Partition &part = sec->getPartition();
+      if (sym.isPreemptible || sym.isUndefined()) {
+        part.relaDyn->addSymbolReloc(type, *sec, offset, sym, addend, type);
+      } else if (part.relrAuthDyn && sec->addralign >= 2 && offset % 2 == 0 &&
+                 isInt<32>(sym.getVA(addend))) {
----------------
MaskRay wrote:

Should test a large addend

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


More information about the llvm-commits mailing list