summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp39
-rw-r--r--llvm/test/CodeGen/AArch64/patchable-function-entry.ll1
2 files changed, 22 insertions, 18 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 1579646352d..6f9aa4dd79f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3204,26 +3204,29 @@ void AsmPrinter::emitPatchableFunctionEntries() {
const unsigned PointerSize = getPointerSize();
if (TM.getTargetTriple().isOSBinFormatELF()) {
auto Flags = ELF::SHF_WRITE | ELF::SHF_ALLOC;
- std::string GroupName;
- if (F.hasComdat()) {
- Flags |= ELF::SHF_GROUP;
- GroupName = F.getComdat()->getName();
- }
- // As of binutils 2.33, GNU as does not support section flag "o". Use
- // SHF_LINK_ORDER if we are using the integrated assembler.
- MCSymbolELF *Link = MAI->useIntegratedAssembler()
- ? cast<MCSymbolELF>(CurrentFnSym)
- : nullptr;
- if (Link)
+ // As of binutils 2.33, GNU as does not support section flag "o" or linkage
+ // field "unique". Use SHF_LINK_ORDER if we are using the integrated
+ // assembler.
+ if (MAI->useIntegratedAssembler()) {
Flags |= ELF::SHF_LINK_ORDER;
-
- MCSection *Section = getObjFileLowering().SectionForGlobal(&F, TM);
- auto R = PatchableFunctionEntryID.try_emplace(
- Section, PatchableFunctionEntryID.size());
- OutStreamer->SwitchSection(OutContext.getELFSection(
- "__patchable_function_entries", ELF::SHT_PROGBITS, Flags, 0, GroupName,
- R.first->second, Link));
+ std::string GroupName;
+ if (F.hasComdat()) {
+ Flags |= ELF::SHF_GROUP;
+ GroupName = F.getComdat()->getName();
+ }
+ MCSection *Section = getObjFileLowering().SectionForGlobal(&F, TM);
+ unsigned UniqueID =
+ PatchableFunctionEntryID
+ .try_emplace(Section, PatchableFunctionEntryID.size())
+ .first->second;
+ OutStreamer->SwitchSection(OutContext.getELFSection(
+ "__patchable_function_entries", ELF::SHT_PROGBITS, Flags, 0,
+ GroupName, UniqueID, cast<MCSymbolELF>(CurrentFnSym)));
+ } else {
+ OutStreamer->SwitchSection(OutContext.getELFSection(
+ "__patchable_function_entries", ELF::SHT_PROGBITS, Flags));
+ }
EmitAlignment(Align(PointerSize));
OutStreamer->EmitSymbolValue(CurrentFnBegin, PointerSize);
}
diff --git a/llvm/test/CodeGen/AArch64/patchable-function-entry.ll b/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
index d90d42f4917..12b8a35cb93 100644
--- a/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
+++ b/llvm/test/CodeGen/AArch64/patchable-function-entry.ll
@@ -3,6 +3,7 @@
; RUN: llc -mtriple=aarch64 -no-integrated-as %s -o - | FileCheck --check-prefix=NOLINK %s
; NOLINK-NOT: "awo"
+; NOLINK-NOT: ,unique,0
define i32 @f0() "patchable-function-entry"="0" {
; CHECK-LABEL: f0:
OpenPOWER on IntegriCloud