m4b / goblin

An impish, cross-platform binary parsing crate, written in Rust
MIT License
1.19k stars 158 forks source link

Don't return an error when some section are not correct #228

Open calixteman opened 4 years ago

calixteman commented 4 years ago

I have a debug file (IBM935.so.debug) which contains some incorrect info in dynamic section and so the section failed to be parsed with error Invalid PT_DYNAMIC size (offset 0x14db0, filesz 0x1f0) (offset & section come from the .so file and in this file they're correct). The problem is that I don't care at all about this section and I'd be fine to have dynamic: None in my Elf object. So would it be possible to not return an error or at least have a way to configure the way to handle errors ?

calixteman commented 4 years ago

A possibility is to have an Option< Result > for dynamic field and so let people handle errors like they want. Wdyt ?

m4b commented 4 years ago

what is the .debug file? is it additional dwarf debug information? Who produced it? Just wondering why the PT_DYNAMIC is incorrect; that's usually pretty bad. We could potentially make these changes but it would be a breaking change. Would like more information about what's going on (maybe the .debug file is just bad, e.g., and we shouldn't support it); can other tools parse this file, e.g., nm, objdump, etc.?

calixteman commented 4 years ago

IBM935.so.zip

The debug file comes from Fedora's glibc.

gabrielesvelto commented 4 years ago

The files are taken from this debuginfo package. One thing worth noting is that this file and other two from Fedora's glibc package exhibit this behavior and always did so in previous releases too, going back at least to Fedora 30. So it's not some kind of bug that was introduced recently.

nm and objdump both seem able to process the file but both print an empty dynamic section and no symbols. dwarfdump also doesn't seem to fail when processing the file and prints out the debug information. Looking at the DW_AT_producer entries the source was a mix of C and assembly files built with the following: