From ac5f048e0906449cab9844736afc9cdf98811f57 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Tue, 8 Sep 2015 22:51:46 +0000 Subject: [PATCH] [lld][elf2] Address review comments. llvm-svn: 247096 --- lld/ELF/SymbolTable.cpp | 5 +---- lld/ELF/SymbolTable.h | 4 ++-- lld/ELF/Writer.cpp | 3 +-- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lld/ELF/SymbolTable.cpp b/lld/ELF/SymbolTable.cpp index e62297271ed6..6275b13764ee 100644 --- a/lld/ELF/SymbolTable.cpp +++ b/lld/ELF/SymbolTable.cpp @@ -17,8 +17,7 @@ using namespace llvm::object; using namespace lld; using namespace lld::elf2; -SymbolTable::SymbolTable() : EntrySym(nullptr) { -} +SymbolTable::SymbolTable() {} void SymbolTable::addFile(std::unique_ptr File) { File->parse(); @@ -33,8 +32,6 @@ void SymbolTable::addFile(std::unique_ptr File) { } template void SymbolTable::init() { - if (EntrySym) - return; EntrySym = new (Alloc) Undefined("_start", Undefined::Synthetic); resolve(EntrySym); } diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index 356c9e40ccae..42c49c6fbbce 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -55,7 +55,7 @@ public: } SymbolBody *getEntrySym() const { - return EntrySym; + return EntrySym->getReplacement(); } private: @@ -78,7 +78,7 @@ private: std::vector> SharedFiles; - SymbolBody *EntrySym; + SymbolBody *EntrySym = nullptr; }; } // namespace elf2 diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 10dd162463ca..779f832f5d23 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -577,8 +577,7 @@ template void Writer::writeHeader() { auto &FirstObj = cast>(*Symtab.getFirstELF()); EHdr->e_machine = FirstObj.getEMachine(); EHdr->e_version = EV_CURRENT; - EHdr->e_entry = getSymVA( - cast>(Symtab.getEntrySym()->getReplacement())); + EHdr->e_entry = getSymVA(cast>(Symtab.getEntrySym())); EHdr->e_phoff = sizeof(Elf_Ehdr); EHdr->e_shoff = SectionHeaderOff; EHdr->e_ehsize = sizeof(Elf_Ehdr);