8

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.

3
  • 1
    I think .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 .a files, e.g. ar, nm or objdump. E.g. objdump -d whatever.rlib gives me the disassembly of all functions in an rlib. A script to unmangle the Rust symbols may be helpful as well. Commented Oct 13, 2019 at 19:25
  • Thank you so much. I used objdump and and it seems to be working. Do you know a way that I could use a way to demangle the rust symbols? Sorry I am just a beginner to rust and have not much experience with it Commented Oct 13, 2019 at 19:44
  • 1
    Apparently I linked the wrong thing in the last comment. cargo install rustfilt and piping the output of objdump to rustfilt should give you reasonable output. Commented Oct 13, 2019 at 20:06

2 Answers 2

10

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 
Sign up to request clarification or add additional context in comments.

Comments

-2

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.