if (T.getArch() == Triple::aarch64)
return true;
+ // armv7k always has it.
+ if (T.isWatchOS())
+ return true;
+
// Use it on newer version of OS X.
if (T.isMacOSX() && !T.isMacOSXVersionLT(10, 6))
return true;
// MachO
SupportsWeakOmittedEHFrame = false;
+ EHFrameSection = Ctx->getMachOSection(
+ "__TEXT", "__eh_frame",
+ MachO::S_COALESCED | MachO::S_ATTR_NO_TOC |
+ MachO::S_ATTR_STRIP_STATIC_SYMS | MachO::S_ATTR_LIVE_SUPPORT,
+ SectionKind::getReadOnly());
+
if (T.isOSDarwin() && T.getArch() == Triple::aarch64)
SupportsCompactUnwindWithoutEHFrame = true;
+ if (T.isWatchOS())
+ OmitDwarfIfHaveCompactUnwind = true;
+
PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel
| dwarf::DW_EH_PE_sdata4;
LSDAEncoding = FDECFIEncoding = dwarf::DW_EH_PE_pcrel;
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", 0,
SectionKind::getReadOnly());
- TextCoalSection
- = Ctx->getMachOSection("__TEXT", "__textcoal_nt",
- MachO::S_COALESCED |
- MachO::S_ATTR_PURE_INSTRUCTIONS,
- SectionKind::getText());
- ConstTextCoalSection
- = Ctx->getMachOSection("__TEXT", "__const_coal",
- MachO::S_COALESCED,
- SectionKind::getReadOnly());
+ // If the target is not powerpc, map the coal sections to the non-coal
+ // sections.
+ //
+ // "__TEXT/__textcoal_nt" => section "__TEXT/__text"
+ // "__TEXT/__const_coal" => section "__TEXT/__const"
+ // "__DATA/__datacoal_nt" => section "__DATA/__data"
+ Triple::ArchType ArchTy = T.getArch();
+
+ if (ArchTy == Triple::ppc || ArchTy == Triple::ppc64) {
+ TextCoalSection
+ = Ctx->getMachOSection("__TEXT", "__textcoal_nt",
+ MachO::S_COALESCED |
+ MachO::S_ATTR_PURE_INSTRUCTIONS,
+ SectionKind::getText());
+ ConstTextCoalSection
+ = Ctx->getMachOSection("__TEXT", "__const_coal",
+ MachO::S_COALESCED,
+ SectionKind::getReadOnly());
+ DataCoalSection = Ctx->getMachOSection(
+ "__DATA", "__datacoal_nt", MachO::S_COALESCED, SectionKind::getData());
+ } else {
+ TextCoalSection = TextSection;
+ ConstTextCoalSection = ReadOnlySection;
+ DataCoalSection = DataSection;
+ }
+
ConstDataSection // .const_data
= Ctx->getMachOSection("__DATA", "__const", 0,
SectionKind::getReadOnlyWithRel());
- DataCoalSection
- = Ctx->getMachOSection("__DATA","__datacoal_nt",
- MachO::S_COALESCED,
- SectionKind::getDataRel());
DataCommonSection
= Ctx->getMachOSection("__DATA","__common",
MachO::S_ZEROFILL,
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.
SectionKind::getReadOnly());
if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)
- CompactUnwindDwarfEHFrameOnly = 0x04000000;
+ CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_X86_64_MODE_DWARF
else if (T.getArch() == Triple::aarch64)
- CompactUnwindDwarfEHFrameOnly = 0x03000000;
+ CompactUnwindDwarfEHFrameOnly = 0x03000000; // UNWIND_ARM64_MODE_DWARF
+ else if (T.getArch() == Triple::arm || T.getArch() == Triple::thumb)
+ CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_ARM_MODE_DWARF
}
// Debug Information.
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());
break;
}
+ unsigned EHSectionType = T.getArch() == Triple::x86_64
+ ? ELF::SHT_X86_64_UNWIND
+ : ELF::SHT_PROGBITS;
+
// Solaris requires different flags for .eh_frame to seemingly every other
// platform.
- EHSectionType = ELF::SHT_PROGBITS;
- EHSectionFlags = ELF::SHF_ALLOC;
- if (T.isOSSolaris()) {
- if (T.getArch() == Triple::x86_64)
- EHSectionType = ELF::SHT_X86_64_UNWIND;
- else
- EHSectionFlags |= ELF::SHF_WRITE;
- }
+ unsigned EHSectionFlags = ELF::SHF_ALLOC;
+ if (T.isOSSolaris() && T.getArch() != Triple::x86_64)
+ EHSectionFlags |= ELF::SHF_WRITE;
// ELF
BSSSection = Ctx->getELFSection(".bss", ELF::SHT_NOBITS,
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, "");
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);
FaultMapSection =
Ctx->getELFSection(".llvm_faultmaps", ELF::SHT_PROGBITS, ELF::SHF_ALLOC);
+
+ EHFrameSection =
+ Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
}
void MCObjectFileInfo::initCOFFMCObjectFileInfo(Triple T) {
+ EHFrameSection = Ctx->getCOFFSection(
+ ".eh_frame", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
+ COFF::IMAGE_SCN_MEM_READ | COFF::IMAGE_SCN_MEM_WRITE,
+ SectionKind::getData());
+
bool IsWoA = T.getArch() == Triple::arm || T.getArch() == Triple::thumb;
CommDirectiveSupportsAlignment = true;
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
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 |
CommDirectiveSupportsAlignment = true;
SupportsWeakOmittedEHFrame = true;
SupportsCompactUnwindWithoutEHFrame = false;
+ OmitDwarfIfHaveCompactUnwind = false;
PersonalityEncoding = LSDAEncoding = FDECFIEncoding = TTypeEncoding =
dwarf::DW_EH_PE_absptr;
return Ctx->getELFSection(".debug_types", ELF::SHT_PROGBITS, ELF::SHF_GROUP,
0, utostr(Hash));
}
-
-void MCObjectFileInfo::InitEHFrameSection() {
- if (Env == IsMachO)
- EHFrameSection =
- Ctx->getMachOSection("__TEXT", "__eh_frame",
- MachO::S_COALESCED |
- MachO::S_ATTR_NO_TOC |
- MachO::S_ATTR_STRIP_STATIC_SYMS |
- MachO::S_ATTR_LIVE_SUPPORT,
- SectionKind::getReadOnly());
- else if (Env == IsELF)
- EHFrameSection =
- Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
- else
- EHFrameSection =
- Ctx->getCOFFSection(".eh_frame",
- COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
- COFF::IMAGE_SCN_MEM_READ |
- COFF::IMAGE_SCN_MEM_WRITE,
- SectionKind::getDataRel());
-}