aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectFileInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/MCObjectFileInfo.cpp')
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 576827a..ade4b49 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -767,25 +767,19 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple,
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()) {
- Env = IsMachO;
+ Triple::ObjectFormatType Format = TT.getObjectFormat();
+ switch (Format) {
+ case Triple::MachO:
initMachOMCObjectFileInfo(TT);
- } else if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
- Arch == Triple::arm || Arch == Triple::thumb) &&
- (TT.isOSWindows() && TT.getObjectFormat() == Triple::COFF)) {
- Env = IsCOFF;
+ break;
+ case Triple::COFF:
initCOFFMCObjectFileInfo(TT);
- } else {
- Env = IsELF;
+ break;
+ case Triple::ELF:
initELFMCObjectFileInfo(TT);
+ break;
+ case Triple::UnknownObjectFormat:
+ break;
}
}
@@ -801,7 +795,9 @@ MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
}
void MCObjectFileInfo::InitEHFrameSection() {
- if (Env == IsMachO)
+ Triple::ObjectFormatType Format = TT.getObjectFormat();
+ switch (Format) {
+ case Triple::MachO:
EHFrameSection =
Ctx->getMachOSection("__TEXT", "__eh_frame",
MachO::S_COALESCED |
@@ -809,14 +805,20 @@ void MCObjectFileInfo::InitEHFrameSection() {
MachO::S_ATTR_STRIP_STATIC_SYMS |
MachO::S_ATTR_LIVE_SUPPORT,
SectionKind::getReadOnly());
- else if (Env == IsELF)
+ break;
+ case Triple::ELF:
EHFrameSection =
Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
- else
+ break;
+ case Triple::COFF:
EHFrameSection =
Ctx->getCOFFSection(".eh_frame",
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE,
SectionKind::getDataRel());
+ break;
+ case Triple::UnknownObjectFormat:
+ break;
+ }
}