From owner-freebsd-arch@FreeBSD.ORG Thu Feb 12 19:28:12 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 796DA1065670 for ; Thu, 12 Feb 2009 19:28:12 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) Received: from mail.ambrisko.com (mail.ambrisko.com [64.174.51.43]) by mx1.freebsd.org (Postfix) with ESMTP id 454188FC13 for ; Thu, 12 Feb 2009 19:28:11 +0000 (UTC) (envelope-from ambrisko@ambrisko.com) X-Ambrisko-Me: Yes Received: from server2.ambrisko.com (HELO www.ambrisko.com) ([192.168.1.2]) by ironport.ambrisko.com with ESMTP; 12 Feb 2009 11:00:17 -0800 Received: from ambrisko.com (localhost [127.0.0.1]) by www.ambrisko.com (8.14.1/8.14.1) with ESMTP id n1CIxaJm083446 for ; Thu, 12 Feb 2009 10:59:36 -0800 (PST) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.14.3/8.14.3/Submit) id n1CIxaJd083445 for arch@freebsd.org; Thu, 12 Feb 2009 10:59:36 -0800 (PST) (envelope-from ambrisko) From: Doug Ambrisko Message-Id: <200902121859.n1CIxaJd083445@ambrisko.com> To: arch@freebsd.org Date: Thu, 12 Feb 2009 10:59:36 -0800 (PST) X-Mailer: ELM [version 2.4ME+ PL94b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Cc: Subject: 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 19:28:12 -0000 Hi folks, 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. /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 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! 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 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 osversion sub-directory then the osversion major and finally the standard location. I even extended this to LD_PRELOAD and 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. 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 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/