diff options
| author | Chris Lattner <sabre@nondot.org> | 2005-07-16 17:41:06 +0000 | 
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2005-07-16 17:41:06 +0000 | 
| commit | a5998ce94fa1856f0287d180693d0424d3abb046 (patch) | |
| tree | 3e56fcc6bafba97caacc7224b1713684cf7f5763 /llvm/lib/CodeGen | |
| parent | 2148cffae7d4f227a31c95236209f654390b9f93 (diff) | |
| download | bcm5719-llvm-a5998ce94fa1856f0287d180693d0424d3abb046.tar.gz bcm5719-llvm-a5998ce94fa1856f0287d180693d0424d3abb046.zip | |
Only get the .bss and .data sections when needed instead of unconditionally.
This allows is to not emit empty sections when .data or .bss is not used.
llvm-svn: 22457
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/ELFWriter.cpp | 14 | 
1 files changed, 3 insertions, 11 deletions
| diff --git a/llvm/lib/CodeGen/ELFWriter.cpp b/llvm/lib/CodeGen/ELFWriter.cpp index afd6c3b05ca..d53afde6a45 100644 --- a/llvm/lib/CodeGen/ELFWriter.cpp +++ b/llvm/lib/CodeGen/ELFWriter.cpp @@ -223,8 +223,7 @@ bool ELFWriter::doInitialization(Module &M) {    return false;  } -void ELFWriter::EmitGlobal(GlobalVariable *GV, ELFSection &DataSection, -                           ELFSection &BSSSection) { +void ELFWriter::EmitGlobal(GlobalVariable *GV) {    // If this is an external global, emit it now.  TODO: Note that it would be    // better to ignore the symbol here and only add it to the symbol table if    // referenced. @@ -264,6 +263,7 @@ void ELFWriter::EmitGlobal(GlobalVariable *GV, ELFSection &DataSection,      // Handle alignment.  Ensure section is aligned at least as much as required      // by this symbol. +    ELFSection &BSSSection = getBSSSection();      BSSSection.Align = std::max(BSSSection.Align, Align);      // Within the section, emit enough virtual padding to get us to an alignment @@ -315,17 +315,9 @@ bool ELFWriter::runOnMachineFunction(MachineFunction &MF) {  bool ELFWriter::doFinalization(Module &M) {    // Okay, the ELF header and .text sections have been completed, build the    // .data, .bss, and "common" sections next. -  ELFSection &DataSection = -    getSection(".data", ELFSection::SHT_PROGBITS, -               ELFSection::SHF_WRITE | ELFSection::SHF_ALLOC); - -  ELFSection &BSSSection = -    getSection(".bss", ELFSection::SHT_NOBITS, -               ELFSection::SHF_WRITE | ELFSection::SHF_ALLOC); -    for (Module::global_iterator I = M.global_begin(), E = M.global_end();         I != E; ++I) -    EmitGlobal(I, DataSection, BSSSection); +    EmitGlobal(I);    // Emit the symbol table now, if non-empty.    EmitSymbolTable(); | 

