I have a rlib generated from this repository (a HAL library that could be used in embedded Rust) and I would like to identify the instruction sequences of functions in the library for my research work. Though there are many tools that are there for different languages, I couldn't find a tool that could work with rlib's. I found Rust library for inspecting .rlib binaries, but the tool noted here does not seem to be working.
2 Answers
The .rlib format is specific to Rust, and its format is unspecified. It is essentially the respective platform's static library format with some additional metadata in additional archive members. This means that you can use whatever tool you would use on your platform to inspect static libraries.
On Linux, you can use objdump -d to dump the disassembly of all functions in an .rlib file. All symbols will be mangled and hard to read, though, which can be fixed with rustfilt:
cargo install rustfilt objdump -d whatever.rlib | rustfilt Comments
when un archive the .rlib file, there is a .o file and .rmeta file.
Since .o is the object file and the .rmeta look like been defined in here.
.rlibs are just static libraries with some additional metadata. What platform are you on? On Linux, you should be able to use the standard tools that work for.afiles, e.g.ar,nmorobjdump. E.g.objdump -d whatever.rlibgives me the disassembly of all functions in an rlib. A script to unmangle the Rust symbols may be helpful as well.cargo install rustfiltand piping the output ofobjdumptorustfiltshould give you reasonable output.