Add ELF ObjectWriter and Streamer support.
authorMatt Fleming <matt@console-pimps.org>
Mon, 16 Aug 2010 18:35:43 +0000 (18:35 +0000)
committerMatt Fleming <matt@console-pimps.org>
Mon, 16 Aug 2010 18:35:43 +0000 (18:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111172 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCSectionELF.h
include/llvm/MC/MCStreamer.h
include/llvm/Support/ELF.h
lib/MC/CMakeLists.txt
lib/MC/MCContext.cpp

index a90aa38156ab25d42a1e68402990646789d1c578..5de0bf58fe0c832ac2b04c0b6b91312cccf42b9c 100644 (file)
@@ -44,9 +44,9 @@ class MCSectionELF : public MCSection {
 private:
   friend class MCContext;
   MCSectionELF(StringRef Section, unsigned type, unsigned flags,
-               SectionKind K, bool isExplicit)
+               SectionKind K, bool isExplicit, unsigned entrySize)
     : MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags),
-      IsExplicit(isExplicit) {}
+      IsExplicit(isExplicit), EntrySize(entrySize) {}
   ~MCSectionELF();
 public:
 
@@ -174,6 +174,7 @@ public:
   StringRef getSectionName() const { return SectionName; }
   unsigned getType() const { return Type; }
   unsigned getFlags() const { return Flags; }
+  unsigned getEntrySize() const { return EntrySize; }
   
   void PrintSwitchToSection(const MCAsmInfo &MAI,
                             raw_ostream &OS) const;
index 5767a94a6bc3ce97d5bc063a2a00c4a0427956db..e152c39e19d5f5dc26a60929a1a29d721604dcf0 100644 (file)
@@ -359,6 +359,12 @@ namespace llvm {
                                     MCCodeEmitter &CE, raw_ostream &OS,
                                     bool RelaxAll = false);
 
+  /// createELFStreamer - Create a machine code streamer which will generate
+  /// ELF format object files.
+  MCStreamer *createELFStreamer(MCContext &Ctx, TargetAsmBackend &TAB,
+                               raw_ostream &OS, MCCodeEmitter *CE,
+                               bool RelaxAll = false);
+
   /// createLoggingStreamer - Create a machine code streamer which just logs the
   /// API calls and then dispatches to another streamer.
   ///
index a4223cf6ca397c3bf895f68d81d7e9a4085abf24..f33aeb4188ad0b6b3478dd8b300e791521cc0e3b 100644 (file)
@@ -330,6 +330,12 @@ struct Elf64_Sym {
   }
 };
 
+// The size (in bytes) of symbol table entries.
+enum {
+  SYMENTRY_SIZE32 = 16, // 32-bit symbol entry size
+  SYMENTRY_SIZE64 = 24  // 64-bit symbol entry size.
+};
+
 // Symbol bindings.
 enum {
   STB_LOCAL = 0,   // Local symbol, not visible outside obj file containing def
index 7b9b355339a10bb8b3ee4cee1b3434135b119bc7..60a3a3e3e312802b83fd316f2ad0cf19c30a5cd4 100644 (file)
@@ -1,4 +1,5 @@
 add_llvm_library(LLVMMC
+  ELFObjectWriter.cpp
   MCAsmInfo.cpp
   MCAsmInfoCOFF.cpp
   MCAsmInfoDarwin.cpp
@@ -7,6 +8,7 @@ add_llvm_library(LLVMMC
   MCCodeEmitter.cpp
   MCContext.cpp
   MCDisassembler.cpp
+  MCELFStreamer.cpp
   MCExpr.cpp
   MCInst.cpp
   MCInstPrinter.cpp
index 3996334d9bc239120dad94b1f4580df586b59b4f..adf476cf3f465416bb0244551696fd37bf349073 100644 (file)
@@ -148,7 +148,7 @@ getMachOSection(StringRef Segment, StringRef Section,
 
 const MCSection *MCContext::
 getELFSection(StringRef Section, unsigned Type, unsigned Flags,
-              SectionKind Kind, bool IsExplicit) {
+              SectionKind Kind, bool IsExplicit, unsigned EntrySize) {
   if (ELFUniquingMap == 0)
     ELFUniquingMap = new ELFUniqueMapTy();
   ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)ELFUniquingMap;
@@ -158,7 +158,7 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags,
   if (Entry.getValue()) return Entry.getValue();
   
   MCSectionELF *Result = new (*this) MCSectionELF(Entry.getKey(), Type, Flags,
-                                                  Kind, IsExplicit);
+                                                  Kind, IsExplicit, EntrySize);
   Entry.setValue(Result);
   return Result;
 }