Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Jan 2012 00:30:15 +0100
From:      Jilles Tjoelker <jilles@stack.nl>
To:        Luigi Rizzo <rizzo@iet.unipi.it>
Cc:        Garrett Cooper <yanegomi@gmail.com>, current@freebsd.org
Subject:   Re: add 'ldd' to cross-tools ?
Message-ID:  <20120104233015.GA51906@stack.nl>
In-Reply-To: <20120104225815.GA73964@onelab2.iet.unipi.it>
References:  <20120104222315.GA73613@onelab2.iet.unipi.it> <CAGH67wR0jwr9vtJWNCB=-947TSAxciEf971m4keNNkwxvO9SeQ@mail.gmail.com> <20120104222955.GA73868@onelab2.iet.unipi.it> <CAGH67wR8WCimVp8tn4MY=7=BWUubjma1Cjcsj0%2BqEqo4StK_wg@mail.gmail.com> <20120104225815.GA73964@onelab2.iet.unipi.it>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Jan 04, 2012 at 11:58:15PM +0100, Luigi Rizzo wrote:
> On Wed, Jan 04, 2012 at 02:30:27PM -0800, Garrett Cooper wrote:
> > On Wed, Jan 4, 2012 at 2:29 PM, Luigi Rizzo <rizzo@iet.unipi.it> wrote:
> ...
> > >> $ objdump -x `which tar` | awk '$1 == "NEEDED" { print $2 }'
> > >> libarchive.so.5
> > >> libbz2.so.4
> > >> libz.so.6
> > >> liblzma.so.5
> > >> libbsdxml.so.4
> > >> libcrypto.so.6
> > >> libc.so.7

> > > wonderful, thanks!

> >     Np! The only gap with both of these tools is that you have to
> > watch out for dl_open'ed binaries as they won't show up in ldd/objdump
> > -x. If I could figure out how to detect these with a command line
> > tool, I would be set for life :).

> and the other thing, i just realized, is that once you locate
> the libraries you should run objdump recursively to find
> out further dependencies. Perhaps ldd sorts this out by itself ?

ldd basically sets LD_TRACE_LOADED_OBJECTS=yes and runs the program
(after having checked it is a dynamic executable). This means it will
not work as a cross tool. Upsides are that it is simple and it shows
exactly what rtld would do (because it is rtld), handling things like
/var/run/ld-elf.so.hints, LD_LIBRARY_PATH and pathnames hardcoded into
objects.

You will have to run objdump (or readelf) recursively. (Note that there
are also use cases where just the non-recursive NEEDED tags are
appropriate, not all objects that happen to be loaded.)

-- 
Jilles Tjoelker



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120104233015.GA51906>