SecureLog = nullptr;
SecureLogUsed = false;
- if (SrcMgr && SrcMgr->getNumBuffers() > 0)
- MainFileName = SrcMgr->getMemoryBuffer(0)->getBufferIdentifier();
+ if (SrcMgr && SrcMgr->getNumBuffers())
+ MainFileName =
+ SrcMgr->getMemoryBuffer(SrcMgr->getMainFileID())->getBufferIdentifier();
}
MCContext::~MCContext() {
Symbols.clear();
Allocator.Reset();
Instances.clear();
+ CompilationDir.clear();
+ MainFileName.clear();
MCDwarfLineTablesCUMap.clear();
+ SectionStartEndSyms.clear();
MCGenDwarfLabelEntries.clear();
DwarfDebugFlags = StringRef();
DwarfCompileUnitID = 0;
return Sym;
}
+MCSymbol *MCContext::getOrCreateSectionSymbol(const MCSectionELF &Section) {
+ MCSymbol *&Sym = SectionSymbols[&Section];
+ if (Sym)
+ return Sym;
+
+ StringRef Name = Section.getSectionName();
+
+ StringMapEntry<MCSymbol*> &Entry = Symbols.GetOrCreateValue(Name);
+ MCSymbol *OldSym = Entry.getValue();
+ if (OldSym && OldSym->isUndefined()) {
+ Sym = OldSym;
+ return OldSym;
+ }
+
+ StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name);
+ NameEntry->setValue(true);
+ Sym = new (*this) MCSymbol(NameEntry->getKey(), /*isTemporary*/ false);
+
+ 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;
if (!IterBool.second)
return Iter->second;
- const MCSymbol *COMDATSymbol = nullptr;
+ MCSymbol *COMDATSymbol = nullptr;
if (!COMDATSymName.empty())
COMDATSymbol = GetOrCreateSymbol(COMDATSymName);
return Iter->second;
}
+const MCSectionCOFF *
+MCContext::getAssociativeCOFFSection(const MCSectionCOFF *Sec,
+ const MCSymbol *KeySym) {
+ // Return the normal section if we don't have to be associative.
+ if (!KeySym)
+ return Sec;
+
+ // Make an associative section with the same name and kind as the normal
+ // section.
+ unsigned Characteristics =
+ Sec->getCharacteristics() | COFF::IMAGE_SCN_LNK_COMDAT;
+ return getCOFFSection(Sec->getSectionName(), Characteristics, Sec->getKind(),
+ KeySym->getName(),
+ COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE);
+}
+
//===----------------------------------------------------------------------===//
// Dwarf Management
//===----------------------------------------------------------------------===//