[llvm-readobj] - Do not crash when an invalid .eh_frame_hdr is dumped using --unwind.
authorGeorgii Rymar <grimar@accesssoftek.com>
Thu, 21 May 2020 14:29:18 +0000 (17:29 +0300)
committerGeorgii Rymar <grimar@accesssoftek.com>
Wed, 27 May 2020 13:41:09 +0000 (16:41 +0300)
commit4ab03e62fd040efdbde4b6c310e5abbda5363abd
tree44f813554c683bdaf31264e0374b0662dbe89981
parentad5d319ee85d31ee2b1ca5c29b3a10b340513fec
[llvm-readobj] - Do not crash when an invalid .eh_frame_hdr is dumped using --unwind.

When the p_offset/p_filesz of the PT_GNU_EH_FRAME is invalid
(e.g larger than the file size) then llvm-readobj might crash.

This patch fixes the issue. I've introduced `ELFFile<ELFT>::getSegmentContent`
method, which is very similar to `ELFFile<ELFT>::getSectionContentsAsArray` one.

Differential revision: https://reviews.llvm.org/D80380
llvm/include/llvm/Object/ELF.h
llvm/test/tools/llvm-readobj/ELF/unwind.test
llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h