Subject: Re: Dynamic linking is go (again)
To: Jason Thorpe <thorpej@wasabisystems.com>
From: Marcus Comstedt <marcus@mc.pp.se>
List: port-sh3
Date: 07/04/2003 13:55:00
Jason Thorpe <thorpej@wasabisystems.com> writes:

> On Thursday, July 3, 2003, at 01:44  PM, Marcus Comstedt wrote:
> 
> > Well, this works, but then how come I don't need the -E flag when I
> > link against the shared object?  That is, if I do
> >
> >   gcc -o prog foo.o -R. bar.so
> >
> > then bar can access the symbols in foo without -E, but if I instead
> > dlopen() bar.so from foo, -E is needed.  I think the semantics
> > should be
> > the same for these two cases, if I specify RTLD_GLOBAL to dlopen()...
> 
> I think in this case you're simply linking a PIC object directly into
> the executable, right?  It's not actually recording a dependency on
> bar.so in the binary, is it?

No, I'm not.  If I ldd the resulting binary, it shows a dependency on
bar.so.  If you specify a .a or .so on the command line to ld, it has
the same effect as linking it with -l, only that you can specify the
path explicitly.  Right now I'm thinking maybe ld will automatically
add exports of symbols in the main binary if it can see that they are
being used from a shared object?  That would explain the behaviour,
but it would be a bit underhanded of ld...  :-)  I'll investigate
further.


  // Marcus