diff options
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 39 |
1 files changed, 21 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); } |