summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/MCContext.cpp')
-rw-r--r--llvm/lib/MC/MCContext.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 9d8a57e55f6..3ac8d658873 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -113,6 +113,23 @@ MCSymbol *MCContext::GetOrCreateSymbol(StringRef Name) {
return Sym;
}
+MCSymbol *MCContext::getOrCreateSectionSymbol(const MCSectionELF &Section) {
+ MCSymbol *&Sym = SectionSymbols[&Section];
+ if (Sym)
+ return Sym;
+
+ StringRef Name = Section.getSectionName();
+ StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name);
+ NameEntry->setValue(true);
+ Sym = new (*this) MCSymbol(NameEntry->getKey(), /*isTemporary*/ false);
+
+ StringMapEntry<MCSymbol*> &Entry = Symbols.GetOrCreateValue(Name);
+ if (!Entry.getValue())
+ Entry.setValue(Sym);
+
+ return Sym;
+}
+
MCSymbol *MCContext::CreateSymbol(StringRef Name) {
// Determine whether this is an assembler temporary or normal label, if used.
bool isTemporary = false;
OpenPOWER on IntegriCloud