Add more methods to gather target specific elf stuff
[oota-llvm.git] / lib / CodeGen / ELFCodeEmitter.cpp
index ca683969e411b7e66bda017812e444231712913d..8cb7c94c5d0f1a34cbd36475b779e362dfaff9d2 100644 (file)
@@ -71,39 +71,38 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &MF) {
   // Update Section Size
   ES->Size = CurBufferPtr - BufferBegin;
 
+  // Set the symbol type as a function
+  FnSym.setType(ELFSym::STT_FUNC);
+  FnSym.SectionIdx = ES->SectionIdx;
+  FnSym.Size = CurBufferPtr-FnStartPtr;
+
+  // Offset from start of Section
+  FnSym.Value = FnStartPtr-BufferBegin;
+
   // Figure out the binding (linkage) of the symbol.
   switch (MF.getFunction()->getLinkage()) {
   default:
     // appending linkage is illegal for functions.
     assert(0 && "Unknown linkage type!");
   case GlobalValue::ExternalLinkage:
-    FnSym.SetBind(ELFSym::STB_GLOBAL);
+    FnSym.setBind(ELFSym::STB_GLOBAL);
+    EW.SymbolList.push_back(FnSym);
     break;
   case GlobalValue::LinkOnceAnyLinkage:
   case GlobalValue::LinkOnceODRLinkage:
   case GlobalValue::WeakAnyLinkage:
   case GlobalValue::WeakODRLinkage:
-    FnSym.SetBind(ELFSym::STB_WEAK);
+    FnSym.setBind(ELFSym::STB_WEAK);
+    EW.SymbolList.push_back(FnSym);
     break;
   case GlobalValue::PrivateLinkage:
     assert (0 && "PrivateLinkage should not be in the symbol table.");
   case GlobalValue::InternalLinkage:
-    FnSym.SetBind(ELFSym::STB_LOCAL);
+    FnSym.setBind(ELFSym::STB_LOCAL);
+    EW.SymbolList.push_front(FnSym);
     break;
   }
 
-  // Set the symbol type as a function
-  FnSym.SetType(ELFSym::STT_FUNC);
-
-  FnSym.SectionIdx = ES->SectionIdx;
-  FnSym.Size = CurBufferPtr-FnStartPtr;
-
-  // Offset from start of Section
-  FnSym.Value = FnStartPtr-BufferBegin;
-
-  // Finally, add it to the symtab.
-  EW.SymbolList.push_back(FnSym);
-
   // Relocations
   // -----------
   // If we have emitted any relocations to function-specific objects such as 
@@ -113,7 +112,6 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &MF) {
   for (unsigned i = 0, e = Relocations.size(); i != e; ++i) {
     MachineRelocation &MR = Relocations[i];
     intptr_t Addr;
-
     if (MR.isBasicBlock()) {
       Addr = getMachineBasicBlockAddress(MR.getBasicBlock());
       MR.setConstantVal(ES->SectionIdx);