LDD without LDD

Posted by Marcus Folkesson on Friday, January 27, 2017

LDD without LDD

I often meet colleges at work who gets frustrated when they try to see the shared libraries dependencies for an ELF file and the ldd command is simply stripped out from target. (I do often strip targets :-) )

The ldd command is not a binary executable but a script that simple calls the runtime dynamic linker with a few environment variables set, and you may do the same! The essential environment variable in this case is LD_TRACE_LOADED_OBJECTS, that should be set to something != 0.

In short, you may do:

1$ LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux.so.2 ./my_application.

Even the --list option may be used, but does not work on all targets:

1$ /lib/ld-linux.so.2 --list ./my_application.

Example outputs with ldd:

1$ ldd ./main
2linux-vdso.so.1 =>  (0x00007fffc8bff000)
3libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f564e254000)
4/lib64/ld-linux-x86-64.so.2 (0x00007f564e647000)

Example output without ldd:

1$ LD_TRACE_LOADED_OBJECTS=1 /lib64/ld-linux-x86-64.so.2 ./main
2linux-vdso.so.1 =>  (0x00007fffeecbc000)
3libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcce7700000)
4/lib64/ld-linux-x86-64.so.2 (0x00007fcce7af3000)

So, do not get frustrated, be happy.