[kwlug-disc] how to identify superfluous shared library references?

Robert P. J. Day rpjday at crashcourse.ca
Tue Mar 10 17:10:38 EDT 2009


On Tue, 10 Mar 2009, Khalid Baheyeldin wrote:

> >From the ldd man page, there is a -u for "Unused direct dependencies".
>
> root at salmon:~# ldd /bin/ls
>         linux-vdso.so.1 =>  (0x00007fff6c5fe000)
>         librt.so.1 => /lib/librt.so.1 (0x00007f1263fde000)
>         libselinux.so.1 => /lib/libselinux.so.1 (0x00007f1263dc2000)
>         libacl.so.1 => /lib/libacl.so.1 (0x00007f1263bbb000)
>         libc.so.6 => /lib/libc.so.6 (0x00007f1263859000)
>         libpthread.so.0 => /lib/libpthread.so.0 (0x00007f126363d000)
>         /lib64/ld-linux-x86-64.so.2 (0x00007f12641e7000)
>         libdl.so.2 => /lib/libdl.so.2 (0x00007f1263439000)
>         libattr.so.1 => /lib/libattr.so.1 (0x00007f1263235000)
>
> root at salmon:~# ldd -u /bin/ls
> Unused direct dependencies:
>         /lib/librt.so.1
>         /lib/libselinux.so.1
>         /lib/libacl.so.1
>
> Maybe that is what you need?

  it would be, except things are a bit trickier than that.  this is on
an embedded system that has no "ldd" command, but i've managed to
kludge that via the following:

  $ LD_TRACE_LOADED_OBJECTS=1 /bin/ls

that env var is recognized by the linker which prints out the shared
lib references for any command, just as "ldd" does.  problem is,
there's no way i can see to add the "-u" behaviour of ldd to that.

rday
--

========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry:
    Have classroom, will lecture.

http://crashcourse.ca                          Waterloo, Ontario, CANADA
========================================================================


More information about the kwlug-disc_kwlug.org mailing list