m4b / goblin

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

Wrong dynamic library soname parsing #290

Open nagua opened 2 years ago

nagua commented 2 years ago

Hello everyone,

I wanted to get the soname of a shared library and readelf was able to correctly determine the name, but goblin wasn't able to do so. It just showed that the library had no soname. So I dug a bit in the elf file specification and was able to get the correct value. With goblin I could simply call elf.dynstrtab.get_at(elf.dynamic.unwrap().info.soname) and get the correct result. While implementing lazy parsing, I encountered that goblin refuses to set a soname if dyninfo.soname is zero. So checking for 0 isn't correct here: https://github.com/m4b/goblin/blob/b43b93ed2243b75043d6fb1021ad9aec227df1f5/src/elf/mod.rs#L297

I'm not sure how to correctly check if there isn't any soname.

Have a nice day everyone and thanks for the great library!