Support adding relocations for data sections, handling the cases where
[oota-llvm.git] / lib / CodeGen / ELFWriter.h
index ec2e44ac2caf17ca7cd880bd40175fad7cb06e25..6f083b925aec1b1bd57c60507df29db7f1d7ecad 100644 (file)
@@ -171,18 +171,6 @@ namespace llvm {
                         ELFSection::SHF_EXECINSTR | ELFSection::SHF_ALLOC);
     }
 
-    /// Return the relocation section of section 'S'. 'RelA' is true
-    /// if the relocation section contains entries with addends.
-    ELFSection &getRelocSection(std::string SName, bool RelA, unsigned Align) {
-      std::string RelSName(".rel");
-      unsigned SHdrTy = RelA ? ELFSection::SHT_RELA : ELFSection::SHT_REL;
-
-      if (RelA) RelSName.append("a");
-      RelSName.append(SName);
-
-      return getSection(RelSName, SHdrTy, 0, Align);
-    }
-
     ELFSection &getNonExecStackSection() {
       return getSection(".note.GNU-stack", ELFSection::SHT_PROGBITS, 0, 1);
     }
@@ -215,6 +203,7 @@ namespace llvm {
 
     ELFSection &getJumpTableSection();
     ELFSection &getConstantPoolSection(MachineConstantPoolEntry &CPE);
+    ELFSection &getRelocSection(ELFSection &S);
 
     // Helpers for obtaining ELF specific info.
     unsigned getGlobalELFBinding(const GlobalValue *GV);
@@ -222,6 +211,11 @@ namespace llvm {
     unsigned getGlobalELFVisibility(const GlobalValue *GV);
     unsigned getElfSectionFlags(unsigned Flags);
 
+    // setGlobalSymLookup - Set global value 'GV' with 'Index' in the lookup map
+    void setGlobalSymLookup(const GlobalValue *GV, unsigned Index) {
+      GblSymLookup[GV] = Index;
+    }
+
     // As we complete the ELF file, we need to update fields in the ELF header
     // (e.g. the location of the section table).  These members keep track of
     // the offset in ELFHeader of these various pieces to update and other
@@ -244,6 +238,8 @@ namespace llvm {
     void EmitSymbolTable();
     void EmitStringTable();
     void OutputSectionsAndSectionTable();
+    void RelocateField(BinaryObject &BO, uint32_t Offset, int64_t Value,
+                       unsigned Size);
     unsigned SortSymbols();
   };
 }