From owner-freebsd-hackers Sat Jan 6 03:55:30 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id DAA14845 for hackers-outgoing; Sat, 6 Jan 1996 03:55:30 -0800 (PST) Received: from minnow.render.com (render.demon.co.uk [158.152.30.118]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id DAA14828 Sat, 6 Jan 1996 03:55:13 -0800 (PST) Received: (from dfr@localhost) by minnow.render.com (8.6.12/8.6.9) id LAA11562; Sat, 6 Jan 1996 11:53:28 GMT Date: Sat, 6 Jan 1996 11:53:27 +0000 (GMT) From: Doug Rabson To: John Polstra cc: hasty@rah.star-gate.com, freebsd-hackers@FreeBSD.ORG, jkh@FreeBSD.ORG Subject: Re: Anyone got GNU `dld' ported to FreeBSD? In-Reply-To: <199601060200.SAA03676@austin.polstra.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@FreeBSD.ORG Precedence: bulk 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