aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r--llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp38
1 files changed, 27 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index eef0555..f0f4516 100644
--- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -798,6 +798,23 @@ static MCSectionELF *selectELFSectionForGlobal(
AssociatedSymbol);
}
+static MCSection *selectELFSectionForGlobal(
+ MCContext &Ctx, const GlobalObject *GO, SectionKind Kind, Mangler &Mang,
+ const TargetMachine &TM, bool EmitUniqueSection, unsigned Flags,
+ unsigned *NextUniqueID) {
+ const MCSymbolELF *LinkedToSym = getLinkedToSymbol(GO, TM);
+ if (LinkedToSym) {
+ EmitUniqueSection = true;
+ Flags |= ELF::SHF_LINK_ORDER;
+ }
+
+ MCSectionELF *Section = selectELFSectionForGlobal(
+ Ctx, GO, Kind, Mang, TM, EmitUniqueSection, Flags,
+ NextUniqueID, LinkedToSym);
+ assert(Section->getLinkedToSymbol() == LinkedToSym);
+ return Section;
+}
+
MCSection *TargetLoweringObjectFileELF::SelectSectionForGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
unsigned Flags = getELFSectionFlags(Kind);
@@ -812,18 +829,17 @@ MCSection *TargetLoweringObjectFileELF::SelectSectionForGlobal(
EmitUniqueSection = TM.getDataSections();
}
EmitUniqueSection |= GO->hasComdat();
+ return selectELFSectionForGlobal(getContext(), GO, Kind, getMangler(), TM,
+ EmitUniqueSection, Flags, &NextUniqueID);
+}
- const MCSymbolELF *LinkedToSym = getLinkedToSymbol(GO, TM);
- if (LinkedToSym) {
- EmitUniqueSection = true;
- Flags |= ELF::SHF_LINK_ORDER;
- }
-
- MCSectionELF *Section = selectELFSectionForGlobal(
- getContext(), GO, Kind, getMangler(), TM, EmitUniqueSection, Flags,
- &NextUniqueID, LinkedToSym);
- assert(Section->getLinkedToSymbol() == LinkedToSym);
- return Section;
+MCSection *TargetLoweringObjectFileELF::getUniqueSectionForFunction(
+ const Function &F, const TargetMachine &TM) const {
+ SectionKind Kind = SectionKind::getText();
+ unsigned Flags = getELFSectionFlags(Kind);
+ return selectELFSectionForGlobal(getContext(), &F, Kind, getMangler(), TM,
+ /* EmitUniqueSection = */ true, Flags,
+ &NextUniqueID);
}
MCSection *TargetLoweringObjectFileELF::getSectionForJumpTable(