[PATCH] D69192: llvm-objdump can error out with an unexpected EOF error if .bss is larger than the file being dumped.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 24 14:02:40 PDT 2019


MaskRay added a comment.

LG after grimar's comment is addressed.



================
Comment at: llvm/include/llvm/Object/ELFObjectFile.h:727
+  if (EShdr->sh_type == ELF::SHT_NOBITS)
+    return makeArrayRef((const uint8_t *)base() + EShdr->sh_offset, 0);
   if (std::error_code EC =
----------------
sidneym wrote:
> grimar wrote:
> > MaskRay wrote:
> > > Delete `+ sh_offset` to solve the problem I described in a previous comment.
> > It is strange to know that sh_offset can be greater than the file size.
> > 
> > If we want to have this change and not error out, I'd add a comment and a one more test case for
> > this (yaml2obj allows overriding the sh_offset with use of "ShOffset" field).
> I don't think sh_offset will be larger than the file size but sh_offset+sh_size can be and that would cause checkOffset to fail.  I guess one could argue that if sh_offset is outside the scope of the file something is really bogus about the file but if the section NOBITS maybe it doesn't matter.
It can be larger than the file size with some usage of objcopy. We can proceed with this change for now. I'll come up a test later.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69192/new/

https://reviews.llvm.org/D69192





More information about the llvm-commits mailing list