ghidra icon indicating copy to clipboard operation
ghidra copied to clipboard

External DWARF parsing errors

Open LostBenjamin opened this issue 2 years ago • 2 comments

Describe the bug ghidra throws an exception when parsing an external DWARF file. It cannot even correctly parse the DWARF version, which is located at the start of each compilation unit in the .debug_info section. The external DWARF file should be well formed, as it can be successfuly parsed by readelf or IDA Pro.

To Reproduce Steps to reproduce the behavior:

  1. Download and extract arm.tar.gz, which consists of the binary patch and the external DWARF file in the directory .build-id.
  2. Loading the binary in ghidra.
  3. Click Edit -> DWARF External Debug Config and set the directory to the one containing .build-id.
  4. Run the DWARF analyzer by Analysis -> One Shot -> DWARF.
  5. Wait and see error.

Expected behavior The error message is as follows:

Error during DWARFAnalyzer import: Only DWARF version 2, 3, or 4 information is currently supported (detected 31553).

Screenshots image

Attachments I also encountered a similar error on the x64 version of this binary: x64.tar.gz. The error message is as follows:

Error during DWARFAnalyzer import: Only DWARF version 2, 3, or 4 information is currently supported (detected 0).

Environment (please complete the following information):

  • OS: macOS 12.4
  • Java Version: openjdk 11.0.15 2022-04-19
  • Ghidra Version: 10.2
  • Ghidra Origin: locally built from commit 25aa4663d91965416d3e4c96cb9efa71d50d2eac

LostBenjamin avatar Jul 22 '22 07:07 LostBenjamin

initial troubleshooting: it looks like these binaries are using a newer option for compressed Elf sections that we don't support yet.

dev747368 avatar Jul 22 '22 15:07 dev747368

These binaries are taken from Ubuntu Debug Symbol Packages. pyelftools can also parse these binaries. Check this line and this line from pyelftools on how it handles compressed sections.

LostBenjamin avatar Jul 22 '22 20:07 LostBenjamin

If you are having issues with this, you can use the elfdecompress utility, with the following command: elfdecompress -vt none [file] to decompress the sections, which worked for me and I was able to analyze binaries afterward. This is a good workaround until it is fixed in Ghidra.

c0repwn3r avatar Apr 30 '23 14:04 c0repwn3r

Fixed by 0133090b0d84c15c28bf6ea63a14939c07eda71e

dev747368 avatar May 03 '23 22:05 dev747368