ldd equivalent on android
Asked Answered
R

4

23

I have a libTest.so that does not load on some devices. logcat is absolutely useless. Using arm-linux-androideabi-readelf.exe -d libTest.so I was able to see all required libs that libTest.so needs. I pulled them all in, into the same folder on my local PC.

How can I find out which symbols is missing and in which library? I have only standard set of tools from the NDK (nm, readelf, objdump etc). Which tool and how can I use so that it parses my libTest.so and all dependent libs as well and tells me which symbol prevents my lib from loading on the target device.

Risser answered 20/3, 2013 at 20:32 Comment(1)
<NDK_DIR>/toolchains/llvm/prebuild/<HOST_OS>/bin/<ARCH>-strings | grep ^lib | grep soCatabolism
R
21

Thanks to android developers. My feature request was implemented :) Now we have ndk-depends, a tool that allows to troubleshoot dependencies.

Edit: it doesn't do full symbol resolution though. E.g. if you build against Android-14 and try to use methods that didn't exist in old Androids, then this tool won't list missing symbols. This part was left as a TODO in ndk-depends.

Risser answered 5/10, 2013 at 22:40 Comment(1)
unfortunately ndk-depends was removed in ndk r19: github.com/android/ndk/wiki/Changelog-r19#announcementsStickle
Y
23

If you don't have the NDK try doing:

readelf --dynamic filename | grep NEEDED

to display the dynamic libraries for an elf binary.

Yurev answered 19/10, 2016 at 11:41 Comment(0)
R
21

Thanks to android developers. My feature request was implemented :) Now we have ndk-depends, a tool that allows to troubleshoot dependencies.

Edit: it doesn't do full symbol resolution though. E.g. if you build against Android-14 and try to use methods that didn't exist in old Androids, then this tool won't list missing symbols. This part was left as a TODO in ndk-depends.

Risser answered 5/10, 2013 at 22:40 Comment(1)
unfortunately ndk-depends was removed in ndk r19: github.com/android/ndk/wiki/Changelog-r19#announcementsStickle
C
6

At Android terminal try this:
strings /path/to/your/file | grep ^lib Found here: https://forum.xda-developers.com/showthread.php?t=2737126&page=5

Cornflakes answered 24/2, 2017 at 22:13 Comment(0)
M
0

You can do something like:

$ /lib/ld-linux.so.2 --list filename

This is because ldd is just a shell script that works like a wrapper around the dynamic loader. The name of the dynamic loader, i.e., ld-{version}.so might differ.

Melanosis answered 15/8, 2013 at 17:27 Comment(2)
Android appears to use /system/bin/linker and not /lib/ld-linux.so . Anyhow I can't get linker to output anythingBathypelagic
I just get Segmentation fault when invoking /system/bin/linker directly, no matter what arguments I use!Khoury

© 2022 - 2024 — McMap. All rights reserved.