Mark Target's creation routines as const.
[oota-llvm.git] / include / llvm / Target / TargetELFWriterInfo.h
index e266a71f8c85af53810cf1e180f1ab857097ad33..a5b30c4f6e3d6db8a7f0deed5f78dbeb9ac0a149 100644 (file)
 #define LLVM_TARGET_TARGETELFWRITERINFO_H
 
 namespace llvm {
+  class Function;
+  class TargetData;
+  class TargetMachine;
 
   //===--------------------------------------------------------------------===//
   //                          TargetELFWriterInfo
   //===--------------------------------------------------------------------===//
 
   class TargetELFWriterInfo {
+  protected:
     // EMachine - This field is the target specific value to emit as the
     // e_machine member of the ELF header.
     unsigned short EMachine;
+    TargetMachine &TM;
+    bool is64Bit, isLittleEndian;
   public:
 
     // Machine architectures
@@ -44,10 +50,56 @@ namespace llvm {
       EM_X86_64 = 62   // AMD64
     };
 
-    explicit TargetELFWriterInfo(MachineType machine) : EMachine(machine) {}
-    virtual ~TargetELFWriterInfo() {}
+    // ELF File classes
+    enum {
+      ELFCLASS32 = 1, // 32-bit object file
+      ELFCLASS64 = 2  // 64-bit object file
+    };
+
+    // ELF Endianess
+    enum {
+      ELFDATA2LSB = 1, // Little-endian object file
+      ELFDATA2MSB = 2  // Big-endian object file
+    };
+
+    explicit TargetELFWriterInfo(TargetMachine &tm);
+    virtual ~TargetELFWriterInfo();
 
     unsigned short getEMachine() const { return EMachine; }
+    unsigned getEFlags() const { return 0; }
+    unsigned getEIClass() const { return is64Bit ? ELFCLASS64 : ELFCLASS32; }
+    unsigned getEIData() const {
+      return isLittleEndian ? ELFDATA2LSB : ELFDATA2MSB;
+    }
+
+    /// ELF Header and ELF Section Header Info
+    unsigned getHdrSize() const { return is64Bit ? 64 : 52; }
+    unsigned getSHdrSize() const { return is64Bit ? 64 : 40; }
+
+    /// Symbol Table Info
+    unsigned getSymTabEntrySize() const { return is64Bit ? 24 : 16; }
+
+    /// getPrefELFAlignment - Returns the preferred alignment for ELF. This
+    /// is used to align some sections.
+    unsigned getPrefELFAlignment() const { return is64Bit ? 8 : 4; }
+
+    /// getRelocationEntrySize - Entry size used in the relocation section
+    unsigned getRelocationEntrySize() const {
+      return is64Bit ? (hasRelocationAddend() ? 24 : 16)
+                     : (hasRelocationAddend() ? 12 : 8);
+    }
+
+    /// getRelocationType - Returns the target specific ELF Relocation type.
+    /// 'MachineRelTy' contains the object code independent relocation type
+    virtual unsigned getRelocationType(unsigned MachineRelTy) const = 0;
+
+    /// hasRelocationAddend - True if the target uses an addend in the
+    /// ELF relocation entry.
+    virtual bool hasRelocationAddend() const = 0;
+
+    /// getAddendForRelTy - Gets the addend value for an ELF relocation entry
+    /// based on the target relocation type. If addend is not used returns 0.
+    virtual long int getAddendForRelTy(unsigned RelTy) const = 0;
   };
 
 } // end llvm namespace