Re: Dynamic linking is go (again)

Marcus Comstedt <[email protected]>
Newsgroups gmane.os.netbsd.ports.sh3,gmane.os.netbsd.ports.dreamcast
Message-ID <[email protected]>
Jason Thorpe <[email protected]> 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.