From owner-freebsd-current@FreeBSD.ORG Wed Jan 4 23:30:16 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A68C61065675 for ; Wed, 4 Jan 2012 23:30:16 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay02.stack.nl [IPv6:2001:610:1108:5010::104]) by mx1.freebsd.org (Postfix) with ESMTP id 3ECF78FC1D for ; Wed, 4 Jan 2012 23:30:16 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id 8DE0B359356; Thu, 5 Jan 2012 00:30:15 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id 657B728468; Thu, 5 Jan 2012 00:30:15 +0100 (CET) Date: Thu, 5 Jan 2012 00:30:15 +0100 From: Jilles Tjoelker To: Luigi Rizzo Message-ID: <20120104233015.GA51906@stack.nl> References: <20120104222315.GA73613@onelab2.iet.unipi.it> <20120104222955.GA73868@onelab2.iet.unipi.it> <20120104225815.GA73964@onelab2.iet.unipi.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120104225815.GA73964@onelab2.iet.unipi.it> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Garrett Cooper , current@freebsd.org Subject: Re: add 'ldd' to cross-tools ? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Jan 2012 23:30:16 -0000 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 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