Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2009 22:11:01 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Doug Ambrisko <ambrisko@ambrisko.com>
Cc:        arch@freebsd.org
Subject:   Re: rtld enhancement to add osversion sub-directory search
Message-ID:  <20090212201101.GI2723@deviant.kiev.zoral.com.ua>
In-Reply-To: <200902121859.n1CIxaJd083445@ambrisko.com>
References:  <200902121859.n1CIxaJd083445@ambrisko.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--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/<osversion major), upgrade packages and=20
> 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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090212201101.GI2723>