Respect object format choice on Darwin
authorKeno Fischer <kfischer@college.harvard.edu>
Mon, 4 May 2015 20:03:01 +0000 (20:03 +0000)
committerKeno Fischer <kfischer@college.harvard.edu>
Mon, 4 May 2015 20:03:01 +0000 (20:03 +0000)
Summary:
The object format can be set to something other than MachO, e.g.
to use ELF-on-Darwin for MCJIT. This already works on Windows, so
there's no reason it shouldn't on Darwin.

Reviewers: lhames, grosbach

Subscribers: rafael, grosbach, t.p.northover, llvm-commits

Differential Revision: http://reviews.llvm.org/D6185

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236455 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCObjectFileInfo.cpp
test/MC/ELF/empty.s

index 02fc55e07494299865320de48f770b1faffe6057..29f5a1d3752cc418695c47fdccf13fa22d9b9d1f 100644 (file)
@@ -754,7 +754,7 @@ void MCObjectFileInfo::InitMCObjectFileInfo(StringRef T, Reloc::Model relocm,
        Arch == Triple::aarch64 ||
        Arch == Triple::ppc || Arch == Triple::ppc64 ||
        Arch == Triple::UnknownArch) &&
-      (TT.isOSDarwin() || TT.isOSBinFormatMachO())) {
+      TT.isOSBinFormatMachO()) {
     Env = IsMachO;
     InitMachOMCObjectFileInfo(TT);
   } else if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
index d6a852ce15ad179b15f5e05e8f73eb682218a1e8..a371af443daab37869808c78aa7f5102e99f5084 100644 (file)
@@ -1,4 +1,14 @@
 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -s | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple x86_64-apple-darwin14.0.0-elf %s -o - | llvm-readobj -s | FileCheck %s -check-prefix=DARWIN
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32-elf %s -o - | llvm-readobj -s | FileCheck %s -check-prefix=WINDOWS
+
+// Check that we can create ELF files for darwin/windows, even though
+// it is not the default file format.
+
+// DARWIN:       Format: ELF64-x86-64
+// WINDOWS:      Format: ELF64-x86-64
+// DARWIN-NEXT:  Arch: x86_64
+// WINDOWS-NEXT: Arch: x86_64
 
 // Test that like gnu as we create text, data and bss by default. Also test
 // that shstrtab, symtab and strtab are listed.