aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectFileInfo.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-08-14 15:48:41 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-08-14 15:48:41 +0000
commitdbaf0498a9009f38ce7d4ff66df50451b65e50aa (patch)
tree7237392ad2c82b0360236e79f1bbd68402961d19 /llvm/lib/MC/MCObjectFileInfo.cpp
parentbd481b8f899f9a5eba806ac7b3ca339ca1f94366 (diff)
downloadllvm-dbaf0498a9009f38ce7d4ff66df50451b65e50aa.zip
llvm-dbaf0498a9009f38ce7d4ff66df50451b65e50aa.tar.gz
llvm-dbaf0498a9009f38ce7d4ff66df50451b65e50aa.tar.bz2
Revert "Centralize the information about which object format we are using."
This reverts commit r245047. It was failing on the darwin bots. The problem was that when running ./bin/llc -march=msp430 llc gets to if (TheTriple.getTriple().empty()) TheTriple.setTriple(sys::getDefaultTargetTriple()); Which means that we go with an arch of msp430 but a triple of x86_64-apple-darwin14.4.0 which fails badly. That code has to be updated to select a triple based on the value of march, but that is not a trivial fix. llvm-svn: 245062
Diffstat (limited to 'llvm/lib/MC/MCObjectFileInfo.cpp')
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index ade4b49..576827a 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -767,19 +767,25 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple,
TT = TheTriple;
- Triple::ObjectFormatType Format = TT.getObjectFormat();
- switch (Format) {
- case Triple::MachO:
+ 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;
initMachOMCObjectFileInfo(TT);
- break;
- case Triple::COFF:
+ } else if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
+ Arch == Triple::arm || Arch == Triple::thumb) &&
+ (TT.isOSWindows() && TT.getObjectFormat() == Triple::COFF)) {
+ Env = IsCOFF;
initCOFFMCObjectFileInfo(TT);
- break;
- case Triple::ELF:
+ } else {
+ Env = IsELF;
initELFMCObjectFileInfo(TT);
- break;
- case Triple::UnknownObjectFormat:
- break;
}
}
@@ -795,9 +801,7 @@ MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
}
void MCObjectFileInfo::InitEHFrameSection() {
- Triple::ObjectFormatType Format = TT.getObjectFormat();
- switch (Format) {
- case Triple::MachO:
+ if (Env == IsMachO)
EHFrameSection =
Ctx->getMachOSection("__TEXT", "__eh_frame",
MachO::S_COALESCED |
@@ -805,20 +809,14 @@ void MCObjectFileInfo::InitEHFrameSection() {
MachO::S_ATTR_STRIP_STATIC_SYMS |
MachO::S_ATTR_LIVE_SUPPORT,
SectionKind::getReadOnly());
- break;
- case Triple::ELF:
+ else if (Env == IsELF)
EHFrameSection =
Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
- break;
- case Triple::COFF:
+ else
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;
- }
}