This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Do not crash when SHT_HASH table is broken.
ClosedPublic

Authored by grimar on Mar 31 2020, 7:54 AM.

Details

Summary

We have scenarios when the logic of --elf-hash-histogram/--hash-symbols/--hash-table
options might crash when given a broken hash table.

This patch adds pre-checks for tables for these 3 options
and provides test cases.

Diff Detail

Event Timeline

grimar created this revision.Mar 31 2020, 7:54 AM
MaskRay accepted this revision.Mar 31 2020, 10:38 AM

Thanks!

llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
116

starts with

llvm/tools/llvm-readobj/ELFDumper.cpp
2619

starts with

I think "Hence the length of a hash table can't be less than 8 bytes." is naturally inferred from the first sentence.

This revision is now accepted and ready to land.Mar 31 2020, 10:38 AM
jhenderson added inline comments.Apr 1 2020, 12:15 AM
llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
116

(Also applies in the other tests)

117

points to data (also applies in other tests)

122

I'd spell out "EOF" in error messages (i.e. "goes past the end of the file"). Same goes below.

152

end of the file

llvm/test/tools/llvm-readobj/ELF/hash-symbols.test
387

end of the file

408

This line probably wants splitting.

llvm/test/tools/llvm-readobj/ELF/hash-table.test
163

All these lines probably want splitting.

grimar updated this revision to Diff 254152.Apr 1 2020, 3:42 AM
grimar marked 10 inline comments as done.
grimar edited the summary of this revision. (Show Details)
  • Addressed review comments.
llvm/test/tools/llvm-readobj/ELF/hash-histogram.test
122

Ok. My motivation was to make error messages shorter, but I have no preference and I've expected to get a comment like this too :)

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptApr 1 2020, 8:15 AM