Skip to content

Commit 8d9b9f6

Browse files
author
George Rimar
committed
[LLD][ELF] - Minor simplification. NFC.
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
1 parent 6e89887 commit 8d9b9f6

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lld/ELF/InputFiles.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -466,9 +466,11 @@ template <class ELFT> void ObjFile<ELFT>::parse(bool ignoreComdats) {
466466
template <class ELFT>
467467
StringRef ObjFile<ELFT>::getShtGroupSignature(ArrayRef<Elf_Shdr> sections,
468468
const Elf_Shdr &sec) {
469-
const Elf_Sym *sym =
470-
CHECK(object::getSymbol<ELFT>(this->getELFSyms<ELFT>(), sec.sh_info), this);
471-
StringRef signature = CHECK(sym->getName(this->stringTable), this);
469+
typename ELFT::SymRange symbols = this->getELFSyms<ELFT>();
470+
if (sec.sh_info >= symbols.size())
471+
fatal(toString(this) + ": invalid symbol index");
472+
const typename ELFT::Sym &sym = symbols[sec.sh_info];
473+
StringRef signature = CHECK(sym.getName(this->stringTable), this);
472474

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

0 commit comments

Comments
 (0)