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:
Rafael Espindola 2015-03-10 22:00:25 +00:00
parent a1cc020e29
commit f3d745cdc9
11 changed files with 152 additions and 126 deletions

View File

@ -258,23 +258,30 @@ namespace llvm {
/// the operands to be valid. /// the operands to be valid.
const MCSectionMachO *getMachOSection(StringRef Segment, StringRef Section, const MCSectionMachO *getMachOSection(StringRef Segment, StringRef Section,
unsigned TypeAndAttributes, unsigned TypeAndAttributes,
unsigned Reserved2, SectionKind K); unsigned Reserved2, SectionKind K,
const char *BeginSymName = nullptr);
const MCSectionMachO *getMachOSection(StringRef Segment, StringRef Section, const MCSectionMachO *getMachOSection(StringRef Segment, StringRef Section,
unsigned TypeAndAttributes, unsigned TypeAndAttributes,
SectionKind K) { SectionKind K,
return getMachOSection(Segment, Section, TypeAndAttributes, 0, K); const char *BeginSymName = nullptr) {
return getMachOSection(Segment, Section, TypeAndAttributes, 0, K,
BeginSymName);
} }
const MCSectionELF *getELFSection(StringRef Section, unsigned Type, const MCSectionELF *getELFSection(StringRef Section, unsigned Type,
unsigned Flags); unsigned Flags,
const char *BeginSymName = nullptr);
const MCSectionELF *getELFSection(StringRef Section, unsigned Type, const MCSectionELF *getELFSection(StringRef Section, unsigned Type,
unsigned Flags, unsigned EntrySize, unsigned Flags, unsigned EntrySize,
StringRef Group); StringRef Group,
const char *BeginSymName = nullptr);
const MCSectionELF *getELFSection(StringRef Section, unsigned Type, const MCSectionELF *getELFSection(StringRef Section, unsigned Type,
unsigned Flags, unsigned EntrySize, unsigned Flags, unsigned EntrySize,
StringRef Group, bool Unique); StringRef Group, bool Unique,
const char *BeginSymName = nullptr);
void renameELFSection(const MCSectionELF *Section, StringRef Name); void renameELFSection(const MCSectionELF *Section, StringRef Name);
@ -283,11 +290,13 @@ namespace llvm {
const MCSectionCOFF *getCOFFSection(StringRef Section, const MCSectionCOFF *getCOFFSection(StringRef Section,
unsigned Characteristics, unsigned Characteristics,
SectionKind Kind, SectionKind Kind,
StringRef COMDATSymName, int Selection); StringRef COMDATSymName, int Selection,
const char *BeginSymName = nullptr);
const MCSectionCOFF *getCOFFSection(StringRef Section, const MCSectionCOFF *getCOFFSection(StringRef Section,
unsigned Characteristics, unsigned Characteristics,
SectionKind Kind); SectionKind Kind,
const char *BeginSymName = nullptr);
const MCSectionCOFF *getCOFFSection(StringRef Section); const MCSectionCOFF *getCOFFSection(StringRef Section);

View File

@ -34,11 +34,11 @@ private:
MCSection(const MCSection &) = delete; MCSection(const MCSection &) = delete;
void operator=(const MCSection &) = delete; void operator=(const MCSection &) = delete;
mutable const MCSymbol *Begin; MCSymbol *Begin;
protected: protected:
MCSection(SectionVariant V, SectionKind K) MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
: Begin(nullptr), Variant(V), Kind(K) {} : Begin(Begin), Variant(V), Kind(K) {}
SectionVariant Variant; SectionVariant Variant;
SectionKind Kind; SectionKind Kind;
@ -49,12 +49,7 @@ public:
SectionVariant getVariant() const { return Variant; } SectionVariant getVariant() const { return Variant; }
const MCSymbol *getBeginSymbol() const { return Begin; } MCSymbol *getBeginSymbol() const { return Begin; }
void setBeginSymbol(const MCSymbol &L) const {
assert(!Begin);
Begin = &L;
}
virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS, virtual void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS,
const MCExpr *Subsection) const = 0; const MCExpr *Subsection) const = 0;

View File

