From owner-freebsd-arch@FreeBSD.ORG Thu Feb 12 20:11:21 2009 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D5A01065693 for ; Thu, 12 Feb 2009 20:11:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.terabit.net.ua (mail.terabit.net.ua [195.137.202.147]) by mx1.freebsd.org (Postfix) with ESMTP id BAA4A8FC12 for ; Thu, 12 Feb 2009 20:11:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from skuns.zoral.com.ua ([91.193.166.194] helo=mail.zoral.com.ua) by mail.terabit.net.ua with esmtps (TLSv1:AES256-SHA:256) (Exim 4.63 (FreeBSD)) (envelope-from ) id 1LXhu0-000EqX-TT; Thu, 12 Feb 2009 22:11:16 +0200 Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id n1CKB1B1051221 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 12 Feb 2009 22:11:01 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3) with ESMTP id n1CKB16X072032; Thu, 12 Feb 2009 22:11:01 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.3/8.14.3/Submit) id n1CKB1RL072031; Thu, 12 Feb 2009 22:11:01 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 12 Feb 2009 22:11:01 +0200 From: Kostik Belousov To: Doug Ambrisko Message-ID: <20090212201101.GI2723@deviant.kiev.zoral.com.ua> References: <200902121859.n1CIxaJd083445@ambrisko.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LiQwW4YX+w4axhAx" Content-Disposition: inline In-Reply-To: <200902121859.n1CIxaJd083445@ambrisko.com> User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: ClamAV version 0.94.2, clamav-milter version 0.94.2 on skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua X-Virus-Scanned: mail.terabit.net.ua 1LXhu0-000EqX-TT 5fc29a02cff3c55cba36ffce4e5c3b37 X-Terabit: YES Cc: arch@freebsd.org Subject: Re: rtld enhancement to add osversion sub-directory search X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 20:11:21 -0000 --LiQwW4YX+w4axhAx Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Feb 12, 2009 at 10:59:36AM -0800, Doug Ambrisko wrote: > Hi folks, >=20 > I'd like to discuss the idea of adding an automatic directory search > feature to rtld. At work we need to run 3rd party code that we get > as objects or even binaries that are compiled by other groups. This > works okay when our base OS is the same as the 3rd party but not so > good when we upgrade our base OS and we don't want to force th 3rd > party code to upgrade at the same time. Sometimes they can't since > legacy systems that needs to run the 3rd party code run the older > OS. Now WRT to FreeBSD's base libraries this isn't much of a problem > since the OS's lib's general bump version between releases so just > via the name we have unique lib's and the loader can get the correct > one. However, once you start to link to stuff in ports (ie.=20 > /usr/local/lib) then these names are no longer unique and something > built for FreeBSD 4 through 7 (as part of FreeBSD's release, ie=20 > pre-built packages) end up with the same name. This is a problem since > sticking the old version in /usr/lib/compat is a problem since it > looks based on name (ie. /usr/local/lib/libiconv.so.3). Things can > get interesting when the /usr/local/lib pulls in libc. So now your > FreeBSD 4 binary could pull in a libiconv.so.3 for FreeBSD 7 and > libc from FreeBSD 7. Interesting things start to happen! >=20 > What I've done for work is to teach the rtld to look for the > .note.ABI-tag and extract the osversion. I then put that and the=20 > osversion major number (ie. 6 instead of 603000) into a "try" list. > Then whenever an object/lib is attemped to be accessed I look in the=20 > osversion sub-directory then the osversion major and finally the > standard location. I even extended this to LD_PRELOAD and=20 > insert this try into the path just before the object/lib if fully > qualified. Actually, I do it for all fully qualified things. > Now I can stick most things into /usr/lib/compat/6 and it just > works. For fully qualified LD_PRELOAD I "mv" things on boot > into the sub-directory for that OS. Also I had to change LD_PRELOAD > to accept failure if the thing wasn't found since children in herit > that and if it a different version that LD_PRELOAD might not be > applicable. >=20 > I don't really see a maintain for rtld since jdp when I worked with > him to add LD_PRELOAD. I'd like to get feed back on this idea and > get it into FreeBSD. It would help solve some of these issues for > other people as well. It definitely, made my life easier at work. > It would also make things easier on my FreeBSD machines, when I=20 > upgrade the OS and ports but have legacy compiled things that I > don't want to recompile again. I could move all of my /usr/local/libs > into /usr/local/lib/compat/ still run my old stuff. I've had issues before when OO was cross-linked > with libc from 6 and 7 due to this. Rebuilding OO was not fun and > I shouldn't have needed to. >=20 > There is one glitch in atleast FreeBSD 6.1 didn't put the .note.ABI-tag > into binaries so for now if not specified I assume FreeBSD 6. That > is good enough for work but I could add an env. variable to hold > the default. If not set then it wouldn't do the sub-directory thing > on binaries that are not known. >=20 > Loading of objects will slow done a bit since it adds extra=20 > searches. It might be good enough to just do the os version major=20 > and not for the complete osversion. >=20 > BTW, I also added a feature to look at LD32_ first then LD_ > when running 32bit on 64bit. Legacy SW doesn't know about > LD32_ and just sets LD_. This way that stuff doesn't need > to be taught about LD32_ when it shouldn't really need to. There is a popular feature, unfortunately, not supported by FreeBSD ld.so, called Dynamic String Tokens, see http://docs.sun.com/app/docs/doc/817-1984/appendixc-4?l=3Den&a=3Dview I have almost abandoned patch that adds support for $ORIGIN, $OSREL, $OSNAME, and $PLATFORM. Quite amazingly, it merged with today CURRENT without serious conflicts. http://people.freebsd.org/~kib/misc/rtld_locks.4.patch --LiQwW4YX+w4axhAx Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEARECAAYFAkmUglQACgkQC3+MBN1Mb4jXKwCg7pWUsPFfaSLafOs4TLiyEMfN WTwAoNnOoF1fOh0jmEMLbEajxM+fwIZ1 =h7ot -----END PGP SIGNATURE----- --LiQwW4YX+w4axhAx--