[PATCH] D81937: [llvm-readobj] - Do not crash when GnuHashTable->symndx is greater than the dynamic symbols count.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 16 07:10:18 PDT 2020


grimar created this revision.
grimar added reviewers: jhenderson, MaskRay.
Herald added subscribers: rupprecht, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
grimar added a parent revision: D81928: [llvm-readobj] - Split the printGnuHashTable(). NFCI..

`Elf_GnuHash_Impl` has the following method:

  ArrayRef<Elf_Word> values(unsigned DynamicSymCount) const {
    return ArrayRef<Elf_Word>(buckets().end(), DynamicSymCount - symndx);
  }

When DynamicSymCount is less than symndx we return an array with the huge broken size.
This patch fixes the issue ans adds an assert. This assert helped to fix an issue
in one of the test cases.

The `printGnuHashHistogram` method also needs to be fixed. I am planning to fix it
independently after we land the D81928 <https://reviews.llvm.org/D81928>, which will allow to reuse the code that validates
the GNU hash table before the dumping.

Depends on: D81928 <https://reviews.llvm.org/D81928>


https://reviews.llvm.org/D81937

Files:
  llvm/include/llvm/Object/ELFTypes.h
  llvm/test/tools/llvm-readobj/ELF/gnuhash.test
  llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81937.271082.patch
Type: text/x-patch
Size: 6236 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200616/2d67a002/attachment.bin>


More information about the llvm-commits mailing list