Vector35 / dwarf_import

This loads DWARF info from an open binary and propagates function names, arguments, and type info
MIT License
24 stars 7 forks source link

`AttributeError: 'BinaryReader' object has no attribute 'tell'` #14

Closed yvt closed 2 years ago

yvt commented 2 years ago
Traceback (most recent call last):
  File "/nix/store/j2g1lns927px777irnraxk63fh91kppy-binary-ninja-personal/opt/plugins/../python/binaryninja/plugin.py", line 227, in _default_is_valid
    return is_valid(view_obj)
  File ".../.binaryninja/repositories/official/plugins/Vector35_dwarf_import/__init__.py", line 60, in is_valid
    return raw and elf and ELFFile(bn.binaryview.BinaryReader(bv.file.raw)).has_dwarf_info()
  File ".../.binaryninja/python39/site-packages/elftools/elf/elffile.py", line 182, in has_dwarf_info
    return bool(self.get_section_by_name('.debug_info') or
  File ".../.binaryninja/python39/site-packages/elftools/elf/elffile.py", line 124, in get_section_by_name
    for i, sec in enumerate(self.iter_sections()):
  File ".../.binaryninja/python39/site-packages/elftools/elf/elffile.py", line 133, in iter_sections
    yield self.get_section(i)
  File ".../.binaryninja/python39/site-packages/elftools/elf/elffile.py", line 113, in get_section
    return self._make_section(section_header)
  File ".../.binaryninja/python39/site-packages/elftools/elf/elffile.py", line 569, in _make_section
    return ARMAttributesSection(section_header, name, self)
  File ".../.binaryninja/python39/site-packages/elftools/elf/sections.py", line 474, in __init__
    self.subsec_start = self.stream.tell()
AttributeError: 'BinaryReader' object has no attribute 'tell'

The error only occurs when an Arm ELF file is opened. It doesn't occur with x86.

Systen information

ElykDeer commented 2 years ago

This should be resolved in version 1.1.0.

ElykDeer commented 2 years ago

You'll need to be on the development branch to use the plugin, now, however... Until the next stable (presumably 3.0).

0bs3n commented 2 years ago

This is not fixed in version 1.1.1 (latest from master at time of writing) Binary Ninja version: 2.5.3112-dev File information: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.31, with debug_info, not stripped

I see the same error that yvt reported.

ElykDeer commented 2 years ago

Would you be able to provide the binary?

0bs3n commented 2 years ago

See below

0bs3n commented 2 years ago

Thanks for waiting -- here is a binary with which you can reproduce the behavior. arm-unpack.tar.gz For reference, this was compiled like so: gcc -gdwarf arm-unpack.c -o arm-unpack -lcrypto

Green-Avocado commented 2 years ago

I get the same error on some x86-64 ELFs with DWARF Import 1.1.1, Binary Ninja 3.0.336-dev Personal