Tools for inspecting .rlib files
Asked Answered
U

2

7

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.

Undertaking answered 13/10, 2019 at 19:3 Comment(3)
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.Myrwyn
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 itUndertaking
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.Myrwyn
M
9

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
Myrwyn answered 14/10, 2019 at 14:24 Comment(0)
B
-3

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.

Brig answered 30/4, 2021 at 8:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.