[llvm-commits] [llvm] r117099 - in /llvm/trunk: include/llvm/MC/ELFObjectWriter.h lib/MC/ELFObjectWriter.cpp lib/Target/ARM/ARMAsmBackend.cpp lib/Target/MBlaze/MBlazeAsmBackend.cpp lib/Target/X86/X86AsmBackend.cpp

Wesley Peck peckw at wesleypeck.com
Fri Oct 22 08:52:49 PDT 2010


Author: peckw
Date: Fri Oct 22 10:52:49 2010
New Revision: 117099

URL: http://llvm.org/viewvc/llvm-project?rev=117099&view=rev
Log:
Making the e_machine configurable by the target backend in ELFObjectWriter.

Modified:
    llvm/trunk/include/llvm/MC/ELFObjectWriter.h
    llvm/trunk/lib/MC/ELFObjectWriter.cpp
    llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp
    llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp
    llvm/trunk/lib/Target/X86/X86AsmBackend.cpp

Modified: llvm/trunk/include/llvm/MC/ELFObjectWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/ELFObjectWriter.h?rev=117099&r1=117098&r2=117099&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/ELFObjectWriter.h (original)
+++ llvm/trunk/include/llvm/MC/ELFObjectWriter.h Fri Oct 22 10:52:49 2010
@@ -27,7 +27,8 @@
 
 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();
 

Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=117099&r1=117098&r2=117099&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri Oct 22 10:52:49 2010
@@ -164,6 +164,8 @@
 
     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 @@
 
   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 @@
 
   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 @@
 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() {

Modified: llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp?rev=117099&r1=117098&r2=117099&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMAsmBackend.cpp Fri Oct 22 10:52:49 2010
@@ -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 @@
 
   MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
     return new ELFObjectWriter(OS, /*Is64Bit=*/false,
-                               OSType,
+                               OSType, ELF::EM_ARM,
                                /*IsLittleEndian=*/true,
                                /*HasRelocationAddend=*/false);
   }

Modified: llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp?rev=117099&r1=117098&r2=117099&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/MBlaze/MBlazeAsmBackend.cpp Fri Oct 22 10:52:49 2010
@@ -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 @@
 
   MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
     return new ELFObjectWriter(OS, /*Is64Bit=*/false,
-                               OSType,
+                               OSType, ELF::EM_MBLAZE,
                                /*IsLittleEndian=*/false,
                                /*HasRelocationAddend=*/true);
   }

Modified: llvm/trunk/lib/Target/X86/X86AsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86AsmBackend.cpp?rev=117099&r1=117098&r2=117099&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86AsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86AsmBackend.cpp Fri Oct 22 10:52:49 2010
@@ -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 @@
 
   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 @@
 
   MCObjectWriter *createObjectWriter(raw_ostream &OS) const {
     return new ELFObjectWriter(OS, /*Is64Bit=*/true,
-                               OSType,
+                               OSType, ELF::EM_X86_64,
                                /*IsLittleEndian=*/true,
                                /*HasRelocationAddend=*/true);
   }





More information about the llvm-commits mailing list