Skip to content

Commit

Permalink
[LLD][ELF] - Minor simplification. NFC.
Browse files Browse the repository at this point in the history
This removes a call to `object::getSymbol<ELFT>`.
We used this function in a next way: it was given an
array of symbols and index and returned either a symbol
at the index given or a error.

This function was removed in D64631. 
(rL366052, but was reverted because of LLD compilation error
that I didn't know about).

It does not make much sense to keep this function on LLVM side
only for LLD, because having only a list of symbols and the index it
is not able to produce a valueable error message about context anyways.

llvm-svn: 366057
  • Loading branch information
George Rimar committed Jul 15, 2019
1 parent 6e89887 commit 8d9b9f6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lld/ELF/InputFiles.cpp
Expand Up @@ -466,9 +466,11 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
template <class ELFT>
StringRef ObjFile<ELFT>::getShtGroupSignature(ArrayRef<Elf_Shdr> sections,
const Elf_Shdr &sec) {
const Elf_Sym *sym =
CHECK(object::getSymbol<ELFT>(this->getELFSyms<ELFT>(), sec.sh_info), this);
StringRef signature = CHECK(sym->getName(this->stringTable), this);
typename ELFT::SymRange symbols = this->getELFSyms<ELFT>();
if (sec.sh_info >= symbols.size())
fatal(toString(this) + ": invalid symbol index");
const typename ELFT::Sym &sym = symbols[sec.sh_info];
StringRef signature = CHECK(sym.getName(this->stringTable), this);

// As a special case, if a symbol is a section symbol and has no name,
// we use a section name as a signature.
Expand All @@ -477,7 +479,7 @@ StringRef ObjFile<ELFT>::getShtGroupSignature(ArrayRef<Elf_Shdr> sections,
// standard, but GNU gold 1.14 (the newest version as of July 2017) or
// older produce such sections as outputs for the -r option, so we need
// a bug-compatibility.
if (signature.empty() && sym->getType() == STT_SECTION)
if (signature.empty() && sym.getType() == STT_SECTION)
return getSectionName(sec);
return signature;
}
Expand Down

0 comments on commit 8d9b9f6

Please sign in to comment.