From owner-freebsd-hackers Thu Aug 5 20:57:46 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id AA7D214E3E; Thu, 5 Aug 1999 20:57:41 -0700 (PDT) (envelope-from jdp@polstra.com) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.9.3/8.9.1) with ESMTP id UAA27256; Thu, 5 Aug 1999 20:57:38 -0700 (PDT) (envelope-from jdp@polstra.com) From: John Polstra Received: (from jdp@localhost) by vashon.polstra.com (8.9.3/8.9.1) id UAA08168; Thu, 5 Aug 1999 20:57:37 -0700 (PDT) (envelope-from jdp@polstra.com) Date: Thu, 5 Aug 1999 20:57:37 -0700 (PDT) Message-Id: <199908060357.UAA08168@vashon.polstra.com> To: green@freebsd.org Subject: Re: NSS Project In-Reply-To: Organization: Polstra & Co., Seattle, WA Cc: hackers@freebsd.org Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article , Brian F. Feldman wrote: > > Mind pointing me to the technical reason why (I'm sure you've explained > it before) we can't use the dl* calls in any way without linking > against ld-elf.so.1? I mean, have them in libc, for instance... The versions in libc are just stubs. Take a look at "src/lib/libc/gen/dlfcn.c". The implementations are in the dynamic linker. > One option I don't think anyone's brought up: why don't we _just_ > have ld-elf.so.1 in the root, but not libraries? That way, we > don't bloat root excessively, but we can let people depend on > being able to build -static/-Bstatic binaries that make everything > static except the rtld? And modify gcc/ld to have static link with > the rtld, so we have the benefit of those calls, can have static > binaries still, and be able to depend on having an rtld (even for > single-user mode.) I think you have some misconceptions about how it all fits together. Executables aren't "linked with" the dynamic linker. It's a separate shared object that is loaded directly by the kernel. It gets control before the main executable gets control. Look at "src/sys/kern/imgact_elf.c" and at the dynamic linker. Also, programs that are linked (at "ld" time) with dynamic libraries are different from programs that are linked with static libraries. I.e., "ld" does very different things in the two cases. You can't take a statically-linked program and suddenly decide to treat it as dynamically-linked at runtime. It's too late at that point. Finally, shared "libraries" aren't really libraries at all in the traditional sense. They're monolithic whereas traditional archive libraries are made up of separate object files which are subsetted by the linker. To really understand the issues I think it's necessary to read through the dynamic linker sources and understand what it's doing. There used to be books that described how it all worked (Prentice-Hall "System V Application Binary Interface"), but as far as I know they're out of print now. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "No matter how cynical I get, I just can't keep up." -- Nora Ephron To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message