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 | df0b6503d601c2150e3242b66f02fe906f838979 (patch) | |
tree | ac9bf5bbae2540b4a948d326eea13a3629ce6d6a /lib/CodeGen/ELFWriter.cpp | |
parent | 3b07b5214ccf545ff6638d1327946c3300f1ee5f (diff) |
add module identifier to the elf object file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77238 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ELFWriter.cpp')
-rw-r--r-- | lib/CodeGen/ELFWriter.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index f2a9bf34e5..2679d983f4 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/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; |