How to list library dependencies of a non-native binary?

lvella picture lvella · Apr 7, 2012 · Viewed 73.8k times · Source

When developing for native platform, I can use ldd to list all the shared libraries (.so files) a binary executable I build will try to load upon start-up. But when cross-compiling, I don't know how to get the same information. The ldd is not a normal binutils utility, like strip or ar, that can be built alongside gcc for cross compiling, but instead, it is a cryptic shell script that apparently can only run on native platform.

So, using the cross-target binutils tools, is there any way to get a list of the dynamically linked dependency for of a foreign binary?

Answer

Employed Russian picture Employed Russian · Apr 7, 2012

is there any way to get a list of the dynamically linked dependency for of a foreign binary

You can list direct dependencies of a binary easily enough:

readelf -d a.out | grep NEEDED

 0x0000000000000001 (NEEDED)             Shared library: [librt.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]

I know of no way to recursively continue this to get the full list (as ldd does). You'll have to repeat the process for every NEEDED library by hand.