From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/2433 Path: news.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: static linking and dlopen Date: Sun, 9 Dec 2012 03:55:30 +0100 Message-ID: <20121209025529.GF23126@port70.net> References: <20121208225237.GV20323@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1355021747 11059 80.91.229.3 (9 Dec 2012 02:55:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 9 Dec 2012 02:55:47 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-2434-gllmg-musl=m.gmane.org@lists.openwall.com Sun Dec 09 03:56:00 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ThX3a-00019H-Gp for gllmg-musl@plane.gmane.org; Sun, 09 Dec 2012 03:55:54 +0100 Original-Received: (qmail 3459 invoked by uid 550); 9 Dec 2012 02:55:41 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 3450 invoked from network); 9 Dec 2012 02:55:41 -0000 Content-Disposition: inline In-Reply-To: <20121208225237.GV20323@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:2433 Archived-At: * Rich Felker [2012-12-08 17:52:37 -0500]: > Presently, it does not work at all. At best, it loses all the > advantages of static linking. i think it can work > With static linking, they would have to be loaded too. This means a > static-linked program using dlopen would have to contain the entire > dynamic linker logic. What's worse, it would also have to contain at > least the entire libc, and if you were using static versions of any > other library in the main program, and a loaded module referenced a > dynamic version of the same library, you'd probably run into > unpredictable crashing when the versions do not match exactly. i think one could make a dso that has no dependency (all dependencies are linked into it including libc), and no pointers are passed (directly or indirectly) to types which are not entirely part of the abi between the dso and the main binary (ie no FILE* or anything that might have different internals on the two sides) in that case dlopen() would work and even dlclose() can be safe (as the programmer has control over the entire code) of course care should be taken and it might not be very useful but one could implement loadable/unloadable plugins with static linking