diff options
-rw-r--r-- | include/llvm/MC/ELFObjectWriter.h | 3 | ||||
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 14 | ||||
-rw-r--r-- | lib/Target/ARM/ARMAsmBackend.cpp | 3 | ||||
-rw-r--r-- | lib/Target/MBlaze/MBlazeAsmBackend.cpp | 3 | ||||
-rw-r--r-- | lib/Target/X86/X86AsmBackend.cpp | 5 |
5 files changed, 18 insertions, 10 deletions
diff --git a/include/llvm/MC/ELFObjectWriter.h b/include/llvm/MC/ELFObjectWriter.h index aba8b49..ce52c50 100644 --- a/include/llvm/MC/ELFObjectWriter.h +++ b/include/llvm/MC/ELFObjectWriter.h @@ -27,7 +27,8 @@ class ELFObjectWriter : public MCObjectWriter { public: ELFObjectWriter(raw_ostream &OS, bool Is64Bit, Triple::OSType OSType, - bool IsLittleEndian = true, bool HasRelocationAddend = true); + uint16_t EMachine, bool IsLittleEndian = true, + bool HasRelocationAddend = true); virtual ~ELFObjectWriter(); diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index b6b71be..dad69eb 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -164,6 +164,8 @@ namespace { Triple::OSType OSType; + uint16_t EMachine; + // This holds the symbol table index of the last local symbol. unsigned LastLocalSymbolIndex; // This holds the .strtab section index. @@ -173,10 +175,11 @@ namespace { public: ELFObjectWriterImpl(ELFObjectWriter *_Writer, bool _Is64Bit, - bool _HasRelAddend, Triple::OSType _OSType) + uint16_t _EMachine, bool _HasRelAddend, + Triple::OSType _OSType) : NeedsGOT(false), Writer(_Writer), OS(Writer->getStream()), Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend), - OSType(_OSType) { + OSType(_OSType), EMachine(_EMachine) { } void Write8(uint8_t Value) { Writer->Write8(Value); } @@ -344,8 +347,7 @@ void ELFObjectWriterImpl::WriteHeader(uint64_t SectionDataSize, Write16(ELF::ET_REL); // e_type - // FIXME: Make this configurable - Write16(Is64Bit ? ELF::EM_X86_64 : ELF::EM_386); // e_machine = target + Write16(EMachine); // e_machine = target Write32(ELF::EV_CURRENT); // e_version WriteWord(0); // e_entry, no entry point in .o file @@ -1221,11 +1223,13 @@ void ELFObjectWriterImpl::WriteObject(MCAssembler &Asm, ELFObjectWriter::ELFObjectWriter(raw_ostream &OS, bool Is64Bit, Triple::OSType OSType, + uint16_t EMachine, bool IsLittleEndian, bool HasRelocationAddend) : MCObjectWriter(OS, IsLittleEndian) { - Impl = new ELFObjectWriterImpl(this, Is64Bit, HasRelocationAddend, OSType); + Impl = new ELFObjectWriterImpl(this, Is64Bit, EMachine, + HasRelocationAddend, OSType); } ELFObjectWriter::~ELFObjectWriter() { diff --git a/lib/Target/ARM/ARMAsmBackend.cpp b/lib/Target/ARM/ARMAsmBackend.cpp index d113cf5..72f6e2b 100644 --- a/lib/Target/ARM/ARMAsmBackend.cpp +++ b/lib/Target/ARM/ARMAsmBackend.cpp @@ -19,6 +19,7 @@ #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MachObjectWriter.h" +#include "llvm/Support/ELF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetRegistry.h" @@ -90,7 +91,7 @@ public: MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new ELFObjectWriter(OS, /*Is64Bit=*/false, - OSType, + OSType, ELF::EM_ARM, /*IsLittleEndian=*/true, /*HasRelocationAddend=*/false); } diff --git a/lib/Target/MBlaze/MBlazeAsmBackend.cpp b/lib/Target/MBlaze/MBlazeAsmBackend.cpp index 7e11f73..05d9c90 100644 --- a/lib/Target/MBlaze/MBlazeAsmBackend.cpp +++ b/lib/Target/MBlaze/MBlazeAsmBackend.cpp @@ -19,6 +19,7 @@ #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MachObjectWriter.h" +#include "llvm/Support/ELF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetRegistry.h" @@ -104,7 +105,7 @@ public: MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new ELFObjectWriter(OS, /*Is64Bit=*/false, - OSType, + OSType, ELF::EM_MBLAZE, /*IsLittleEndian=*/false, /*HasRelocationAddend=*/true); } diff --git a/lib/Target/X86/X86AsmBackend.cpp b/lib/Target/X86/X86AsmBackend.cpp index 83fca51..17db41a 100644 --- a/lib/Target/X86/X86AsmBackend.cpp +++ b/lib/Target/X86/X86AsmBackend.cpp @@ -20,6 +20,7 @@ #include "llvm/MC/MCSectionELF.h" #include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MachObjectWriter.h" +#include "llvm/Support/ELF.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetRegistry.h" @@ -228,7 +229,7 @@ public: MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new ELFObjectWriter(OS, /*Is64Bit=*/false, - OSType, + OSType, ELF::EM_386, /*IsLittleEndian=*/true, /*HasRelocationAddend=*/false); } @@ -245,7 +246,7 @@ public: MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new ELFObjectWriter(OS, /*Is64Bit=*/true, - OSType, + OSType, ELF::EM_X86_64, /*IsLittleEndian=*/true, /*HasRelocationAddend=*/true); } |