Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <rth@cygnus.com>
Subject: Re: dlsym() &amp; multiple libs.so. how should it work
Date: Thu, 11 Sep 1997 20:20:14 -0700 (PDT)	[thread overview]
Message-ID: <199709120320.UAA26535@rtl.cygnus.com> (raw)
In-Reply-To: <34187B6A.6F7DE1E0@voicenet.com>

> say for instance i have a main(), and a private .so (private because I
> created it for this pgm). in the private .so there is a global open()
> routine. ALSO in the private .so, in another routine, there is a call
> to dlsym(RTLD_NEXT, "OPEN").
[...]
> What address should be returned - the open from my private .so, or the
> one from libc.so ?? if dlsym was called from private.so ??

I'm assuming here the dependencies (see objdump -p):

main: 
	DT_NEEDED	private.so
	DT_NEEDED	libc.so.6

RTLD_NEXT returns the symbol from the shared object "next" on the
dependancy list from the location of call.  Thus if main uses it,
it will find the symbol in private.so, and if private.so uses it,
it will find it in libc.so.6.

The dependancy list generation, btw, is defined by ELF to be a 
breadth-first search of the DT_NEEDED's.  Look in the ELF docs for
exact details.

Now, things are a bit different if main uses dlopen() to bring in
private.so.  There are two sub cases here, with and without RTLD_GLOBAL.
Without, there exists a dependancy list as if main and private.so
(and all of private.so's dependencies) were the only things on the
chain.  With, private.so gets put on the global chain somewhere, but
I forget exactly where, probably the end.

r~

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

       reply	other threads:[~1997-09-12  3:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <34187B6A.6F7DE1E0@voicenet.com>
1997-09-12  3:20 ` Richard Henderson [this message]
1997-09-12 11:54 dlsym() &amp; multiple libs.so. how should it work Uncle George
  -- strict thread matches above, loose matches on Subject: below --
1997-09-11 23:14 Uncle George
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox