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

Daniil Kovalev via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 02:49:09 PST 2024


================
@@ -1734,9 +1742,34 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
       in.mipsGot->updateAllocSize();
 
     for (Partition &part : partitions) {
+      // We've put relocations in relrAuthDyn during
+      // RelocationScanner::processAux, but the target VA for some of them might
+      // be wider than 32 bits which does not fit the place for implicit value
+      // of relr AUTH reloc. We can only know the final VA at this point, so
+      // move relocations with large values from relr to rela.
+      if (part.relrAuthDyn) {
+        for (auto it = part.relrAuthDyn->relocs.begin();
+             it != part.relrAuthDyn->relocs.end();) {
+          if (isInt<32>(it->reloc->sym->getVA(it->reloc->addend))) {
+            ++it;
+            continue;
+          }
+          part.relaDyn->addReloc({R_AARCH64_AUTH_RELATIVE, it->inputSec,
+                                  it->reloc->offset,
+                                  DynamicReloc::AddendOnlyWithTargetVA,
+                                  *it->reloc->sym, it->reloc->addend, R_ABS});
+          part.relrAuthDyn->relocs.erase(it);
----------------
kovdan01 wrote:

Changed to `llvm::remove_if`, thanks. BTW, also changed `std::find_if` in `readSecurityNotes` to `llvm::find_if`. See b215b0d60ac0c2ac29aeb318da7c95725be6ef86


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


More information about the llvm-commits mailing list