Turns out AnalyzeBranch can modify the mbb being analyzed. This is a nasty
[oota-llvm.git] / lib / CodeGen / ELFWriter.cpp
index 683a21e5e493b1256150056911f8f1a4f99c01c2..b698178d780db6007b36cf325c3548f65d46ca05 100644 (file)
@@ -34,7 +34,7 @@
 #include "ELFWriter.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
-#include "llvm/Type.h"          // FIXME: For PATypeHolder::get().
+#include "llvm/DerivedTypes.h"
 #include "llvm/CodeGen/FileWriters.h"
 #include "llvm/CodeGen/MachineCodeEmitter.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
@@ -174,6 +174,8 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &F) {
   case GlobalValue::WeakLinkage:
     FnSym.SetBind(ELFWriter::ELFSym::STB_WEAK);
     break;
+  case GlobalValue::PrivateLinkage:
+    assert (0 && "PrivateLinkage should not be in the symbol table.");
   case GlobalValue::InternalLinkage:
     FnSym.SetBind(ELFWriter::ELFSym::STB_LOCAL);
     break;
@@ -274,9 +276,9 @@ void ELFWriter::EmitGlobal(GlobalVariable *GV) {
     return;
   }
 
-  const Type *GVType = (const Type*)GV->getType();
   unsigned Align = TM.getTargetData()->getPreferredAlignment(GV);
-  unsigned Size  = TM.getTargetData()->getABITypeSize(GVType);
+  unsigned Size  =
+    TM.getTargetData()->getTypePaddedSize(GV->getType()->getElementType());
 
   // If this global has a zero initializer, it is part of the .bss or common
   // section.
@@ -329,7 +331,8 @@ void ELFWriter::EmitGlobal(GlobalVariable *GV) {
 
     // Set the idx of the .bss section
     BSSSym.SectionIdx = BSSSection.SectionIdx;
-    SymbolTable.push_back(BSSSym);
+    if (!GV->hasPrivateLinkage())
+      SymbolTable.push_back(BSSSym);
 
     // Reserve space in the .bss section for this symbol.
     BSSSection.Size += Size;