Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 01 Apr 2004 00:28:28 -0500 (EST)
From:      Mike Heffner <mheffner@vt.edu>
To:        Igor Pokrovsky <tiamat@comset.net>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Determining a program's shared libraries at runtime
Message-ID:  <XFMail.20040401002027.mheffner@vt.edu>
In-Reply-To: <20040401025345.GA542@doom.homeunix.org>

next in thread | previous in thread | raw e-mail | index | archive | help

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       <mheffner@[acm.]vt.edu>
                         <mikeh@FreeBSD.org>



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