[PATCH] D80380: [llvm-readobj] - Do not crash when an invalid .eh_frame_hdr is dumped using --unwind.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 21 08:03:40 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 marked an inline comment as done.
grimar added inline comments.


================
Comment at: llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h:113
+  if (!Content)
+    reportError(Content.takeError(), ObjF->getFileName());
+
----------------
Note: we might want to change this and all other `reportError` calls in the `PrinterContext<ELFT>` to report warnings.


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.


https://reviews.llvm.org/D80380

Files:
  llvm/include/llvm/Object/ELF.h
  llvm/test/tools/llvm-readobj/ELF/unwind.test
  llvm/tools/llvm-readobj/DwarfCFIEHPrinter.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80380.265506.patch
Type: text/x-patch
Size: 8344 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200521/47c55d85/attachment.bin>


More information about the llvm-commits mailing list