@ -45,8 +45,9 @@ class MCSymbol;
private: private:
friend class MCContext; friend class MCContext;
MCSectionCOFF(StringRef Section, unsigned Characteristics, MCSectionCOFF(StringRef Section, unsigned Characteristics,
MCSymbol *COMDATSymbol, int Selection, SectionKind K) MCSymbol *COMDATSymbol, int Selection, SectionKind K,
: MCSection(SV_COFF, K), SectionName(Section), MCSymbol *Begin)
: MCSection(SV_COFF, K, Begin), SectionName(Section),
Characteristics(Characteristics), COMDATSymbol(COMDATSymbol), Characteristics(Characteristics), COMDATSymbol(COMDATSymbol),
Selection(Selection) { Selection(Selection) {
assert ((Characteristics & 0x00F00000) == 0 && assert ((Characteristics & 0x00F00000) == 0 &&

View File

@ -51,9 +51,10 @@ class MCSectionELF : public MCSection {
private: private:
friend class MCContext; friend class MCContext;
MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K, MCSectionELF(StringRef Section, unsigned type, unsigned flags, SectionKind K,
unsigned entrySize, const MCSymbol *group, bool Unique) unsigned entrySize, const MCSymbol *group, bool Unique,
: MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags), MCSymbol *Begin)
Unique(Unique), EntrySize(entrySize), Group(group) {} : MCSection(SV_ELF, K, Begin), SectionName(Section), Type(type),
Flags(flags), Unique(Unique), EntrySize(entrySize), Group(group) {}
~MCSectionELF(); ~MCSectionELF();
void setSectionName(StringRef Name) { SectionName = Name; } void setSectionName(StringRef Name) { SectionName = Name; }

View File

@ -35,8 +35,8 @@ class MCSectionMachO : public MCSection {
/// size of stubs, for example. /// size of stubs, for example.
unsigned Reserved2; unsigned Reserved2;
MCSectionMachO(StringRef Segment, StringRef Section, MCSectionMachO(StringRef Segment, StringRef Section, unsigned TAA,
unsigned TAA, unsigned reserved2, SectionKind K); unsigned reserved2, SectionKind K, MCSymbol *Begin);
friend class MCContext; friend class MCContext;
public: public:

View File

@ -243,12 +243,10 @@ DwarfDebug::~DwarfDebug() { }
// Switch to the specified MCSection and emit an assembler // Switch to the specified MCSection and emit an assembler
// temporary label to it if SymbolStem is specified. // temporary label to it if SymbolStem is specified.
static void emitSectionSym(AsmPrinter *Asm, const MCSection *Section, static void emitSectionSym(AsmPrinter *Asm, const MCSection *Section) {
StringRef SymbolStem) {
Asm->OutStreamer.SwitchSection(Section); Asm->OutStreamer.SwitchSection(Section);
MCSymbol *TmpSym = Asm->GetTempSymbol(SymbolStem); MCSymbol *TmpSym = Section->getBeginSymbol();
Asm->OutStreamer.EmitLabel(TmpSym); Asm->OutStreamer.EmitLabel(TmpSym);
Section->setBeginSymbol(*TmpSym);
} }
static bool isObjCClass(StringRef Name) { static bool isObjCClass(StringRef Name) {
@ -628,7 +626,7 @@ void DwarfDebug::endModule() {
// If we aren't actually generating debug info (check beginModule - // If we aren't actually generating debug info (check beginModule -
// conditionalized on !DisableDebugInfoPrinting and the presence of the // conditionalized on !DisableDebugInfoPrinting and the presence of the
// llvm.dbg.cu metadata node) // llvm.dbg.cu metadata node)
if (!TLOF.getDwarfInfoSection()->getBeginSymbol()) if (!TLOF.getDwarfInfoSection()->getBeginSymbol()->isInSection())
return; return;
// Finalize the debug info for the module. // Finalize the debug info for the module.
@ -1306,24 +1304,24 @@ void DwarfDebug::emitSectionLabels() {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering(); const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
// Dwarf sections base addresses. // Dwarf sections base addresses.
emitSectionSym(Asm, TLOF.getDwarfInfoSection(), "section_info"); emitSectionSym(Asm, TLOF.getDwarfInfoSection());
if (useSplitDwarf()) { if (useSplitDwarf()) {
emitSectionSym(Asm, TLOF.getDwarfInfoDWOSection(), "section_info_dwo"); emitSectionSym(Asm, TLOF.getDwarfInfoDWOSection());
emitSectionSym(Asm, TLOF.getDwarfTypesDWOSection(), "section_types_dwo"); emitSectionSym(Asm, TLOF.getDwarfTypesDWOSection());
} }
emitSectionSym(Asm, TLOF.getDwarfAbbrevSection(), "section_abbrev"); emitSectionSym(Asm, TLOF.getDwarfAbbrevSection());
if (useSplitDwarf()) if (useSplitDwarf())
emitSectionSym(Asm, TLOF.getDwarfAbbrevDWOSection(), "section_abbrev_dwo"); emitSectionSym(Asm, TLOF.getDwarfAbbrevDWOSection());
emitSectionSym(Asm, TLOF.getDwarfLineSection(), "section_line"); emitSectionSym(Asm, TLOF.getDwarfLineSection());
emitSectionSym(Asm, TLOF.getDwarfStrSection(), "info_string"); emitSectionSym(Asm, TLOF.getDwarfStrSection());
if (useSplitDwarf()) { if (useSplitDwarf()) {
emitSectionSym(Asm, TLOF.getDwarfStrDWOSection(), "skel_string"); emitSectionSym(Asm, TLOF.getDwarfStrDWOSection());
emitSectionSym(Asm, TLOF.getDwarfAddrSection(), "addr_sec"); emitSectionSym(Asm, TLOF.getDwarfAddrSection());
emitSectionSym(Asm, TLOF.getDwarfLocDWOSection(), "skel_loc"); emitSectionSym(Asm, TLOF.getDwarfLocDWOSection());
} else } else
emitSectionSym(Asm, TLOF.getDwarfLocSection(), "section_debug_loc"); emitSectionSym(Asm, TLOF.getDwarfLocSection());
emitSectionSym(Asm, TLOF.getDwarfRangesSection(), "debug_range"); emitSectionSym(Asm, TLOF.getDwarfRangesSection());
} }
// Emit the debug info section. // Emit the debug info section.
@ -1364,9 +1362,9 @@ void DwarfDebug::emitEndOfLineMatrix(unsigned SectionEnd) {
} }
void DwarfDebug::emitAccel(DwarfAccelTable &Accel, const MCSection *Section, void DwarfDebug::emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
StringRef TableName, StringRef SymName) { StringRef TableName) {
Accel.FinalizeTable(Asm, TableName); Accel.FinalizeTable(Asm, TableName);
emitSectionSym(Asm, Section, SymName); emitSectionSym(Asm, Section);
// Emit the full data. // Emit the full data.
Accel.emit(Asm, Section->getBeginSymbol(), this); Accel.emit(Asm, Section->getBeginSymbol(), this);
@ -1375,27 +1373,27 @@ void DwarfDebug::emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
// Emit visible names into a hashed accelerator table section. // Emit visible names into a hashed accelerator table section.
void DwarfDebug::emitAccelNames() { void DwarfDebug::emitAccelNames() {
emitAccel(AccelNames, Asm->getObjFileLowering().getDwarfAccelNamesSection(), emitAccel(AccelNames, Asm->getObjFileLowering().getDwarfAccelNamesSection(),
"Names", "names_begin"); "Names");
} }
// Emit objective C classes and categories into a hashed accelerator table // Emit objective C classes and categories into a hashed accelerator table
// section. // section.
void DwarfDebug::emitAccelObjC() { void DwarfDebug::emitAccelObjC() {
emitAccel(AccelObjC, Asm->getObjFileLowering().getDwarfAccelObjCSection(), emitAccel(AccelObjC, Asm->getObjFileLowering().getDwarfAccelObjCSection(),
"ObjC", "objc_begin"); "ObjC");
} }
// Emit namespace dies into a hashed accelerator table. // Emit namespace dies into a hashed accelerator table.
void DwarfDebug::emitAccelNamespaces() { void DwarfDebug::emitAccelNamespaces() {
emitAccel(AccelNamespace, emitAccel(AccelNamespace,
Asm->getObjFileLowering().getDwarfAccelNamespaceSection(), Asm->getObjFileLowering().getDwarfAccelNamespaceSection(),
"namespac", "namespac_begin"); "namespac");
} }
// Emit type dies into a hashed accelerator table. // Emit type dies into a hashed accelerator table.
void DwarfDebug::emitAccelTypes() { void DwarfDebug::emitAccelTypes() {
emitAccel(AccelTypes, Asm->getObjFileLowering().getDwarfAccelTypesSection(), emitAccel(AccelTypes, Asm->getObjFileLowering().getDwarfAccelTypesSection(),
"types", "types_begin"); "types");
} }
// Public name handling. // Public name handling.

View File

@ -371,7 +371,7 @@ class DwarfDebug : public AsmPrinterHandler {
/// \brief Emit a specified accelerator table. /// \brief Emit a specified accelerator table.
void emitAccel(DwarfAccelTable &Accel, const MCSection *Section, void emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
StringRef TableName, StringRef SymName); StringRef TableName);
/// \brief Emit visible names into a hashed accelerator table section. /// \brief Emit visible names into a hashed accelerator table section.
void emitAccelNames(); void emitAccelNames();

View File

@ -236,11 +236,10 @@ MCSymbol *MCContext::LookupSymbol(const Twine &Name) const {
// Section Management // Section Management
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
const MCSectionMachO *MCContext::getMachOSection(StringRef Segment, const MCSectionMachO *
StringRef Section, MCContext::getMachOSection(StringRef Segment, StringRef Section,
unsigned TypeAndAttributes, unsigned TypeAndAttributes, unsigned Reserved2,
unsigned Reserved2, SectionKind Kind, const char *BeginSymName) {
SectionKind Kind) {
// We unique sections by their segment/section pair. The returned section // 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 // 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) if (Entry)
return Entry; return Entry;
MCSymbol *Begin = nullptr;
if (BeginSymName)
Begin = createTempSymbol(BeginSymName);
// Otherwise, return a new section. // Otherwise, return a new section.
return Entry = new (*this) MCSectionMachO(Segment, Section, TypeAndAttributes, return Entry = new (*this) MCSectionMachO(Segment, Section, TypeAndAttributes,
Reserved2, Kind); Reserved2, Kind, Begin);
} }
const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
unsigned Flags) { unsigned Flags,
return getELFSection(Section, Type, Flags, 0, ""); const char *BeginSymName) {
return getELFSection(Section, Type, Flags, 0, "", BeginSymName);
} }
void MCContext::renameELFSection(const MCSectionELF *Section, StringRef Name) { 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, const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
unsigned Flags, unsigned EntrySize, 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. // Do the lookup, if we have a hit, return it.
auto IterBool = ELFUniquingMap.insert( auto IterBool = ELFUniquingMap.insert(
std::make_pair(SectionGroupPair(Section, Group), nullptr)); std::make_pair(SectionGroupPair(Section, Group), nullptr));
@ -302,8 +307,12 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
else else
Kind = SectionKind::getReadOnly(); Kind = SectionKind::getReadOnly();
MCSectionELF *Result = new (*this) MCSymbol *Begin = nullptr;
MCSectionELF(CachedName, Type, Flags, Kind, EntrySize, GroupSym, Unique); if (BeginSymName)
Begin = createTempSymbol(BeginSymName);
MCSectionELF *Result = new (*this) MCSectionELF(
CachedName, Type, Flags, Kind, EntrySize, GroupSym, Unique, Begin);
if (!Unique) if (!Unique)
Entry.second = Result; Entry.second = Result;
return Result; return Result;
@ -311,22 +320,23 @@ const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type, const MCSectionELF *MCContext::getELFSection(StringRef Section, unsigned Type,
unsigned Flags, unsigned EntrySize, unsigned Flags, unsigned EntrySize,
StringRef Group) { StringRef Group,
return getELFSection(Section, Type, Flags, EntrySize, Group, false); const char *BeginSymName) {
return getELFSection(Section, Type, Flags, EntrySize, Group, false,
BeginSymName);
} }
const MCSectionELF *MCContext::CreateELFGroupSection() { const MCSectionELF *MCContext::CreateELFGroupSection() {
MCSectionELF *Result = MCSectionELF *Result = new (*this)
new (*this) MCSectionELF(".group", ELF::SHT_GROUP, 0, MCSectionELF(".group", ELF::SHT_GROUP, 0, SectionKind::getReadOnly(), 4,
SectionKind::getReadOnly(), 4, nullptr, false); nullptr, false, nullptr);
return Result; return Result;
} }
const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, const MCSectionCOFF *
unsigned Characteristics, MCContext::getCOFFSection(StringRef Section, unsigned Characteristics,
SectionKind Kind, SectionKind Kind, StringRef COMDATSymName,
StringRef COMDATSymName, int Selection, const char *BeginSymName) {
int Selection) {
// Do the lookup, if we have a hit, return it. // Do the lookup, if we have a hit, return it.
SectionGroupTriple T(Section, COMDATSymName, Selection); SectionGroupTriple T(Section, COMDATSymName, Selection);
@ -339,9 +349,13 @@ const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
if (!COMDATSymName.empty()) if (!COMDATSymName.empty())
COMDATSymbol = GetOrCreateSymbol(COMDATSymName); COMDATSymbol = GetOrCreateSymbol(COMDATSymName);
MCSymbol *Begin = nullptr;
if (BeginSymName)
Begin = createTempSymbol(BeginSymName);
StringRef CachedName = std::get<0>(Iter->first); StringRef CachedName = std::get<0>(Iter->first);
MCSectionCOFF *Result = new (*this) MCSectionCOFF *Result = new (*this) MCSectionCOFF(
MCSectionCOFF(CachedName, Characteristics, COMDATSymbol, Selection, Kind); CachedName, Characteristics, COMDATSymbol, Selection, Kind, Begin);
Iter->second = Result; Iter->second = Result;
return Result; return Result;
@ -349,8 +363,9 @@ const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section, const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section,
unsigned Characteristics, unsigned Characteristics,
SectionKind Kind) { SectionKind Kind,
return getCOFFSection(Section, Characteristics, Kind, "", 0); const char *BeginSymName) {
return getCOFFSection(Section, Characteristics, Kind, "", 0, BeginSymName);
} }
const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) { const MCSectionCOFF *MCContext::getCOFFSection(StringRef Section) {

View File

@ -184,27 +184,27 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
// Debug Information. // Debug Information.
DwarfAccelNamesSection = DwarfAccelNamesSection =
Ctx->getMachOSection("__DWARF", "__apple_names", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__apple_names", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "names_begin");
DwarfAccelObjCSection = DwarfAccelObjCSection =
Ctx->getMachOSection("__DWARF", "__apple_objc", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__apple_objc", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "objc_begin");
// 16 character section limit... // 16 character section limit...
DwarfAccelNamespaceSection = DwarfAccelNamespaceSection =
Ctx->getMachOSection("__DWARF", "__apple_namespac", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__apple_namespac", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "namespac_begin");
DwarfAccelTypesSection = DwarfAccelTypesSection =
Ctx->getMachOSection("__DWARF", "__apple_types", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__apple_types", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "types_begin");
DwarfAbbrevSection = DwarfAbbrevSection =
Ctx->getMachOSection("__DWARF", "__debug_abbrev", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__debug_abbrev", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_abbrev");
DwarfInfoSection = DwarfInfoSection =
Ctx->getMachOSection("__DWARF", "__debug_info", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__debug_info", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_info");
DwarfLineSection = DwarfLineSection =
Ctx->getMachOSection("__DWARF", "__debug_line", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__debug_line", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_line");
DwarfFrameSection = DwarfFrameSection =
Ctx->getMachOSection("__DWARF", "__debug_frame", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__debug_frame", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
@ -222,16 +222,16 @@ void MCObjectFileInfo::InitMachOMCObjectFileInfo(Triple T) {
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfStrSection = DwarfStrSection =
Ctx->getMachOSection("__DWARF", "__debug_str", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__debug_str", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "info_string");
DwarfLocSection = DwarfLocSection =
Ctx->getMachOSection("__DWARF", "__debug_loc", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__debug_loc", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_debug_loc");
DwarfARangesSection = DwarfARangesSection =
Ctx->getMachOSection("__DWARF", "__debug_aranges", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__debug_aranges", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
DwarfRangesSection = DwarfRangesSection =
Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata(), "debug_range");
DwarfDebugInlineSection = DwarfDebugInlineSection =
Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG, Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata()); SectionKind::getMetadata());
@ -455,10 +455,12 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
COFFDebugSymbolsSection = nullptr; COFFDebugSymbolsSection = nullptr;
// Debug Info Sections. // Debug Info Sections.
DwarfAbbrevSection = DwarfAbbrevSection = Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0,
Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0); "section_abbrev");
DwarfInfoSection = Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0); DwarfInfoSection =
DwarfLineSection = Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0, "section_info");
DwarfLineSection =
Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0, "section_line");
DwarfFrameSection = Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0); DwarfFrameSection = Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0);
DwarfPubNamesSection = DwarfPubNamesSection =
Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0);
@ -468,44 +470,46 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0);
DwarfGnuPubTypesSection = DwarfGnuPubTypesSection =
Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0);
DwarfStrSection = DwarfStrSection = Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS,
Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "",
ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); "info_string");
DwarfLocSection = Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0); DwarfLocSection = Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0,
"section_debug_loc");
DwarfARangesSection = DwarfARangesSection =
Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0);
DwarfRangesSection = DwarfRangesSection =
Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0, "debug_range");
// DWARF5 Experimental Debug Info // DWARF5 Experimental Debug Info
// Accelerator Tables // Accelerator Tables
DwarfAccelNamesSection = DwarfAccelNamesSection =
Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0, "names_begin");
DwarfAccelObjCSection = DwarfAccelObjCSection =
Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0, "objc_begin");
DwarfAccelNamespaceSection = DwarfAccelNamespaceSection = Ctx->getELFSection(
Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0); ".apple_namespaces", ELF::SHT_PROGBITS, 0, "namespac_begin");
DwarfAccelTypesSection = DwarfAccelTypesSection =
Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0, "types_begin");
// Fission Sections // Fission Sections
DwarfInfoDWOSection = DwarfInfoDWOSection = Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS,
Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0); 0, "section_info_dwo");
DwarfTypesDWOSection = DwarfTypesDWOSection = Ctx->getELFSection(
Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS, 0); ".debug_types.dwo", ELF::SHT_PROGBITS, 0, "section_types_dwo");
DwarfAbbrevDWOSection = DwarfAbbrevDWOSection = Ctx->getELFSection(
Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0); ".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0, "section_abbrev_dwo");
DwarfStrDWOSection = DwarfStrDWOSection = Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS,
Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS, ELF::SHF_MERGE | ELF::SHF_STRINGS, 1,
ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, ""); "", "skel_string");
DwarfLineDWOSection = DwarfLineDWOSection =
Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0);
DwarfLocDWOSection = DwarfLocDWOSection =
Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0, "skel_loc");
DwarfStrOffDWOSection = DwarfStrOffDWOSection =
Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0); Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0);
DwarfAddrSection = Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0); DwarfAddrSection =
Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0, "addr_sec");
StackMapSection = StackMapSection =
Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC); Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
@ -581,17 +585,18 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
".debug_abbrev", ".debug_abbrev",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_abbrev");
DwarfInfoSection = Ctx->getCOFFSection( DwarfInfoSection = Ctx->getCOFFSection(
".debug_info", ".debug_info",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_info");
DwarfLineSection = Ctx->getCOFFSection( DwarfLineSection = Ctx->getCOFFSection(
".debug_line", ".debug_line",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_line");
DwarfFrameSection = Ctx->getCOFFSection( DwarfFrameSection = Ctx->getCOFFSection(
".debug_frame", ".debug_frame",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
@ -621,12 +626,12 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
".debug_str", ".debug_str",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "info_string");
DwarfLocSection = Ctx->getCOFFSection( DwarfLocSection = Ctx->getCOFFSection(
".debug_loc", ".debug_loc",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_debug_loc");
DwarfARangesSection = Ctx->getCOFFSection( DwarfARangesSection = Ctx->getCOFFSection(
".debug_aranges", ".debug_aranges",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
@ -636,12 +641,12 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
".debug_ranges", ".debug_ranges",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "debug_range");
DwarfInfoDWOSection = Ctx->getCOFFSection( DwarfInfoDWOSection = Ctx->getCOFFSection(
".debug_info.dwo", ".debug_info.dwo",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_info_dwo");
DwarfTypesDWOSection = Ctx->getCOFFSection( DwarfTypesDWOSection = Ctx->getCOFFSection(
".debug_types.dwo", ".debug_types.dwo",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
@ -651,12 +656,12 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
".debug_abbrev.dwo", ".debug_abbrev.dwo",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "section_abbrev_dwo");
DwarfStrDWOSection = Ctx->getCOFFSection( DwarfStrDWOSection = Ctx->getCOFFSection(
".debug_str.dwo", ".debug_str.dwo",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "skel_string");
DwarfLineDWOSection = Ctx->getCOFFSection( DwarfLineDWOSection = Ctx->getCOFFSection(
".debug_line.dwo", ".debug_line.dwo",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
@ -666,7 +671,7 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
".debug_loc.dwo", ".debug_loc.dwo",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "skel_loc");
DwarfStrOffDWOSection = Ctx->getCOFFSection( DwarfStrOffDWOSection = Ctx->getCOFFSection(
".debug_str_offsets.dwo", ".debug_str_offsets.dwo",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
@ -676,27 +681,27 @@ void MCObjectFileInfo::InitCOFFMCObjectFileInfo(Triple T) {
".debug_addr", ".debug_addr",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "addr_sec");
DwarfAccelNamesSection = Ctx->getCOFFSection( DwarfAccelNamesSection = Ctx->getCOFFSection(
".apple_names", ".apple_names",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "names_begin");
DwarfAccelNamespaceSection = Ctx->getCOFFSection( DwarfAccelNamespaceSection = Ctx->getCOFFSection(
".apple_namespaces", ".apple_namespaces",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "namespac_begin");
DwarfAccelTypesSection = Ctx->getCOFFSection( DwarfAccelTypesSection = Ctx->getCOFFSection(
".apple_types", ".apple_types",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "types_begin");
DwarfAccelObjCSection = Ctx->getCOFFSection( DwarfAccelObjCSection = Ctx->getCOFFSection(
".apple_objc", ".apple_objc",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ, COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata()); SectionKind::getMetadata(), "objc_begin");
DrectveSection = Ctx->getCOFFSection( DrectveSection = Ctx->getCOFFSection(
".drectve", COFF::IMAGE_SCN_LNK_INFO | COFF::IMAGE_SCN_LNK_REMOVE, ".drectve", COFF::IMAGE_SCN_LNK_INFO | COFF::IMAGE_SCN_LNK_REMOVE,

View File

@ -70,8 +70,10 @@ ENTRY(nullptr /*FIXME*/, S_ATTR_LOC_RELOC)
}; };
MCSectionMachO::MCSectionMachO(StringRef Segment, StringRef Section, MCSectionMachO::MCSectionMachO(StringRef Segment, StringRef Section,
unsigned TAA, unsigned reserved2, SectionKind K) unsigned TAA, unsigned reserved2, SectionKind K,
: MCSection(SV_MachO, K), TypeAndAttributes(TAA), Reserved2(reserved2) { MCSymbol *Begin)
: MCSection(SV_MachO, K, Begin), TypeAndAttributes(TAA),
Reserved2(reserved2) {
assert(Segment.size() <= 16 && Section.size() <= 16 && assert(Segment.size() <= 16 && Section.size() <= 16 &&
"Segment or section string too long"); "Segment or section string too long");
for (unsigned i = 0; i != 16; ++i) { for (unsigned i = 0; i != 16; ++i) {

View File

@ -26,7 +26,7 @@ namespace llvm {
class NVPTXSection : public MCSection { class NVPTXSection : public MCSection {
virtual void anchor(); virtual void anchor();
public: public:
NVPTXSection(SectionVariant V, SectionKind K) : MCSection(V, K) {} NVPTXSection(SectionVariant V, SectionKind K) : MCSection(V, K, nullptr) {}
virtual ~NVPTXSection() {} virtual ~NVPTXSection() {}
/// Override this as NVPTX has its own way of printing switching /// Override this as NVPTX has its own way of printing switching