Skip to content

Commit 2ca0371

Browse files
George Rimarcompnerd
authored andcommitted
[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 (cherry picked from commit 8d9b9f6) (cherry picked from commit 966b3d34e8f8242f34457682dc723a039a74dfe1)
1 parent 83ba3ea commit 2ca0371

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lld/ELF/InputFiles.cpp

Lines changed: 6 additions & 4 deletions
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)