diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-06-22 19:29:56 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-06-22 19:29:56 +0000 |
commit | bd9c94d7af46e9ad888a34c631b26ecc50bf64f1 (patch) | |
tree | 751d7c2c1f789b01ba153c98f08944f8ea4f7a69 /llvm/lib/CodeGen/ELFWriter.cpp | |
parent | a040566fec506b93d5dcff6eb720c3c7e8491858 (diff) | |
download | bcm5719-llvm-bd9c94d7af46e9ad888a34c631b26ecc50bf64f1.tar.gz bcm5719-llvm-bd9c94d7af46e9ad888a34c631b26ecc50bf64f1.zip |
Use different functions to emit the string and symbol tables.
llvm-svn: 73895
Diffstat (limited to 'llvm/lib/CodeGen/ELFWriter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ELFWriter.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/ELFWriter.cpp b/llvm/lib/CodeGen/ELFWriter.cpp index 281cf2fa11e..acdf3d5d56a 100644 --- a/llvm/lib/CodeGen/ELFWriter.cpp +++ b/llvm/lib/CodeGen/ELFWriter.cpp @@ -386,6 +386,9 @@ bool ELFWriter::doFinalization(Module &M) { if (TAI->getNonexecutableStackDirective()) getNonExecStackSection(); + // Emit string table + EmitStringTable(); + // Emit the symbol table now, if non-empty. EmitSymbolTable(); @@ -518,12 +521,10 @@ void ELFWriter::EmitSectionHeader(BinaryObject &SHdrTab, } } -/// EmitSymbolTable - If the current symbol table is non-empty, emit the string -/// table for it and then the symbol table itself. -void ELFWriter::EmitSymbolTable() { +/// EmitStringTable - If the current symbol table is non-empty, emit the string +/// table for it +void ELFWriter::EmitStringTable() { if (!SymbolList.size()) return; // Empty symbol table. - - unsigned FirstNonLocalSymbol = 1; ELFSection &StrTab = getStringTableSection(); // Set the zero'th symbol to a null byte, as required. @@ -550,12 +551,20 @@ void ELFWriter::EmitSymbolTable() { } assert(Index == StrTab.size()); StrTab.Size = Index; +} +/// EmitSymbolTable - Emit the symbol table itself. +void ELFWriter::EmitSymbolTable() { + if (!SymbolList.size()) return; // Empty symbol table. + + unsigned FirstNonLocalSymbol = 1; // Now that we have emitted the string table and know the offset into the // string table of each symbol, emit the symbol table itself. ELFSection &SymTab = getSymbolTableSection(); SymTab.Align = TEW->getPrefELFAlignment(); - SymTab.Link = StrTab.SectionIdx; // Section Index of .strtab. + + // Section Index of .strtab. + SymTab.Link = getStringTableSection().SectionIdx; // Size of each symtab entry. SymTab.EntSize = TEW->getSymTabEntrySize(); @@ -566,7 +575,7 @@ void ELFWriter::EmitSymbolTable() { // Emit all the symbols to the symbol table. Skip the null // symbol, cause it's emitted already - Index = 1; + unsigned Index = 1; for (std::list<ELFSym>::iterator I = SymbolList.begin(), E = SymbolList.end(); I != E; ++I, ++Index) { // Keep track of the first non-local symbol |