From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 31 21:28:11 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3DA2016A4CE for ; Wed, 31 Mar 2004 21:28:11 -0800 (PST) Received: from lennier.cc.vt.edu (lennier.cc.vt.edu [198.82.162.213]) by mx1.FreeBSD.org (Postfix) with ESMTP id AAC3743D55 for ; Wed, 31 Mar 2004 21:28:10 -0800 (PST) (envelope-from mheffner@vt.edu) Received: from zidane.cc.vt.edu (IDENT:mirapoint@evil-zidane [10.1.1.13]) by lennier.cc.vt.edu (8.12.8/8.12.8) with ESMTP id i315RhDW481203; Thu, 1 Apr 2004 00:27:43 -0500 (EST) Received: from enterprise.fesnel.no-ip.org (cowpie.acm.vt.edu [128.173.42.253]) by zidane.cc.vt.edu (MOS 3.4.4-GR) with ESMTP id AMP26551; Thu, 1 Apr 2004 00:27:40 -0500 (EST) Message-ID: X-Mailer: XFMail 1.5-DEVEL on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit MIME-Version: 1.0 In-Reply-To: <20040401025345.GA542@doom.homeunix.org> Date: Thu, 01 Apr 2004 00:28:28 -0500 (EST) From: Mike Heffner To: Igor Pokrovsky cc: freebsd-hackers@freebsd.org Subject: Re: Determining a program's shared libraries at runtime X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Apr 2004 05:28:11 -0000 On 01-Apr-2004 Igor Pokrovsky wrote: | On Wed, Mar 31, 2004 at 02:55:47PM -0500, Mike Heffner wrote: |> |> Is there a method in FreeBSD for a program to retrieve the current list |> of |> dynamic shared libraries it is linked against or has dlopen()'d? | | Looks like ldd is doing exactly what you want, take a look at it's | sources. | Hello, thanks for the response. The problem I found with ldd was it would only give me the shared objects linked in at runtime and I needed the list of dlopen()'d objects as well. On Linux I was able to grab a reference to the link_map list and iterated through that. Matthew George on the list pointed me to dlinfo(3) which can return a reference into the link_map list. From my tests this appears to contain all dlopen()'d libraries as well (also the executable itself, btw). It also appears to be cleaner than the hack I'm using in Linux to get the same reference. ;-) Cheers, Mike -- Mike Heffner