diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-07-27 19:32:57 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-07-27 19:32:57 +0000 |
commit | 16c5b4fca826c0fd4565e2c6a87e38bc95e2f330 (patch) | |
tree | 9532af8ba2b17ed9392053b547d79cb9263a2905 /llvm/lib/CodeGen/ELFWriter.cpp | |
parent | ca6c875e47b22edb5fdaa71ddb1b44cd540701d2 (diff) | |
download | bcm5719-llvm-16c5b4fca826c0fd4565e2c6a87e38bc95e2f330.tar.gz bcm5719-llvm-16c5b4fca826c0fd4565e2c6a87e38bc95e2f330.zip |
add module identifier to the elf object file
llvm-svn: 77238
Diffstat (limited to 'llvm/lib/CodeGen/ELFWriter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ELFWriter.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/ELFWriter.cpp b/llvm/lib/CodeGen/ELFWriter.cpp index f2a9bf34e58..2679d983f44 100644 --- a/llvm/lib/CodeGen/ELFWriter.cpp +++ b/llvm/lib/CodeGen/ELFWriter.cpp @@ -514,6 +514,9 @@ 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]; @@ -524,7 +527,7 @@ bool ELFWriter::doFinalization(Module &M) { } // Emit string table - EmitStringTable(); + EmitStringTable(M.getModuleIdentifier()); // Emit the symbol table now, if non-empty. EmitSymbolTable(); @@ -709,7 +712,7 @@ void ELFWriter::EmitSectionHeader(BinaryObject &SHdrTab, /// EmitStringTable - If the current symbol table is non-empty, emit the string /// table for it -void ELFWriter::EmitStringTable() { +void ELFWriter::EmitStringTable(const std::string &ModuleName) { if (!SymbolList.size()) return; // Empty symbol table. ELFSection &StrTab = getStringTableSection(); @@ -721,12 +724,14 @@ void ELFWriter::EmitStringTable() { for (ELFSymIter I=SymbolList.begin(), E=SymbolList.end(); I != E; ++I) { ELFSym &Sym = *(*I); - // Use the name mangler to uniquify the LLVM symbol. std::string Name; if (Sym.isGlobalValue()) + // Use the name mangler to uniquify the LLVM symbol. Name.append(Mang->getMangledName(Sym.getGlobalValue())); else if (Sym.isExternalSym()) Name.append(Sym.getExternalSymbol()); + else if (Sym.isFileType()) + Name.append(ModuleName); if (Name.empty()) { Sym.NameIdx = 0; |