onie/onie — pull request #5 by cbrune (2014-06-16 18:27:29+00:00)
Title: Add ldd support to uClibc

Reviewed By: dustin

When debugging dynamically linked C programs it is useful to see which
libraries the executable is loading. The ldd(1) utility is often used
for this purpose.

This patch enables LDD support in the uClibc configuration for x86 and
powerpc architectures.

At runtime on the target platform you can get basic LDD information by
setting the environment variable LD_TRACE_LOADED_OBJECTS=1. For
example:

ONIE:/ # LD_TRACE_LOADED_OBJECTS=1 /usr/bin/grub-mkimage
libdevmapper.so.1.02 => /usr/lib/libdevmapper.so.1.02 (0x7fc806c29000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x7fc806a14000)
libc.so.0 => /lib/libc.so.0 (0x7fc8067c8000)
libpthread.so.0 => /lib/libpthread.so.0 (0x7fc8065b0000)
libm.so.0 => /lib/libm.so.0 (0x7fc8063a3000)
libdl.so.0 => /lib/libdl.so.0 (0x7fc80619f000)
ld64-uClibc.so.0 => /lib/ld64-uClibc.so.0 (0x7fc806e62000)

In addition the patch adds a new Makefile target, ldd, which you can
use to run a "cross ldd" on your build host. The utility is provided
by the crosstool-ng project.

For example to inspect the /usr/bin/grub-mkimage binary you would
invoke the Makefile 'ldd' target like this:

build-04:~/onie/build-config$ gmake -j48 ldd LDD_TARGET=usr/bin/grub-mkimage
libdevmapper.so.1.02 => /usr/lib/libdevmapper.so.1.02 (0x00000000deadbeef)
libpthread.so.0 => /lib/libpthread.so.0 (0x00000000deadbeef)
ld64-uClibc.so.0 => /lib/ld64-uClibc.so.0 (0x00000000deadbeef)
libdl.so.0 => /lib/libdl.so.0 (0x00000000deadbeef)
libc.so.0 => /lib/libc.so.0 (0x00000000deadbeef)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00000000deadbeef)
libm.so.0 => /lib/libm.so.0 (0x00000000deadbeef)

Testing Done:

Built images for powerpc and x86 targets. Verify the run-time and
build-time LDD information is working.

Signed-off-by: Curt Brune