Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 6 Jan 1996 11:53:27 +0000 (GMT)
From:      Doug Rabson <dfr@render.com>
To:        John Polstra <jdp@polstra.com>
Cc:        hasty@rah.star-gate.com, freebsd-hackers@FreeBSD.ORG, jkh@FreeBSD.ORG
Subject:   Re: Anyone got GNU `dld' ported to FreeBSD? 
Message-ID:  <Pine.BSF.3.91.960106115114.482D-100000@minnow.render.com>
In-Reply-To: <199601060200.SAA03676@austin.polstra.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 5 Jan 1996, John Polstra wrote:

> In article <199601041943.LAA05776@rah.star-gate.com> Amancio writes:
> > >>> "Jordan K. Hubbard" said:
> >  > Ours works just fine too, but I can't use dynamic linking from a
> >  > statically-linked application, which is what sysinstall needs to be.
> > 
> > What is your problem exactly when you try to use dlopen in a statically
> > compiled program?
> 
> The dlopen and related functions are implemented in the dynamic linker,
> /usr/libexec/ld.so.  The dynamic linker is itself a shared library.  It
> is mapped into the address space (i.e., it is made available) only for
> dynamically-linked programs.  So if your program is statically linked,
> it does not have access to the dl* functions.
> 
> This is exactly the same behavior as SVR4 and SunOS, by the way.
> 
> Also, a few people referred to the "static crt0.o" and the "dynamic
> crt0.o".  There is only one crt0.o.  It decides whether or not to invoke
> the dynamic linker, according to whether the program being run is
> dynamically linked.
> 
> I suppose it might be possible to add support for the dl* functions into
> the static libc.a.  I haven't thought through the ramifications of that.

Currently crt0.o checks the value of the __DYNAMIC symbol to decide when 
to load ld.so.  It then implements dl*() by indirecting through function 
pointers returned by the ld.so initialisation.

It would be pretty easy in a static binary to 'demand load' ld.so the 
first time a dl*() function was used, I think.

--
Doug Rabson, Microsoft RenderMorphics Ltd.	Mail:  dfr@render.com
						Phone: +44 171 251 4411
						FAX:   +44 171 251 0939




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.960106115114.482D-100000>