summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2020-01-12 12:23:16 -0800
committerFangrui Song <maskray@google.com>2020-01-12 12:53:44 -0800
commit7fa5290d5bd5632d7a36a4ea9f46e81e04fb819e (patch)
tree1359e8b200e2f40bdeb6716955e2b2371fde02cc /llvm/lib/CodeGen/AsmPrinter
parentde797ccdd74f46d5f637ccf66c78da9905a46f42 (diff)
downloadbcm5719-llvm-7fa5290d5bd5632d7a36a4ea9f46e81e04fb819e.tar.gz
bcm5719-llvm-7fa5290d5bd5632d7a36a4ea9f46e81e04fb819e.zip
__patchable_function_entries: don't use linkage field 'unique' with -no-integrated-as
.section name, "flags"G, @type, GroupName[, linkage] As of binutils 2.33, linkage cannot be 'unique'. For integrated assembler, we use both 'o' flag and 'unique' linkage to support --gc-sections and COMDAT with lld. https://sourceware.org/ml/binutils/2019-11/msg00266.html
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp39
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);
}
OpenPOWER on IntegriCloud