HomePhabricator

[libObject, llvm-readobj] - Reimplement `ELFFile<ELFT>::getEntry`.

Authored by grimar on Dec 11 2020, 3:54 AM.

Description

[libObject, llvm-readobj] - Reimplement ELFFile<ELFT>::getEntry.

Currently, ELFFile<ELFT>::getEntry does not check an index of
an entry. Because of that the code might read past the end of the symbol
table silently. I've added a test to llvm-readobj\ELF\relocations.test
to demonstrate the possible issue. Also, I've added a unit test for
this method.

After this change, getEntry stops reporting the section index and
reuses the getSectionContentsAsArray method, which already has
all the validation needed. Our related warnings now provide
more and better context sometimes.

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