[all-commits] [llvm/llvm-project] 6cd47f: [llvm-objdump] Fix spurious "The end of the file w...

SidManning via All-commits all-commits at lists.llvm.org
Tue Nov 5 11:14:46 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 6cd47f9dd7dd664ff855fb0d1ed26bf5e4bb77fc
      https://github.com/llvm/llvm-project/commit/6cd47f9dd7dd664ff855fb0d1ed26bf5e4bb77fc
  Author: Sid Manning <sidneym at quicinc.com>
  Date:   2019-11-05 (Tue, 05 Nov 2019)

  Changed paths:
    M llvm/include/llvm/Object/ELFObjectFile.h
    A llvm/test/tools/llvm-objdump/X86/elf-disassemble-bss.test

  Log Message:
  -----------
  [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




More information about the All-commits mailing list