aboutsummaryrefslogtreecommitdiff
path: root/lib/MC/MCContext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MC/MCContext.cpp')
-rw-r--r--lib/MC/MCContext.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp
index 6a6841a48d..dc757bb0bf 100644
--- a/lib/MC/MCContext.cpp
+++ b/lib/MC/MCContext.cpp
@@ -10,16 +10,19 @@
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCSectionMachO.h"
+#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Twine.h"
using namespace llvm;
typedef StringMap<const MCSectionMachO*> MachOUniqueMapTy;
+typedef StringMap<const MCSectionELF*> ELFUniqueMapTy;
MCContext::MCContext(const MCAsmInfo &mai) : MAI(mai), NextUniqueID(0) {
MachOUniquingMap = 0;
+ ELFUniquingMap = 0;
}
MCContext::~MCContext() {
@@ -28,6 +31,7 @@ MCContext::~MCContext() {
// If we have the MachO uniquing map, free it.
delete (MachOUniqueMapTy*)MachOUniquingMap;
+ delete (ELFUniqueMapTy*)ELFUniquingMap;
}
//===----------------------------------------------------------------------===//
@@ -96,6 +100,26 @@ getMachOSection(StringRef Segment, StringRef Section,
if (Entry) return Entry;
// Otherwise, return a new section.
- return Entry = MCSectionMachO::Create(Segment, Section, TypeAndAttributes,
- Reserved2, Kind, *this);
+ return Entry = new (*this) MCSectionMachO(Segment, Section, TypeAndAttributes,
+ Reserved2, Kind);
}
+
+
+const MCSection *MCContext::
+getELFSection(StringRef Section, unsigned Type, unsigned Flags,
+ SectionKind Kind, bool IsExplicit) {
+ if (ELFUniquingMap == 0)
+ ELFUniquingMap = new ELFUniqueMapTy();
+ ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)ELFUniquingMap;
+
+ // Do the lookup, if we have a hit, return it.
+ StringMapEntry<const MCSectionELF*> &Entry = Map.GetOrCreateValue(Section);
+ if (Entry.getValue()) return Entry.getValue();
+
+ MCSectionELF *Result = new (*this) MCSectionELF(Entry.getKey(), Type, Flags,
+ Kind, IsExplicit);
+ Entry.setValue(Result);
+ return Result;
+}
+
+