From df1e05a26c9fff96509458ad7bb9849b21dfa11a Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 6 Aug 2015 15:33:21 +0000 Subject: [PATCH] Delete broken code. This was using a hard coded string table and getting it for every symbol. The symbol name was already available. llvm-svn: 244220 --- lld/ELF/InputFiles.cpp | 2 +- lld/ELF/Symbols.cpp | 18 ++---------------- lld/ELF/Symbols.h | 5 +---- 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index aaddc7d992d0..8e7e29634357 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -71,7 +71,7 @@ SymbolBody *elf2::ObjectFile::createSymbolBody(StringRef StringTable, StringRef Name = *NameOrErr; if (Sym->isUndefined()) return new (Alloc) Undefined(Name); - return new (Alloc) DefinedRegular(this, Sym); + return new (Alloc) DefinedRegular(Name); } namespace lld { diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 3e8cb7072cb5..194d379e04da 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -18,22 +18,8 @@ using namespace lld; using namespace lld::elf2; template -static StringRef -getSymbolName(const llvm::object::ELFFile *F, - const typename llvm::object::ELFFile::Elf_Sym *S) { - ErrorOr StrTabOrErr = - F->getStringTableForSymtab(*F->getDotSymtabSec()); - error(StrTabOrErr, "Invalid string table."); - StringRef StrTab = *StrTabOrErr; - if (S->st_name >= StrTab.size()) - error("Invalid string table offset"); - return StrTab.data() + S->st_name; -} - -template -DefinedRegular::DefinedRegular(ObjectFile *F, const Elf_Sym *S) - : Defined(DefinedRegularKind, getSymbolName(F->getObj(), S)), - File(F) {} +DefinedRegular::DefinedRegular(StringRef Name) + : Defined(DefinedRegularKind, Name) {} // Returns 1, 0 or -1 if this symbol should take precedence // over the Other, tie or lose, respectively. diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index a039d6a9eb88..1707047d5c10 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -87,14 +87,11 @@ template class DefinedRegular : public Defined { typedef typename llvm::object::ELFFile::Elf_Sym Elf_Sym; public: - DefinedRegular(ObjectFile *F, const Elf_Sym *S); + DefinedRegular(StringRef Name); static bool classof(const SymbolBody *S) { return S->kind() == DefinedRegularKind; } - -private: - ObjectFile *File; }; // Undefined symbols.