-//===-- MObjectFileInfo.cpp - Object File Information ---------------------===//
+//===-- MCObjectFileInfo.cpp - Object File Information --------------------===//
//
// The LLVM Compiler Infrastructure
//
MachO::S_ATTR_PURE_INSTRUCTIONS,
SectionKind::getText());
DataSection // .data
- = Ctx->getMachOSection("__DATA", "__data", 0,
- SectionKind::getDataRel());
+ = Ctx->getMachOSection("__DATA", "__data", 0, SectionKind::getData());
// BSSSection might not be expected initialized on msvc.
BSSSection = nullptr;
TLSDataSection // .tdata
- = Ctx->getMachOSection("__DATA", "__thread_data",
- MachO::S_THREAD_LOCAL_REGULAR,
- SectionKind::getDataRel());
+ = Ctx->getMachOSection("__DATA", "__thread_data",
+ MachO::S_THREAD_LOCAL_REGULAR,
+ SectionKind::getData());
TLSBSSSection // .tbss
= Ctx->getMachOSection("__DATA", "__thread_bss",
MachO::S_THREAD_LOCAL_ZEROFILL,
// TODO: Verify datarel below.
TLSTLVSection // .tlv
- = Ctx->getMachOSection("__DATA", "__thread_vars",
- MachO::S_THREAD_LOCAL_VARIABLES,
- SectionKind::getDataRel());
+ = Ctx->getMachOSection("__DATA", "__thread_vars",
+ MachO::S_THREAD_LOCAL_VARIABLES,
+ SectionKind::getData());
- TLSThreadInitSection
- = Ctx->getMachOSection("__DATA", "__thread_init",
- MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
- SectionKind::getDataRel());
+ TLSThreadInitSection = Ctx->getMachOSection(
+ "__DATA", "__thread_init", MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS,
+ SectionKind::getData());
CStringSection // .cstring
= Ctx->getMachOSection("__TEXT", "__cstring",
= Ctx->getMachOSection("__TEXT", "__const_coal",
MachO::S_COALESCED,
SectionKind::getReadOnly());
- DataCoalSection
- = Ctx->getMachOSection("__DATA","__datacoal_nt",
- MachO::S_COALESCED,
- SectionKind::getDataRel());
+ DataCoalSection = Ctx->getMachOSection(
+ "__DATA", "__datacoal_nt", MachO::S_COALESCED, SectionKind::getData());
} else {
TextCoalSection = TextSection;
ConstTextCoalSection = ReadOnlySection;
SectionKind::getMetadata());
if (RelocM == Reloc::Static) {
- StaticCtorSection
- = Ctx->getMachOSection("__TEXT", "__constructor", 0,
- SectionKind::getDataRel());
- StaticDtorSection
- = Ctx->getMachOSection("__TEXT", "__destructor", 0,
- SectionKind::getDataRel());
+ StaticCtorSection = Ctx->getMachOSection("__TEXT", "__constructor", 0,
+ SectionKind::getData());
+ StaticDtorSection = Ctx->getMachOSection("__TEXT", "__destructor", 0,
+ SectionKind::getData());
} else {
- StaticCtorSection
- = Ctx->getMachOSection("__DATA", "__mod_init_func",
- MachO::S_MOD_INIT_FUNC_POINTERS,
- SectionKind::getDataRel());
- StaticDtorSection
- = Ctx->getMachOSection("__DATA", "__mod_term_func",
- MachO::S_MOD_TERM_FUNC_POINTERS,
- SectionKind::getDataRel());
+ StaticCtorSection = Ctx->getMachOSection("__DATA", "__mod_init_func",
+ MachO::S_MOD_INIT_FUNC_POINTERS,
+ SectionKind::getData());
+ StaticDtorSection = Ctx->getMachOSection("__DATA", "__mod_term_func",
+ MachO::S_MOD_TERM_FUNC_POINTERS,
+ SectionKind::getData());
}
// Exception Handling.
DwarfRangesSection =
Ctx->getMachOSection("__DWARF", "__debug_ranges", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata(), "debug_range");
+ DwarfMacinfoSection =
+ Ctx->getMachOSection("__DWARF", "__debug_macinfo", MachO::S_ATTR_DEBUG,
+ SectionKind::getMetadata());
DwarfDebugInlineSection =
Ctx->getMachOSection("__DWARF", "__debug_inlined", MachO::S_ATTR_DEBUG,
SectionKind::getMetadata());
+ DwarfCUIndexSection =
+ Ctx->getMachOSection("__DWARF", "__debug_cu_index", MachO::S_ATTR_DEBUG,
+ SectionKind::getMetadata());
+ DwarfTUIndexSection =
+ Ctx->getMachOSection("__DWARF", "__debug_tu_index", MachO::S_ATTR_DEBUG,
+ SectionKind::getMetadata());
StackMapSection = Ctx->getMachOSection("__LLVM_STACKMAPS", "__llvm_stackmaps",
0, SectionKind::getMetadata());
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);
-
- 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);
- 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, 4, "");
Ctx->getELFSection(".debug_aranges", ELF::SHT_PROGBITS, 0);
DwarfRangesSection =
Ctx->getELFSection(".debug_ranges", ELF::SHT_PROGBITS, 0, "debug_range");
+ DwarfMacinfoSection =
+ Ctx->getELFSection(".debug_macinfo", ELF::SHT_PROGBITS, 0);
// DWARF5 Experimental Debug Info
DwarfAddrSection =
Ctx->getELFSection(".debug_addr", ELF::SHT_PROGBITS, 0, "addr_sec");
+ // DWP Sections
+ DwarfCUIndexSection =
+ Ctx->getELFSection(".debug_cu_index", ELF::SHT_PROGBITS, 0);
+ DwarfTUIndexSection =
+ Ctx->getELFSection(".debug_tu_index", ELF::SHT_PROGBITS, 0);
+
StackMapSection =
Ctx->getELFSection(".llvm_stackmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
EHFrameSection = Ctx->getCOFFSection(
".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
- SectionKind::getDataRel());
+ SectionKind::getData());
bool IsWoA = T.getArch() == Triple::arm || T.getArch() == Triple::thumb;
DataSection = Ctx->getCOFFSection(
".data", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE,
- SectionKind::getDataRel());
+ SectionKind::getData());
ReadOnlySection = Ctx->getCOFFSection(
".rdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
SectionKind::getReadOnly());
StaticCtorSection = Ctx->getCOFFSection(
".ctors", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
- SectionKind::getDataRel());
+ SectionKind::getData());
StaticDtorSection = Ctx->getCOFFSection(
".dtors", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
- SectionKind::getDataRel());
+ SectionKind::getData());
}
// FIXME: We're emitting LSDA info into a readonly section on COFF, even
// though 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.
- assert(T.isOSWindows() && "Windows is the only supported COFF target");
if (T.getArch() == Triple::x86_64) {
// On Windows 64 with SEH, the LSDA is emitted into the .xdata section
LSDASection = nullptr;
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ,
SectionKind::getMetadata(), "debug_range");
+ DwarfMacinfoSection = Ctx->getCOFFSection(
+ ".debug_macinfo",
+ COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_READ,
+ SectionKind::getMetadata());
DwarfInfoDWOSection = Ctx->getCOFFSection(
".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,
SectionKind::getMetadata(), "addr_sec");
+ DwarfCUIndexSection = Ctx->getCOFFSection(
+ ".debug_cu_index",
+ COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_READ,
+ SectionKind::getMetadata());
+ DwarfTUIndexSection = Ctx->getCOFFSection(
+ ".debug_tu_index",
+ COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_READ,
+ SectionKind::getMetadata());
DwarfAccelNamesSection = Ctx->getCOFFSection(
".apple_names",
COFF::IMAGE_SCN_MEM_DISCARDABLE | COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
PDataSection = Ctx->getCOFFSection(
".pdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
- SectionKind::getDataRel());
+ SectionKind::getData());
XDataSection = Ctx->getCOFFSection(
".xdata", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ,
- SectionKind::getDataRel());
+ SectionKind::getData());
SXDataSection = Ctx->getCOFFSection(".sxdata", COFF::IMAGE_SCN_LNK_INFO,
SectionKind::getMetadata());
TLSDataSection = Ctx->getCOFFSection(
".tls$", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE,
- SectionKind::getDataRel());
+ SectionKind::getData());
StackMapSection = Ctx->getCOFFSection(".llvm_stackmaps",
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
TT = TheTriple;
- Triple::ArchType Arch = TT.getArch();
- // FIXME: Checking for Arch here to filter out bogus triples such as
- // cellspu-apple-darwin. Perhaps we should fix in Triple?
- if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
- Arch == Triple::arm || Arch == Triple::thumb ||
- Arch == Triple::aarch64 ||
- Arch == Triple::ppc || Arch == Triple::ppc64 ||
- Arch == Triple::UnknownArch) &&
- TT.isOSBinFormatMachO()) {
+ switch (TT.getObjectFormat()) {
+ case Triple::MachO:
Env = IsMachO;
initMachOMCObjectFileInfo(TT);
- } else if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
- Arch == Triple::arm || Arch == Triple::thumb) &&
- (TT.isOSWindows() && TT.getObjectFormat() == Triple::COFF)) {
+ break;
+ case Triple::COFF:
+ if (!TT.isOSWindows())
+ report_fatal_error(
+ "Cannot initialize MC for non-Windows COFF object files.");
+
Env = IsCOFF;
initCOFFMCObjectFileInfo(TT);
- } else {
+ break;
+ case Triple::ELF:
Env = IsELF;
initELFMCObjectFileInfo(TT);
+ break;
+ case Triple::UnknownObjectFormat:
+ report_fatal_error("Cannot initialize MC for unknown object file format.");
+ break;
}
}