* dlsym() & multiple libs.so. how should it work
@ 1997-09-11 23:14 Uncle George
0 siblings, 0 replies; 3+ messages in thread
From: Uncle George @ 1997-09-11 23:14 UTC (permalink / raw)
I seem to have this prob with dlsym(RTLD_NEXT, name ). How should it work if u have
multiple shared libraries, some having the same module/routine name!
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"). the main()
routine also has use of libc.so which also contains an open() routine.
ergo:
private.so -> open()
libc.so.6 -> 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 ??
DONT ANSWER SO FAST. The program I am debugging, codewise, suggests that the address
should be from libc.so. remember that the dlopen occures within the private .so.
I was debugging on the alpha/axp box - but my intel seems to have the same
unpredictable behaviour.
Any authoratative documentation on the dlsym(RTLD_NEXT feature ???????
anyway it appears that the RTLD_NEXT feature needs some more work
gat aka Uncle george
>
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread[parent not found: <34187B6A.6F7DE1E0@voicenet.com>]
* Re: dlsym() & multiple libs.so. how should it work
[not found] <34187B6A.6F7DE1E0@voicenet.com>
@ 1997-09-12 3:20 ` Richard Henderson
0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 1997-09-12 3:20 UTC (permalink / raw)
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: dlsym() & multiple libs.so. how should it work
@ 1997-09-12 11:54 Uncle George
0 siblings, 0 replies; 3+ messages in thread
From: Uncle George @ 1997-09-12 11:54 UTC (permalink / raw)
This is a multi-part message in MIME format.
--------------9B57471D21E984BA65D3E7FF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Richard Henderson wrote:
> > 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 ??
> 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.
>
>
Plz try this pgm. lemme know if this doesn't surprise u. According to u I
should get open() from libc.so.6, but on axp ( i suspect i86 also ) u get
open() from open.so
--------------9B57471D21E984BA65D3E7FF
Content-Type: text/plain; charset=us-ascii; name="c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="c"
***************** c1.c ************************
#include <dlfcn.h>
int open ( int);
typedef int (*sym)();
void * mydlsym( void *, char *);
main ()
{
sym thispgm = (sym) &open;
sym libc_so = (sym) mydlsym(RTLD_NEXT, "open");
// put a breakpoint here
// see what libc_so contains
// rearrange the shared libs ( gdb/info share )
// you dont always get what u expect!!!!!!
// Uncle George
printf(" addr of open= %p, addr of dlsym = %p\n", thispgm, libc_so);
return;
open (21);
}
****************** open.c **************************
#include <dlfcn.h>
open(i)
{ ; }
void *
mydlsym(opt,name)
char *name;
void * opt;
{
int (*p)() = dlsym( opt, name );
return p;
}
*************************************
cc -g -c open.c
ld -G -o open.so open.o
cc -g -c c1.c
cc -o c1 c1.o open.so -ldl
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.
gdb c1
--------------9B57471D21E984BA65D3E7FF--
--
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1997-09-12 11:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-09-11 23:14 dlsym() & multiple libs.so. how should it work Uncle George
[not found] <34187B6A.6F7DE1E0@voicenet.com>
1997-09-12 3:20 ` Richard Henderson
-- strict thread matches above, loose matches on Subject: below --
1997-09-12 11:54 Uncle George
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox