Skip to content
Commit 6cd47f9d authored by Sid Manning's avatar Sid Manning Committed by Fangrui Song
Browse files

[llvm-objdump] Fix spurious "The end of the file was unexpectedly encountered"...

[llvm-objdump] Fix spurious "The end of the file was unexpectedly encountered" if a SHT_NOBITS sh_offset is larger than the file size

llvm-objdump -D this file:

  int a[100000];
  int main() { return 0; }

Will produce an error: "The end of the file was unexpectedly encountered".

This happens because of a check in Binary.h checkOffset.  (Addr + Size > M.getBufferEnd()).

The sh_offset and sh_size fields can be ignored for SHT_NOBITS sections.
Fix the error by changing ELFObjectFile<ELFT>::getSectionContents to use
the file base for SHT_NOBITS sections.

Reviewed By: grimar, MaskRay

Differential Revision: https://reviews.llvm.org/D69192
parent f1b4c4bf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment