DWARF parsing does not respect rebased image
Version and Platform (required):
- Binary Ninja Version: 4.1.4986-dev
- OS: macOS
- OS Version: 14
- CPU Architecture: M1
Bug Description: I tried to load a DWARF symbol file on a binary where I had set the base image, and the debuginfo parsing threw many many errors:
[Analysis error] Attempting to add function not backed by file: 0x28bfc00
[Analysis error] Attempting to add function not backed by file: 0x28c03b0
[Analysis error] Attempting to add function not backed by file: 0x28c0390
... (10000s more of these)
It seems like the DWARF loader did not respect my image base and tried to load it as if the file was based at 0, so none of the functions it found could resolve.
Steps To Reproduce: Please provide all steps required to reproduce the behavior:
- Open with Option on a file with DWARF info (i used a debug version of libbinaryninjacore.so
- Set the base address to something other than 0 or the default
- Observe errors
Expected Behavior: I expected my DWARF info to parse regardless of the base address.
The solution to this is likely a single line diff that adds the base address of the binary to what's coming in. Unsure if this affects just DWARF or not; Need to test with a PDB to see if that change needs to happen in the core or in the DWARF plugin.
Tried with a PDB a little while ago and they seem to respect the base address and work as expected
Perfect, thank you!
This should now be fixed in builds >= 4.1.5475-dev. We attempt to detect that the user has rebased the binary, calculate the difference, and apply that to functions from debug info that are being applied.
Kyle's earlier suggestion in this issue was good, but only works for situations where the original base was 0 (like in the original report). Fortunately, we have a test case where the original base is non-zero, so I was forced to also make that work. 🙂