[PATCH] [Commented On] D25016: [ELF] - Fixed assert fail when symbol table has invalid sh_info value.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 01:51:59 PDT 2016


grimar added inline comments.


> rafael wrote in InputFiles.cpp:84
> Do you need this check in here to avoid the crash? How was it crashing before getting to the other check you added in Writer?

So already answered in mails, repeat in short here for patch history:

Current invalid-symtab-sh_info3.elf demonstrates the issue.

That happens because of getLocalSymbols() implementation:
ArrayRef<SymbolBody *> elf::ObjectFile<ELFT>::getLocalSymbols() {
.....

  uint32_t FirstNonLocal = this->Symtab->sh_info;
  return makeArrayRef(this->SymbolBodies).slice(1, FirstNonLocal - 1);

}

When FirstNonLocal is 0, returned array has invalid 0xFFFFFFFF length and
accessing memory our of array bounds just may crash.

https://reviews.llvm.org/D25016





More information about the llvm-commits mailing list