Changeset View
Changeset View
Standalone View
Standalone View
lib/MC/MCContext.cpp
Show First 20 Lines • Show All 306 Lines • ▼ Show 20 Lines | void MCContext::renameELFSection(MCSectionELF *Section, StringRef Name) { | ||||
const_cast<MCSectionELF *>(Section)->setSectionName(CachedName); | const_cast<MCSectionELF *>(Section)->setSectionName(CachedName); | ||||
} | } | ||||
MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type, | MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type, | ||||
unsigned Flags, SectionKind K, | unsigned Flags, SectionKind K, | ||||
unsigned EntrySize, | unsigned EntrySize, | ||||
const MCSymbolELF *Group, | const MCSymbolELF *Group, | ||||
unsigned UniqueID, | unsigned UniqueID, | ||||
const MCSectionELF *Associated) { | const MCSymbolELF *Associated) { | ||||
MCSymbolELF *R; | MCSymbolELF *R; | ||||
MCSymbol *&Sym = Symbols[Section]; | MCSymbol *&Sym = Symbols[Section]; | ||||
if (Sym && Sym->isUndefined()) { | if (Sym && Sym->isUndefined()) { | ||||
R = cast<MCSymbolELF>(Sym); | R = cast<MCSymbolELF>(Sym); | ||||
} else { | } else { | ||||
auto NameIter = UsedNames.insert(std::make_pair(Section, false)).first; | auto NameIter = UsedNames.insert(std::make_pair(Section, false)).first; | ||||
R = new (&*NameIter, *this) MCSymbolELF(&*NameIter, /*isTemporary*/ false); | R = new (&*NameIter, *this) MCSymbolELF(&*NameIter, /*isTemporary*/ false); | ||||
if (!Sym) | if (!Sym) | ||||
Show All 12 Lines | MCSectionELF *MCContext::createELFSectionImpl(StringRef Section, unsigned Type, | ||||
R->setFragment(F); | R->setFragment(F); | ||||
return Ret; | return Ret; | ||||
} | } | ||||
MCSectionELF *MCContext::createELFRelSection(const Twine &Name, unsigned Type, | MCSectionELF *MCContext::createELFRelSection(const Twine &Name, unsigned Type, | ||||
unsigned Flags, unsigned EntrySize, | unsigned Flags, unsigned EntrySize, | ||||
const MCSymbolELF *Group, | const MCSymbolELF *Group, | ||||
const MCSectionELF *Associated) { | const MCSectionELF *RelInfoSection) { | ||||
StringMap<bool>::iterator I; | StringMap<bool>::iterator I; | ||||
bool Inserted; | bool Inserted; | ||||
std::tie(I, Inserted) = | std::tie(I, Inserted) = | ||||
ELFRelSecNames.insert(std::make_pair(Name.str(), true)); | ELFRelSecNames.insert(std::make_pair(Name.str(), true)); | ||||
return createELFSectionImpl(I->getKey(), Type, Flags, | MCSectionELF *Section = | ||||
SectionKind::getReadOnly(), EntrySize, Group, | createELFSectionImpl(I->getKey(), Type, Flags, SectionKind::getReadOnly(), | ||||
true, Associated); | EntrySize, Group, true, nullptr); | ||||
Section->setRelInfoSection(RelInfoSection); | |||||
return Section; | |||||
} | } | ||||
MCSectionELF *MCContext::getELFNamedSection(const Twine &Prefix, | MCSectionELF *MCContext::getELFNamedSection(const Twine &Prefix, | ||||
const Twine &Suffix, unsigned Type, | const Twine &Suffix, unsigned Type, | ||||
unsigned Flags, | unsigned Flags, | ||||
unsigned EntrySize) { | unsigned EntrySize) { | ||||
return getELFSection(Prefix + "." + Suffix, Type, Flags, EntrySize, Suffix); | return getELFSection(Prefix + "." + Suffix, Type, Flags, EntrySize, Suffix); | ||||
} | } | ||||
MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type, | MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type, | ||||
unsigned Flags, unsigned EntrySize, | unsigned Flags, unsigned EntrySize, | ||||
const Twine &Group, unsigned UniqueID, | const Twine &Group, unsigned UniqueID, | ||||
const MCSectionELF *Associated) { | const MCSymbolELF *Associated) { | ||||
MCSymbolELF *GroupSym = nullptr; | MCSymbolELF *GroupSym = nullptr; | ||||
if (!Group.isTriviallyEmpty() && !Group.str().empty()) | if (!Group.isTriviallyEmpty() && !Group.str().empty()) | ||||
GroupSym = cast<MCSymbolELF>(getOrCreateSymbol(Group)); | GroupSym = cast<MCSymbolELF>(getOrCreateSymbol(Group)); | ||||
return getELFSection(Section, Type, Flags, EntrySize, GroupSym, UniqueID, | return getELFSection(Section, Type, Flags, EntrySize, GroupSym, UniqueID, | ||||
Associated); | Associated); | ||||
} | } | ||||
MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type, | MCSectionELF *MCContext::getELFSection(const Twine &Section, unsigned Type, | ||||
unsigned Flags, unsigned EntrySize, | unsigned Flags, unsigned EntrySize, | ||||
const MCSymbolELF *GroupSym, | const MCSymbolELF *GroupSym, | ||||
unsigned UniqueID, | unsigned UniqueID, | ||||
const MCSectionELF *Associated) { | const MCSymbolELF *Associated) { | ||||
StringRef Group = ""; | StringRef Group = ""; | ||||
if (GroupSym) | if (GroupSym) | ||||
Group = GroupSym->getName(); | Group = GroupSym->getName(); | ||||
// Do the lookup, if we have a hit, return it. | // Do the lookup, if we have a hit, return it. | ||||
auto IterBool = ELFUniquingMap.insert( | auto IterBool = ELFUniquingMap.insert( | ||||
std::make_pair(ELFSectionKey{Section.str(), Group, UniqueID}, nullptr)); | std::make_pair(ELFSectionKey{Section.str(), Group, UniqueID}, nullptr)); | ||||
auto &Entry = *IterBool.first; | auto &Entry = *IterBool.first; | ||||
if (!IterBool.second) | if (!IterBool.second) | ||||
▲ Show 20 Lines • Show All 161 Lines • Show Last 20 Lines |