What is the difference between ldd and objdump?

I run these two commands, and I get another conclusion:

$ ldd `which ls` linux-gate.so.1 => (0x00db3000) libselinux.so.1 => /lib/i386-linux-gnu/libselinux.so.1 (0x00ba2000) librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0x007bf000) libacl.so.1 => /lib/i386-linux-gnu/libacl.so.1 (0x004ce000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x00110000) libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0x00398000) /lib/ld-linux.so.2 (0x00dea000) libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0x00a83000) libattr.so.1 => /lib/i386-linux-gnu/libattr.so.1 (0x00d3d000) 

and then

 objdump -x `which ls` | grep NEEDED NEEDED libselinux.so.1 NEEDED librt.so.1 NEEDED libacl.so.1 NEEDED libc.so.6 

What's up with that? I thought they both provided library dependencies? The reason is because I suspect ldd is correct, but I am working on linux on ARM where there is no ldd from what I can say ...

+15
linux objdump ldd
Jul 17 '12 at 14:33
source share
2 answers

You can see the difference in output.

objdump simply discards what the object itself lists as libraries containing unresolved characters.

ldd lists which ld.so libraries actually load. And this follows the graph back so you can see what will be loaded by these libraries. This is how libpthread.so.0 works on the output of ldd, even though it is not in the output of objdump.

So ldd is going to give a much better picture of what really needs to be available at runtime. But when solving compilation / link time issues, objdump is very useful.

+15
Jul 17 '12 at 14:44
source share

See HOWTO Program Library , Section 3.5. Installing and using a shared library :

Beware: do not run ldd in a program that you do not trust. As clearly indicated in the ldd (1) manual, ldd works (in some cases) by setting a special environment variable (for ELF objects, LD_TRACE_LOADED_OBJECTS), and then executes the program. Perhaps an unreliable program will force the ldd user to run arbitrary code (instead of just displaying ldd information). So, for security's sake, do not use ldd for programs you do not trust to run.

+1
Dec 10 '15 at 20:24
source share



All Articles