[llvm-readobj] - Add a validation of the GNU hash table to printGnuHashHistogram().
authorGeorgii Rymar <grimar@accesssoftek.com>
Wed, 17 Jun 2020 10:47:37 +0000 (13:47 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Fri, 19 Jun 2020 11:24:51 +0000 (14:24 +0300)
commitc587b076a0e56d6a70c3bb2b8f9d104a48edbfe4
treed6f7ed29360d33b002c4f8f98de25577c611a037
parent88f722c269a571f1e5ef7bcd16f15c4973eb6c73
[llvm-readobj] - Add a validation of the GNU hash table to printGnuHashHistogram().

Similar to D81937, we might crash when printing a histogram for a GNU hash table
with a 'symndx' index that is larger than the number of dynamic symbols.

This patch adopts and reuses the `getGnuHashTableChains()` helper which performs
a validation of the table. As a side effect the warning reported for
the --gnu-hash-table was improved.

Also with this change we start to report a warning when the histogram is requested for
the GNU hash table, but the dynamic symbols table is empty (size == 0).

Differential revision: https://reviews.llvm.org/D82010
llvm/test/tools/llvm-readobj/ELF/gnuhash.test
llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
llvm/tools/llvm-readobj/ELFDumper.cpp