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(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 +@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",@progbits,comdat,comdat