[llvm-branch-commits] [lld] [ELF] Include sharded relocations in RelocationBaseSection::getSize (PR #173285)
Jessica Clarke via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 24 02:54:59 PST 2025
https://github.com/jrtc27 updated https://github.com/llvm/llvm-project/pull/173285
>From b65b9570750b44e565a078fd92adca971515679a Mon Sep 17 00:00:00 2001
From: Jessica Clarke <jrtc27 at jrtc27.com>
Date: Mon, 22 Dec 2025 17:08:05 +0000
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
=?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.5
---
lld/ELF/SyntheticSections.h | 7 ++++++-
lld/test/ELF/aarch64-pauth-rela-iplt-end.s | 20 ++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
create mode 100644 lld/test/ELF/aarch64-pauth-rela-iplt-end.s
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 16bdda8ef75bb..47d87e76357f3 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -528,7 +528,12 @@ class RelocationBaseSection : public SyntheticSection {
return !relocs.empty() ||
llvm::any_of(relocsVec, [](auto &v) { return !v.empty(); });
}
- size_t getSize() const override { return relocs.size() * this->entsize; }
+ size_t getSize() const override {
+ size_t count = relocs.size();
+ for (const auto &v : relocsVec)
+ count += v.size();
+ return count * this->entsize;
+ }
size_t getRelativeRelocCount() const { return numRelativeRelocs; }
void mergeRels();
void partitionRels();
diff --git a/lld/test/ELF/aarch64-pauth-rela-iplt-end.s b/lld/test/ELF/aarch64-pauth-rela-iplt-end.s
new file mode 100644
index 0000000000000..b2c7fe0c61c99
--- /dev/null
+++ b/lld/test/ELF/aarch64-pauth-rela-iplt-end.s
@@ -0,0 +1,20 @@
+# REQUIRES: aarch64
+# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
+# RUN: ld.lld --static %t.o -o %t
+# RUN: llvm-readelf -S -s -d %t | FileCheck %s
+
+## Verify that R_AARCH64_AUTH_RELATIVE relocations are included within the
+## bounds of __rela_iplt_start/end, as relative relocations still emitted for
+## static PDEs due to needing run-time signing. Historically this would not be
+## the case if added to .rela.dyn with sharding.
+
+# CHECK: .rela.dyn RELA 0000000000200158 000158 000018 18 A 0 0 8
+# CHECK: 0000000000200158 0 NOTYPE LOCAL HIDDEN 1 __rela_iplt_start
+# CHECK: 0000000000200170 0 NOTYPE LOCAL HIDDEN 1 __rela_iplt_end
+
+adrp x0, __rela_iplt_start
+adrp x0, __rela_iplt_end
+
+.data
+foo:
+.quad foo at AUTH(da,42)
More information about the llvm-branch-commits
mailing list