[llvm-branch-commits] AArch64: Emit PAuth ifuncs into the same comdat as the containing global. (PR #170965)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Dec 5 19:40:02 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: Peter Collingbourne (pcc)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/170965.diff
2 Files Affected:
- (modified) llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp (+7-2)
- (modified) llvm/test/CodeGen/AArch64/ptrauth-irelative.ll (+6)
``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
index 8267414e78955..8ef985451a4c1 100644
--- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
+++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
@@ -2484,9 +2484,14 @@ const MCExpr *AArch64AsmPrinter::emitPAuthRelocationAsIRelative(
OutStreamer->emitLabel(Place);
OutStreamer->pushSection();
+ const MCSymbolELF *Group =
+ static_cast<MCSectionELF *>(OutStreamer->getCurrentSectionOnly())
+ ->getGroup();
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,
+ ELF::SHF_ALLOC | ELF::SHF_EXECINSTR | (Group ? ELF::SHF_GROUP : 0), 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
``````````
</details>
https://github.com/llvm/llvm-project/pull/170965
More information about the llvm-branch-commits
mailing list