Remove trailing whitespace to reduce later commit patch noise.
[oota-llvm.git] / lib / CodeGen / ELFWriter.cpp
index 6f29112caf45d63280736e42bb1fc7c0054219e5..b698178d780db6007b36cf325c3548f65d46ca05 100644 (file)
@@ -34,6 +34,7 @@
 #include "ELFWriter.h"
 #include "llvm/Module.h"
 #include "llvm/PassManager.h"
+#include "llvm/DerivedTypes.h"
 #include "llvm/CodeGen/FileWriters.h"
 #include "llvm/CodeGen/MachineCodeEmitter.h"
 #include "llvm/CodeGen/MachineConstantPool.h"
@@ -85,21 +86,21 @@ namespace llvm {
     virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) {
     }
 
-    virtual intptr_t getConstantPoolEntryAddress(unsigned Index) const {
+    virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const {
       assert(0 && "CP not implementated yet!");
       return 0;
     }
-    virtual intptr_t getJumpTableEntryAddress(unsigned Index) const {
+    virtual uintptr_t getJumpTableEntryAddress(unsigned Index) const {
       assert(0 && "JT not implementated yet!");
       return 0;
     }
 
-    virtual intptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const {
+    virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) const {
       assert(0 && "JT not implementated yet!");
       return 0;
     }
 
-    virtual intptr_t getLabelAddress(uint64_t Label) const {
+    virtual uintptr_t getLabelAddress(uint64_t Label) const {
       assert(0 && "Label address not implementated yet!");
       abort();
       return 0;
@@ -115,12 +116,12 @@ namespace llvm {
 
 
     /// JIT SPECIFIC FUNCTIONS - DO NOT IMPLEMENT THESE HERE!
-    void startFunctionStub(const GlobalValue* F, unsigned StubSize,
-                           unsigned Alignment = 1) {
+    void startGVStub(const GlobalValue* F, unsigned StubSize,
+                     unsigned Alignment = 1) {
       assert(0 && "JIT specific function called!");
       abort();
     }
-    void *finishFunctionStub(const GlobalValue *F) {
+    void *finishGVStub(const GlobalValue *F) {
       assert(0 && "JIT specific function called!");
       abort();
       return 0;
@@ -173,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;
@@ -195,7 +198,7 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &F) {
 //===----------------------------------------------------------------------===//
 
 ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm) 
-  : MachineFunctionPass((intptr_t)&ID), O(o), TM(tm) {
+  : MachineFunctionPass(&ID), O(o), TM(tm) {
   e_flags = 0;    // e_flags defaults to 0, no flags.
 
   is64Bit = TM.getTargetData()->getPointerSizeInBits() == 64;
@@ -273,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.
@@ -328,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;