[llvm] 390f17f - AArch64: Emit PAuth ifuncs into the same comdat as the containing global.
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 9 19:34:06 PST 2025
Author: Peter Collingbourne
Date: 2025-12-09T19:34:01-08:00
New Revision: 390f17f2db07f55716ad60b40192fa2049e4a8b3
URL: https://github.com/llvm/llvm-project/commit/390f17f2db07f55716ad60b40192fa2049e4a8b3
DIFF: https://github.com/llvm/llvm-project/commit/390f17f2db07f55716ad60b40192fa2049e4a8b3.diff
LOG: AArch64: Emit PAuth ifuncs into the same comdat as the containing global.
PAuth ifuncs contain a relocation pointing to the section they are
relocating (the place), so they need to be in the same comdat in order
to avoid relocations pointing to discarded sections.
Reviewers: atrosinenko, kovdan01, fmayer
Reviewed By: fmayer
Pull Request: https://github.com/llvm/llvm-project/pull/170944
Added:
Modified:
llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
llvm/test/CodeGen/AArch64/ptrauth-irelative.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 574316160fbcb..57bb577ec28df 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -2484,9 +2484,15 @@ const MCExpr *AArch64AsmPrinter::emitPAuthRelocationAsIRelative(
OutStreamer->emitLabel(Place);
OutStreamer->pushSection();
+ const MCSymbolELF *Group =
+ static_cast<MCSectionELF *>(OutStreamer->getCurrentSectionOnly())
+ ->getGroup();
+ auto Flags = ELF::SHF_ALLOC | ELF::SHF_EXECINSTR;
+ if (Group)
+ Flags |= ELF::SHF_GROUP;
OutStreamer->switchSection(OutStreamer->getContext().getELFSection(
- ".text.startup", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_EXECINSTR,
- 0, "", true, PAuthIFuncNextUniqueID++, nullptr));
+ ".text.startup", ELF::SHT_PROGBITS, Flags, 0, Group, true,
+ Group ? MCSection::NonUniqueID : PAuthIFuncNextUniqueID++, nullptr));
MCSymbol *IRelativeSym =
OutStreamer->getContext().createLinkerPrivateSymbol("pauth_ifunc");
diff --git a/llvm/test/CodeGen/AArch64/ptrauth-irelative.ll b/llvm/test/CodeGen/AArch64/ptrauth-irelative.ll
index 4ee1c19a86490..6a291497d6c46 100644
--- a/llvm/test/CodeGen/AArch64/ptrauth-irelative.ll
+++ b/llvm/test/CodeGen/AArch64/ptrauth-irelative.ll
@@ -93,3 +93,9 @@
; CHECK-NEXT: .section .rodata
; CHECK-NEXT: .xword [[FUNC]]@FUNCINIT
@globalref8 = constant ptr ptrauth (ptr getelementptr (i8, ptr @global, i64 8), i32 2, i64 5, ptr null), align 8
+
+$comdat = comdat any
+ at comdat = constant ptr ptrauth (ptr null, i32 2, i64 1, ptr null), align 8, comdat
+; CHECK: comdat:
+; CHECK-NEXT: [[PLACE:.*]]:
+; CHECK-NEXT: .section .text.startup,"axG", at progbits,comdat,comdat
More information about the llvm-commits
mailing list