From: Eli Bendersky Date: Sat, 15 Oct 2016 21:08:50 +0000 (-0700) Subject: Issue #119: readelf - don't do hex/string dumps for SHT_NOBITS sections X-Git-Tag: v0.25~58 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c50de91f3d8d3ff2d3824bfd3c0ab39df72df94b;p=pyelftools.git Issue #119: readelf - don't do hex/string dumps for SHT_NOBITS sections --- diff --git a/scripts/readelf.py b/scripts/readelf.py index 60c9c3e..2a8b31e 100755 --- a/scripts/readelf.py +++ b/scripts/readelf.py @@ -304,7 +304,6 @@ class ReadElf(object): self._emitline(' Num: Value Size Type Bind Vis Ndx Name') for nsym, symbol in enumerate(section.iter_symbols()): - version_info = '' # readelf doesn't display version info for Solaris versioning if (section['sh_type'] == 'SHT_DYNSYM' and @@ -572,6 +571,10 @@ class ReadElf(object): self._emitline("Section '%s' does not exist in the file!" % ( section_spec)) return + if section['sh_type'] == 'SHT_NOBITS': + self._emitline("\nSection '%s' has no data to dump." % ( + section_spec)) + return self._emitline("\nHex dump of section '%s':" % section.name) self._note_relocs_for_section(section) @@ -615,6 +618,10 @@ class ReadElf(object): self._emitline("Section '%s' does not exist in the file!" % ( section_spec)) return + if section['sh_type'] == 'SHT_NOBITS': + self._emitline("\nSection '%s' has no data to dump." % ( + section_spec)) + return self._emitline("\nString dump of section '%s':" % section.name)