Listing all the function names of the stdlib of Rust

Hello, I'm a new Rustacean. I'm analyzing Rust binaries and recently my goal has been to list all the function names of the Rust stdlib, as they appear in a binary file (after demangling). So to do that I compiled rustc from source including debug info (for future use), disabling optimizations (as a way to remove inline functions), and analyzed the resulting libstd.so (in directory: /rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib) with a binary analyzer. Although I'm getting several function names of the stdlib from the symbol table of the above ELF file, I'm not taking them all.

For example in another Rust program where I use get_uchecked I'm getting this instruction in its assembly: call core::slice::<impl [T]>::get_unchecked. However, the core::slice::<impl [T]>::get_unchecked is not included in the function names that I get from the analysis of the libstd.so. However some other variations of the get_unchecked are there (in the results of libstd.so analysis) such as: <core::ops::range::Range as core::slice::index::SliceIndex<[T]>>::get_unchecked.

Am I doing something wrong? Is it possible to get all the possible function names that can be used from the Rust libstd? Thanks!

I'm not sure if I'm actually addressing what you're trying to do or not, but in general the answer is no. You'll only get the monomorphized ones that are used in the standard library itself.

You happened to pick a sealed trait, so I can't give a direct example. But consider this:

struct S;
impl<T> Index<S> for [T] {
    type Output = ();
    fn index(&self, _: S) -> &Self::Output {
        &()
    }
}

How would <[T] as core::ops::Index<S>>::index be in libstd.so? It's never heard of my struct S.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.