I have created a cross compiled arm executable. I want to find the library dependency of the executable. I am using ubuntu natty and installed arm-linux-gnueabi tool chain, which does not contain ldd. Is there a tool available to view arm executables library dependancy in linux.
相关问题
- Is shmid returned by shmget() unique across proces
- Why doesn't php sleep work in the windows-subs
- how to get running process information in java?
- Installing Pydev for Eclipse throws error
- Error building gcc 4.8.3 from source: libstdc++.so
I found this and hope it can help a lot of people who are still searching for a true ldd solution. ldd is just a script with support of ld-linux library. So why not making your own ldd script? First you need to find ld-linux library in your system, which should be available. In my case it is /lib/ld-linux-armhf.so.3 so I put this into RTLDLIST as you can see in the script below.
And put this script in your device or board and you can have ldd which is very convenient to find dependents libraries for an executable.
Good luck!
This is a bit of a kluge, but it's the best solution I could find, and it really works quite well for basic use - just save this script as "arm-none-linux-gnueabi-ldd" with your other cross tools.
As already said, by design
ldd
can only been executed on target. However, it is possible to mimicldd
behavior usingreadelf
. A script calledxldd
was developed incrosstool-ng
project. An independent version of this script is available here:https://gist.github.com/jerome-pouiller/c403786c1394f53f44a3b61214489e6f
I found a solution when running into [Sourceware.Bugzilla]: Bug 16628 - Segfault after a binary without pthread dlopen()s a library linked with pthread while working on a project (which involved porting some C++ code on ARM).
I'm using Ubtu 16.04, and for ARM cross compile tools I installed g++-4.9-arm-linux-gnueabihf (and dependencies, and also forced me to uninstall g++-multilib (and dependencies)). For testing (running) the executables, I installed QEMU (qemu-user-static).
According to [man7]: LDD(1) (which is just a shell (bash) script):
I'm going to exemplify on the data from the above bug report.
issue16417.cpp:
build_issue16417.sh (removed flags unsupported by the compiler):
Output:
As expected, (regular) ldd doesn't work for ARM binaries.
In the ldd script, there's a line (no other one references .sos) somewhere at the beginning:
As seen, it doesn't have the correct ld.so (so far there are only the i686 and x86_64 ones), so it can't handle ARM binaries. To make things work, either (note that for each option, sudo is required):
I chose the 2nd variant. But where is ARM ld.so? As you probably guessed, it can be obtained from ${_QEMU_CMD} env var (after all, qemu needs it as well). On my machine it's: /usr/arm-linux-gnueabihf/lib/ld-2.23.so (libc6-armhf-cross required, but that should be installed by now). So, I copied ldd to arm-linux-gnueabihf-ldd, and replaced the above line with:
Also posting the diff format (check [SO]: Run/Debug a Django application's UnitTests from the mouse right click context menu in PyCharm Community Edition? (@CristiFati's answer) (Patching utrunner section) for how to apply it):
Try running the "new" ldd on the ARM executable, and voilà:
Note: What comes next, is not part of the question / answer.
Anyway, replacing --as-needed by --no-as-needed in build_issue16417.sh, yields:
:)
Here is another option, you can set LD_TRACE_LOADED_OBJECTS environment variable to any value, say 1, and then you just run the executable, the output should be its dynamic dependencies.
You could also use objdump and in order to just dump and search the header fraction of the binary. This may save you some milliseconds...