[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
Mon Mar 18 01:03:50 PDT 2024


================
@@ -1900,6 +1932,18 @@ static void removeUnusedSyntheticSections() {
         auto *sec = cast<SyntheticSection>(s);
         if (sec->getParent() && sec->isNeeded())
           return false;
+        // Packed AArch64 AUTH relocs might be moved from .relr.auth.dyn to
+        // .rela.dyn further in finalizeAddressDependentContent(). It is called
+        // later since removing unused synthetic sections changes the final
+        // layout. So, .rela.dyn should be kept now in such a case even if it's
+        // currently empty. A possible side effect is having empty
+        // .relr.auth.dyn (if all the packed AUTH relocs were moved to
+        // .rela.dyn) or empty .rela.dyn (if no rela relocs were there and no
+        // packed AUTH relocs were moved to it) in the output binary.
+        if (config->emachine == EM_AARCH64 && config->relrPackDynRelocs)
+          if (auto *relSec = dyn_cast<RelocationBaseSection>(sec))
+            if (relSec->name == ".rela.dyn")
----------------
MaskRay wrote:

Use a pointer comparison with `mainPart.relaDyn.get()`

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


More information about the llvm-commits mailing list