mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
Compute the ELF SectionKind from the flags.
Any code creating an MCSectionELF knows ELF and already provides the flags. SectionKind is an abstraction used by common code that uses a plain MCSection. Use the flags to compute the SectionKind. This removes a lot of guessing and boilerplate from the MCSectionELF construction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227476 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -416,83 +416,54 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
|
||||
|
||||
|
||||
// ELF
|
||||
BSSSection =
|
||||
Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
|
||||
ELF::SHF_WRITE | ELF::SHF_ALLOC,
|
||||
SectionKind::getBSS());
|
||||
BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
|
||||
ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
||||
|
||||
TextSection =
|
||||
Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_EXECINSTR |
|
||||
ELF::SHF_ALLOC,
|
||||
SectionKind::getText());
|
||||
TextSection = Ctx->getELFSection(".text", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_EXECINSTR | ELF::SHF_ALLOC);
|
||||
|
||||
DataSection =
|
||||
Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_WRITE |ELF::SHF_ALLOC,
|
||||
SectionKind::getDataRel());
|
||||
DataSection = Ctx->getELFSection(".data", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_WRITE | ELF::SHF_ALLOC);
|
||||
|
||||
ReadOnlySection =
|
||||
Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC,
|
||||
SectionKind::getReadOnly());
|
||||
Ctx->getELFSection(".rodata", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
|
||||
|
||||
TLSDataSection =
|
||||
Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_TLS |
|
||||
ELF::SHF_WRITE,
|
||||
SectionKind::getThreadData());
|
||||
Ctx->getELFSection(".tdata", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
|
||||
|
||||
TLSBSSSection =
|
||||
Ctx->getELFSection(".tbss", ELF::SHT_NOBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_TLS |
|
||||
ELF::SHF_WRITE,
|
||||
SectionKind::getThreadBSS());
|
||||
TLSBSSSection = Ctx->getELFSection(
|
||||
".tbss", ELF::SHT_NOBITS, ELF::SHF_ALLOC | ELF::SHF_TLS | ELF::SHF_WRITE);
|
||||
|
||||
DataRelSection =
|
||||
Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_WRITE,
|
||||
SectionKind::getDataRel());
|
||||
DataRelSection = Ctx->getELFSection(".data.rel", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_WRITE);
|
||||
|
||||
DataRelLocalSection =
|
||||
Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_WRITE,
|
||||
SectionKind::getDataRelLocal());
|
||||
DataRelLocalSection = Ctx->getELFSection(".data.rel.local", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_WRITE);
|
||||
|
||||
DataRelROSection =
|
||||
Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_WRITE,
|
||||
SectionKind::getReadOnlyWithRel());
|
||||
DataRelROSection = Ctx->getELFSection(".data.rel.ro", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_WRITE);
|
||||
|
||||
DataRelROLocalSection =
|
||||
Ctx->getELFSection(".data.rel.ro.local", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_WRITE,
|
||||
SectionKind::getReadOnlyWithRelLocal());
|
||||
DataRelROLocalSection = Ctx->getELFSection(
|
||||
".data.rel.ro.local", ELF::SHT_PROGBITS, ELF::SHF_ALLOC | ELF::SHF_WRITE);
|
||||
|
||||
MergeableConst4Section =
|
||||
Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_MERGE,
|
||||
SectionKind::getMergeableConst4());
|
||||
Ctx->getELFSection(".rodata.cst4", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_MERGE, 4, "");
|
||||
|
||||
MergeableConst8Section =
|
||||
Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_MERGE,
|
||||
SectionKind::getMergeableConst8());
|
||||
Ctx->getELFSection(".rodata.cst8", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_MERGE, 8, "");
|
||||
|
||||
MergeableConst16Section =
|
||||
Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_MERGE,
|
||||
SectionKind::getMergeableConst16());
|
||||
Ctx->getELFSection(".rodata.cst16", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_MERGE, 16, "");
|
||||
|
||||
StaticCtorSection =
|
||||
Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_WRITE,
|
||||
SectionKind::getDataRel());
|
||||
StaticCtorSection = Ctx->getELFSection(".ctors", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_WRITE);
|
||||
|
||||
StaticDtorSection =
|
||||
Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC |ELF::SHF_WRITE,
|
||||
SectionKind::getDataRel());
|
||||
StaticDtorSection = Ctx->getELFSection(".dtors", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC | ELF::SHF_WRITE);
|
||||
|
||||
// Exception Handling Sections.
|
||||
|
||||
@@ -500,103 +471,68 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
|
||||
// it contains relocatable pointers. In PIC mode, this is probably a big
|
||||
// runtime hit for C++ apps. Either the contents of the LSDA need to be
|
||||
// adjusted or this should be a data section.
|
||||
LSDASection =
|
||||
Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC,
|
||||
SectionKind::getReadOnly());
|
||||
LSDASection = Ctx->getELFSection(".gcc_except_table", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC);
|
||||
|
||||
COFFDebugSymbolsSection = nullptr;
|
||||
|
||||
// Debug Info Sections.
|
||||
DwarfAbbrevSection =
|
||||
Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
DwarfInfoSection =
|
||||
Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
DwarfLineSection =
|
||||
Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
DwarfFrameSection =
|
||||
Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_abbrev", ELF::SHT_PROGBITS, 0);
|
||||
DwarfInfoSection = Ctx->getELFSection(".debug_info", ELF::SHT_PROGBITS, 0);
|
||||
DwarfLineSection = Ctx->getELFSection(".debug_line", ELF::SHT_PROGBITS, 0);
|
||||
DwarfFrameSection = Ctx->getELFSection(".debug_frame", ELF::SHT_PROGBITS, 0);
|
||||
DwarfPubNamesSection =
|
||||
Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_pubnames", ELF::SHT_PROGBITS, 0);
|
||||
DwarfPubTypesSection =
|
||||
Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_pubtypes", ELF::SHT_PROGBITS, 0);
|
||||
DwarfGnuPubNamesSection =
|
||||
Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_gnu_pubnames", ELF::SHT_PROGBITS, 0);
|
||||
DwarfGnuPubTypesSection =
|
||||
Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_gnu_pubtypes", ELF::SHT_PROGBITS, 0);
|
||||
DwarfStrSection =
|
||||
Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_MERGE | ELF::SHF_STRINGS,
|
||||
SectionKind::getMergeable1ByteCString());
|
||||
DwarfLocSection =
|
||||
Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_str", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
|
||||
DwarfLocSection = Ctx->getELFSection(".debug_loc", ELF::SHT_PROGBITS, 0);
|
||||
DwarfARangesSection =
|
||||
Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0);
|
||||
DwarfRangesSection =
|
||||
Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0);
|
||||
DwarfMacroInfoSection =
|
||||
Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0);
|
||||
|
||||
// DWARF5 Experimental Debug Info
|
||||
|
||||
// Accelerator Tables
|
||||
DwarfAccelNamesSection =
|
||||
Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".apple_names", ELF::SHT_PROGBITS, 0);
|
||||
DwarfAccelObjCSection =
|
||||
Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".apple_objc", ELF::SHT_PROGBITS, 0);
|
||||
DwarfAccelNamespaceSection =
|
||||
Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".apple_namespaces", ELF::SHT_PROGBITS, 0);
|
||||
DwarfAccelTypesSection =
|
||||
Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".apple_types", ELF::SHT_PROGBITS, 0);
|
||||
|
||||
// Fission Sections
|
||||
DwarfInfoDWOSection =
|
||||
Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_info.dwo", ELF::SHT_PROGBITS, 0);
|
||||
DwarfTypesDWOSection =
|
||||
Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_types.dwo", ELF::SHT_PROGBITS, 0);
|
||||
DwarfAbbrevDWOSection =
|
||||
Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_abbrev.dwo", ELF::SHT_PROGBITS, 0);
|
||||
DwarfStrDWOSection =
|
||||
Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_MERGE | ELF::SHF_STRINGS,
|
||||
SectionKind::getMergeable1ByteCString());
|
||||
Ctx->getELFSection(".debug_str.dwo", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_MERGE | ELF::SHF_STRINGS, 1, "");
|
||||
DwarfLineDWOSection =
|
||||
Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_line.dwo", ELF::SHT_PROGBITS, 0);
|
||||
DwarfLocDWOSection =
|
||||
Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_loc.dwo", ELF::SHT_PROGBITS, 0);
|
||||
DwarfStrOffDWOSection =
|
||||
Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
DwarfAddrSection =
|
||||
Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0,
|
||||
SectionKind::getMetadata());
|
||||
Ctx->getELFSection(".debug_str_offsets.dwo", ELF::SHT_PROGBITS, 0);
|
||||
DwarfAddrSection = Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0);
|
||||
|
||||
StackMapSection =
|
||||
Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS,
|
||||
ELF::SHF_ALLOC,
|
||||
SectionKind::getMetadata());
|
||||
|
||||
Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
|
||||
}
|
||||
|
||||
|
||||
@@ -884,7 +820,7 @@ void MCObjectFileInfo::InitMCObjectFileInfo(StringRef T, Reloc::Model relocm,
|
||||
|
||||
const MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
|
||||
return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
|
||||
SectionKind::getMetadata(), 0, utostr(Hash));
|
||||
0, utostr(Hash));
|
||||
}
|
||||
|
||||
void MCObjectFileInfo::InitEHFrameSection() {
|
||||
@@ -898,9 +834,7 @@ void MCObjectFileInfo::InitEHFrameSection() {
|
||||
SectionKind::getReadOnly());
|
||||
else if (Env == IsELF)
|
||||
EHFrameSection =
|
||||
Ctx->getELFSection(".eh_frame", EHSectionType,
|
||||
EHSectionFlags,
|
||||
SectionKind::getDataRel());
|
||||
Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
|
||||
else
|
||||
EHFrameSection =
|
||||
Ctx->getCOFFSection(".eh_frame",
|
||||
|
Reference in New Issue
Block a user