mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
Create symbols marking the start of a section earlier.
This lets us pass the symbol to the constructor and avoid the mutable field. This also opens the way for outputting the symbol only when needed, instead of outputting them at the start of the file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231859 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -236,11 +236,10 @@ MCSymbol *MCContext::LookupSymbol(const Twine &Name) const {
|
||||
// Section Management
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
const MCSectionMachO *MCContext::getMachOSection(StringRef Segment,
|
||||
StringRef Section,
|
||||
unsigned TypeAndAttributes,
|
||||
unsigned Reserved2,
|
||||
SectionKind Kind) {
|
||||
const MCSectionMachO *
|
||||
MCContext::getMachOSection(StringRef Segment, StringRef Section,
|
||||
unsigned TypeAndAttributes, unsigned Reserved2,
|
||||
SectionKind Kind, const char *BeginSymName) {
|
||||
|
||||
// We unique sections by their segment/section pair. The returned section
|
||||
// may not have the same flags as the requested section, if so this should be
|
||||
@@ -257,14 +256,19 @@ const MCSectionMachO *MCContext::getMachOSection(StringRef Segment,
|
||||
if (Entry)
|
||||
return Entry;
|
||||
|
||||
MCSymbol *Begin = nullptr;
|
||||
if (BeginSymName)
|
||||
Begin = createTempSymbol(BeginSymName);
|
||||
|
||||
// Otherwise, return a new section.
|
||||
return Entry = new (*this) MCSectionMachO(Segment, Section, TypeAndAttributes,
|
||||
Reserved2, Kind);
|
||||
Reserved2, Kind, Begin);
|
||||
}
|
||||
|
||||
const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
|
||||
unsigned Flags) {
|
||||
return getELFSection(Section, Type, Flags, 0, "");
|
||||
unsigned Flags,
|
||||
const char *BeginSymName) {
|
||||
return getELFSection(Section, Type, Flags, 0, "", BeginSymName);
|
||||
}
|
||||
|
||||
void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) {
|
||||
@@ -282,7 +286,8 @@ void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) {
|
||||
|
||||
const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
|
||||
unsigned Flags, unsigned EntrySize,
|
||||
StringRef Group, bool Unique) {
|
||||
StringRef Group, bool Unique,
|
||||
const char *BeginSymName) {
|
||||
// Do the lookup, if we have a hit, return it.
|
||||
auto IterBool = ELFUniquingMap.insert(
|
||||
std::make_pair(SectionGroupPair(Section, Group), nullptr));
|
||||
@@ -302,8 +307,12 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
|
||||
else
|
||||
Kind = SectionKind::getReadOnly();
|
||||
|
||||
MCSectionELF *Result = new (*this)
|
||||
MCSectionELF(CachedName, Type, Flags, Kind, EntrySize, GroupSym, Unique);
|
||||
MCSymbol *Begin = nullptr;
|
||||
if (BeginSymName)
|
||||
Begin = createTempSymbol(BeginSymName);
|
||||
|
||||
MCSectionELF *Result = new (*this) MCSectionELF(
|
||||
CachedName, Type, Flags, Kind, EntrySize, GroupSym, Unique, Begin);
|
||||
if (!Unique)
|
||||
Entry.second = Result;
|
||||
return Result;
|
||||
@@ -311,22 +320,23 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
|
||||
|
||||
const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
|
||||
unsigned Flags, unsigned EntrySize,
|
||||
StringRef Group) {
|
||||
return getELFSection(Section, Type, Flags, EntrySize, Group, false);
|
||||
StringRef Group,
|
||||
const char *BeginSymName) {
|
||||
return getELFSection(Section, Type, Flags, EntrySize, Group, false,
|
||||
BeginSymName);
|
||||
}
|
||||
|
||||
const MCSectionELF *MCContext::CreateELFGroupSection() {
|
||||
MCSectionELF *Result =
|
||||
new (*this) MCSectionELF(".group", ELF::SHT_GROUP, 0,
|
||||
SectionKind::getReadOnly(), 4, nullptr, false);
|
||||
MCSectionELF *Result = new (*this)
|
||||
MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4,
|
||||
nullptr, false, nullptr);
|
||||
return Result;
|
||||
}
|
||||
|
||||
const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
|
||||
unsigned Characteristics,
|
||||
SectionKind Kind,
|
||||
StringRef COMDATSymName,
|
||||
int Selection) {
|
||||
const MCSectionCOFF *
|
||||
MCContext::getCOFFSection(StringRef Section, unsigned Characteristics,
|
||||
SectionKind Kind, StringRef COMDATSymName,
|
||||
int Selection, const char *BeginSymName) {
|
||||
// Do the lookup, if we have a hit, return it.
|
||||
|
||||
SectionGroupTriple T(Section, COMDATSymName, Selection);
|
||||
@@ -339,9 +349,13 @@ const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
|
||||
if (!COMDATSymName.empty())
|
||||
COMDATSymbol = GetOrCreateSymbol(COMDATSymName);
|
||||
|
||||
MCSymbol *Begin = nullptr;
|
||||
if (BeginSymName)
|
||||
Begin = createTempSymbol(BeginSymName);
|
||||
|
||||
StringRef CachedName = std::get<0>(Iter->first);
|
||||
MCSectionCOFF *Result = new (*this)
|
||||
MCSectionCOFF(CachedName, Characteristics, COMDATSymbol, Selection, Kind);
|
||||
MCSectionCOFF *Result = new (*this) MCSectionCOFF(
|
||||
CachedName, Characteristics, COMDATSymbol, Selection, Kind, Begin);
|
||||
|
||||
Iter->second = Result;
|
||||
return Result;
|
||||
@@ -349,8 +363,9 @@ const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
|
||||
|
||||
const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
|
||||
unsigned Characteristics,
|
||||
SectionKind Kind) {
|
||||
return getCOFFSection(Section, Characteristics, Kind, "", 0);
|
||||
SectionKind Kind,
|
||||
const char *BeginSymName) {
|
||||
return getCOFFSection(Section, Characteristics, Kind, "", 0, BeginSymName);
|
||||
}
|
||||
|
||||
const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) {
|
||||
|
Reference in New Issue
Block a user