llvm-svn: 244219
This commit is contained in:
Rafael Espindola 2015-08-06 15:33:19 +00:00
parent 08c1df6a45
commit 49a2ca6ddd
1 changed files with 9 additions and 5 deletions

View File

@ -9,6 +9,7 @@
#include "Symbols.h"
#include "Chunks.h"
#include "Error.h"
#include "InputFiles.h"
using namespace llvm::object;
@ -17,13 +18,16 @@ using namespace lld;
using namespace lld::elf2;
template <class ELFT>
StringRef
static StringRef
getSymbolName(const llvm::object::ELFFile<ELFT> *F,
const typename llvm::object::ELFFile<ELFT>::Elf_Sym *S) {
ErrorOr<StringRef> StrTab = F->getStringTableForSymtab(*F->getDotSymtabSec());
if (!StrTab || S->st_name >= StrTab->size())
llvm::report_fatal_error("Invalid string table.");
return StrTab->data() + S->st_name;
ErrorOr<StringRef> 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 <class ELFT>