[Object/ELF] - Check index argument in getSymbol().
authorGeorge Rimar <grimar@accesssoftek.com>
Thu, 20 Oct 2016 08:03:10 +0000 (08:03 +0000)
committerGeorge Rimar <grimar@accesssoftek.com>
Thu, 20 Oct 2016 08:03:10 +0000 (08:03 +0000)
commitde69e9f5db82d93b5ad901501c95227e77da024b
tree4417e6cec24c363593840ee9ef2e88f24034b460
parente38da03f589901b08c800633e3077af528a9d4d8
[Object/ELF] - Check index argument in getSymbol().

Without this check LLD crashes when SHT_GROUP section has invalid symbol index
because of next code:

template <class ELFT>
StringRef elf::ObjectFile<ELFT>::getShtGroupSignature(const Elf_Shdr &Sec) {
..
  const Elf_Sym *Sym = Obj.getSymbol(Symtab, Sec.sh_info);
..
}
If sh_info is too large, &Symbols[Index] just asserts.

No testcases provided because llvm-objdump/llvm-readelf does
not use getSymbol() function.

I`ll commit testcase for LLD separatelly.

Differential revision: https://reviews.llvm.org/D25516

llvm-svn: 284702
llvm/include/llvm/Object/ELF.h