summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCObjectFileInfo.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-12-22 01:39:04 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-12-22 01:39:04 +0000
commitff1d084aa2f07927f3c63c93f3286822abe9d1ac (patch)
tree5ff2fae7c2a9b59f37829e17a4eac861b1728856 /llvm/lib/MC/MCObjectFileInfo.cpp
parenta9f3bc6d86a7e067a4529895ae3e76f0c587c128 (diff)
downloadbcm5719-llvm-ff1d084aa2f07927f3c63c93f3286822abe9d1ac.tar.gz
bcm5719-llvm-ff1d084aa2f07927f3c63c93f3286822abe9d1ac.zip
[MC] Don't use the architecture to govern which object file format to use
InitMCObjectFileInfo was trying to override the triple in awkward ways. For example, a triple specifying COFF but not Windows was forced as ELF. This makes it easy for internal invariants to get violated, such as those which triggered PR25912. This fixes PR25912. llvm-svn: 256226
Diffstat (limited to 'llvm/lib/MC/MCObjectFileInfo.cpp')
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index dbedd73a432..028f2e955b2 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -606,7 +606,6 @@ void MCObjectFileInfo::initCOFFMCObjectFileInfo(Triple T) {
// 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;
@@ -810,25 +809,26 @@ 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()) {
+ 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;
}
}
OpenPOWER on IntegriCloud