This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Finding the path of the current binary?
Mike Hearn <mike at theoretic dot com> writes:
|> On Fri, 2003-03-07 at 20:18, Roland McGrath wrote:
|> > You can use the DT_DEBUG slot or just the _r_debug symbol, to find the the
|> > `r_map' member giving the head of the struct link_map list (see <link.h>).
|> > Then l_name in each struct link_map gives you the file name that was opened.
|>
|> Doesn't that require the library knows its own soname?
It does, it's part of the ABI and referenced from the dynamic table in the
DT_SONAME slot. The dynamic table itself is reachable via _DYNAMIC.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab at suse dot de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."