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

Robert P. J. Day rpjday at crashcourse.ca
Wed Mar 11 07:53:32 EDT 2009


On Tue, 10 Mar 2009, Chris Frey wrote:

> On Tue, Mar 10, 2009 at 05:10:38PM -0400, Robert P. J. Day wrote:
> >   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.
>
> If you have objdump on the embedded system, or if you can use objdump
> on your development system, you might try something like this:
>
> for f in $(ldd /bin/ls | grep "=> /lib" |awk '{print $3}') ; do
> 	if ! objdump -T $f | grep text | egrep $(objdump -T /bin/ls | grep UND | awk 'BEGIN {printf "("; start = 1} { if( start ) { start = 0; } else { printf "|" } printf "%s", $(NF) } END {printf ")"}') >/dev/null ; then
> 		echo "Useless: $f"
> 	fi
> done
>
>
> You'll have to replace the ldd output in the for loop with your LD_TRACE
> output.
>
> This was a quick hack, so it might not be completely accurate. Or useful. :-)

  interesting, i'll take a look at this later.  or maybe i'll just
write and submit a busybox version of "ldd" so i can build into my
embedded image.  :-)

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 mailing list