Handle null and file symbol on doInitialization

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77354 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Bruno Cardoso Lopes 2009-07-28 19:25:33 +00:00
parent b180d992d8
commit 50bc204291
2 changed files with 8 additions and 9 deletions

View File

@ -143,6 +143,11 @@ bool ELFWriter::doInitialization(Module &M) {
// Add the null section, which is required to be first in the file.
getNullSection();
// The first entry in the symtab is the null symbol and the second
// is a local symbol containing the module/file name
SymbolList.push_back(new ELFSym());
SymbolList.push_back(ELFSym::getFileSym());
return false;
}
@ -320,7 +325,7 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) {
const TargetLoweringObjectFile &TLOF =
TM.getTargetLowering()->getObjFileLowering();
// Get ELF section from TAI
// Get the ELF section where this global belongs from TLOF
const Section *S = TLOF.SectionForGlobal(GV, TM);
unsigned SectionFlags = getElfSectionFlags(S->getKind());
@ -522,9 +527,6 @@ bool ELFWriter::doFinalization(Module &M) {
if (TAI->getNonexecutableStackDirective())
getNonExecStackSection();
// Emit module name
SymbolList.push_back(ELFSym::getFileSym());
// Emit a symbol for each section created until now, skip null section
for (unsigned i = 1, e = SectionList.size(); i < e; ++i) {
ELFSection &ES = *SectionList[i];
@ -798,9 +800,6 @@ void ELFWriter::EmitSymbolTable() {
// Size of each symtab entry.
SymTab.EntSize = TEW->getSymTabEntrySize();
// The first entry in the symtab is the null symbol
SymbolList.insert(SymbolList.begin(), new ELFSym());
// Reorder the symbol table with local symbols first!
unsigned FirstNonLocalSymbol = SortSymbols();