- Remove custom handling of jumptables by the elf writter (this was
a dirty hack and isn't need anymore since the last x86 code emitter patch)
- Add a target-dependent modifier to addend calculation
- Use R_X86_64_32S relocation for X86::reloc_absolute_word_sext
- Use getELFSectionFlags whenever possible
- fix getTextSection to use TLOF and emit the right text section 
- Handle global emission for static ctors, dtors and Type::PointerTyID
- Some minor fixes



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78176 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/ELFWriter.h b/lib/CodeGen/ELFWriter.h
index ebcfe35..fe72652 100644
--- a/lib/CodeGen/ELFWriter.h
+++ b/lib/CodeGen/ELFWriter.h
@@ -33,6 +33,7 @@
   class ObjectCodeEmitter;
   class TargetAsmInfo;
   class TargetELFWriterInfo;
+  class TargetLoweringObjectFile;
   class raw_ostream;
   class SectionKind;
   class MCContext;
@@ -66,6 +67,7 @@
     /// Target machine description.
     TargetMachine &TM;
 
+    /// Context object for machine code objects.
     MCContext &OutContext;
     
     /// Target Elf Writer description.
@@ -78,6 +80,10 @@
     /// code for functions to the .o file.
     ELFCodeEmitter *ElfCE;
 
+    /// TLOF - Target Lowering Object File, provide section names for globals 
+    /// and other object file specific stuff
+    const TargetLoweringObjectFile &TLOF;
+
     /// TAI - Target Asm Info, provide information about section names for
     /// globals and other target specific stuff.
     const TargetAsmInfo *TAI;
@@ -176,13 +182,6 @@
       return *SN;
     }
 
-    /// TODO: support mangled names here to emit the right .text section
-    /// for c++ object files.
-    ELFSection &getTextSection() {
-      return getSection(".text", ELFSection::SHT_PROGBITS,
-                        ELFSection::SHF_EXECINSTR | ELFSection::SHF_ALLOC);
-    }
-
     ELFSection &getNonExecStackSection() {
       return getSection(".note.GNU-stack", ELFSection::SHT_PROGBITS, 0, 1);
     }
@@ -213,21 +212,24 @@
       return getSection("", ELFSection::SHT_NULL, 0);
     }
 
+    ELFSection &getCtorSection();
+    ELFSection &getDtorSection();
     ELFSection &getJumpTableSection();
     ELFSection &getConstantPoolSection(MachineConstantPoolEntry &CPE);
+    ELFSection &getTextSection(Function *F);
     ELFSection &getRelocSection(ELFSection &S);
 
     // Helpers for obtaining ELF specific info.
     unsigned getGlobalELFBinding(const GlobalValue *GV);
     unsigned getGlobalELFType(const GlobalValue *GV);
     unsigned getGlobalELFVisibility(const GlobalValue *GV);
-    unsigned getElfSectionFlags(SectionKind Kind);
+    unsigned getElfSectionFlags(SectionKind Kind, bool IsAlloc = true);
 
-    // addGlobalSymbol - Add a global to be processed and to the
-    // global symbol lookup, use a zero index for non private symbols
-    // because the table index will be determined later.
-    void addGlobalSymbol(const GlobalValue *GV);
-
+    // addGlobalSymbol - Add a global to be processed and to 
+    // the global symbol lookup, use a zero index because the table 
+    // index will be determined later.
+    void addGlobalSymbol(const GlobalValue *GV, bool AddToLookup = false);
+    
     // addExternalSymbol - Add the external to be processed and to the
     // external symbol lookup, use a zero index because the symbol
     // table index will be determined later
@@ -246,7 +248,10 @@
     void EmitGlobalConstant(const Constant *C, ELFSection &GblS);
     void EmitGlobalConstantStruct(const ConstantStruct *CVS,
                                   ELFSection &GblS);
-    ELFSection &getGlobalSymELFSection(const GlobalVariable *GV, ELFSym &Sym);
+    void emitGlobalDataRelocation(const GlobalValue *GV, unsigned Size, 
+                                  ELFSection &GblS);
+    bool EmitSpecialLLVMGlobal(const GlobalVariable *GV);
+    void EmitXXStructorList(Constant *List, ELFSection &Xtor);
     void EmitRelocations();
     void EmitRelocation(BinaryObject &RelSec, ELFRelocation &Rel, bool HasRelA);
     void EmitSectionHeader(BinaryObject &SHdrTab, const ELFSection &SHdr);