From owner-freebsd-arch Tue Feb 13 11:42:14 2001 Delivered-To: freebsd-arch@freebsd.org Received: from mobile.wemm.org (c1315225-a.plstn1.sfba.home.com [65.0.135.147]) by hub.freebsd.org (Postfix) with ESMTP id 3431C37B4EC for ; Tue, 13 Feb 2001 11:42:09 -0800 (PST) Received: from netplex.com.au (localhost [127.0.0.1]) by mobile.wemm.org (8.11.1/8.11.1) with ESMTP id f1DJffU66659; Tue, 13 Feb 2001 11:41:41 -0800 (PST) (envelope-from peter@netplex.com.au) Message-Id: <200102131941.f1DJffU66659@mobile.wemm.org> X-Mailer: exmh version 2.2 06/23/2000 with nmh-1.0.4 To: Warner Losh Cc: Dag-Erling Smorgrav , "Alexander N. Kabaev" , freebsd-arch@FreeBSD.ORG Subject: Re: Proposal on shared libs version values. In-Reply-To: <200102131717.f1DHHNW39519@harmony.village.org> Date: Tue, 13 Feb 2001 11:41:41 -0800 From: Peter Wemm Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Warner Losh wrote: > In message Dag-Erling Smorgrav writes: > : Hmm? I must have seriously misunderstood all the discussions that went > : on around E-day. > > What I had thought happened was that ld just uses the symbolic link > blindly. However, I just tried it on my system: > > cd /usr/lib > cp libc.so.4 libc.so.4.1 > ln -sf libc.so.4.1 libc.so > ldconfig -R > ldconfig -r | grep libc.so.4 > 33:-lc.4 => /usr/lib/libc.so.4 > > So it does look like it has to be a single number. Forget what I said > about 5.1 being a viable option. ldconfig -r is fake anyway. ld(1) does not use it. ldconfig -r exists only for the benefit of 3rd party scripts. > My OpenBSD box does have minor numbers appended, but they also have > hacks in their ld to cope. In order to inject facts into the discussion, consider: peter@mobile[11:22am]~src-161> objdump --all-headers /usr/lib/libc.so.5 ... Dynamic Section: SONAME libc.so.5 ... peter@mobile[11:22am]~src-162> ls -l /usr/lib/libc.so lrwxr-xr-x 1 root wheel 9 Dec 22 15:35 /usr/lib/libc.so@ -> libc.so.5 The way it works is this: - ld opens libc.so (via the symlink, it can be a hard link or copy even) - it sees the embedded DT_SONAME in the object. - the DT_SONAME is what gets copied to the DT_NEEDED of the program being linked. You had better hope they are the same file. :-) - at runtime, ld-elf.so.1 searches for "libc.so.5" by name because that is what was copied. If DT_SONAME had "libc.so.5.1", then that is what ld would copy to the application and ld-elf.so.1 will look for "libc.so.5.1". ldconfig has *nothing* to do with it except provide a list of directories for ld-elf.so.1 to look in, besides the hard coded /usr/lib. peter@mobile[11:27am]~src-166> strings /var/run/ld-elf.so.hints Ehnt /usr/lib:/usr/lib/compat:/usr/X11R6/lib:/usr/local/lib (that's "Elf Hint") Note there are no pathnames, version numbers, anything. ldconfig -r is simply doing a readdir() of /usr/lib and generating a fake a.out lookalike output. It can be easily fixed to deal with libc.so.5.1 if that is desirable. When libc is built, we could link it with "-h libc.so.5-13-Feb-2001" and that is what all applications will depend on (so it had better exist). At link time, all ld looks at is what is embedded in whatever it opens by opening "libc.so" and records the dependency embedded in there. Nothing would check if "libc.so.5-13-Feb-2001" actually existed until you tried to run the application that depended on it. This is not directed at anybody in particular, just an attempt to get some concrete facts and common understanding into the discussion. Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message