From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8877 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: some odd library loading errors Date: Tue, 17 Nov 2015 12:13:20 -0500 Message-ID: <20151117171320.GA3818@brightrain.aerifal.cx> References: <20151117121429.GI26951@example.net> <20151117152355.GF18372@port70.net> <20151117152728.GX3818@brightrain.aerifal.cx> <20151117154515.GG18372@port70.net> <20151117155545.GZ3818@brightrain.aerifal.cx> <20151117163359.GH18372@port70.net> 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 1447780424 25844 80.91.229.3 (17 Nov 2015 17:13:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 17 Nov 2015 17:13:44 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-8890-gllmg-musl=m.gmane.org@lists.openwall.com Tue Nov 17 18:13:39 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1Zyjp0-0008Ao-UZ for gllmg-musl@m.gmane.org; Tue, 17 Nov 2015 18:13:35 +0100 Original-Received: (qmail 20466 invoked by uid 550); 17 Nov 2015 17:13:33 -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 20442 invoked from network); 17 Nov 2015 17:13:32 -0000 Content-Disposition: inline In-Reply-To: <20151117163359.GH18372@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:8877 Archived-At: On Tue, Nov 17, 2015 at 05:34:00PM +0100, Szabolcs Nagy wrote: > * Rich Felker [2015-11-17 10:55:45 -0500]: > > On Tue, Nov 17, 2015 at 04:45:16PM +0100, Szabolcs Nagy wrote: > > > > > > i guess --disable-gnu-indirect-function could be the default when > > > gcc targets musl (assuming musl will not implement ifuncs anytime soon). > > > > I think that's a reasonable assumption. Based on what I've seen > > lately, rather than finding solutions to the problems we knew about > > already, the rabbit hole keeps going deeper... > > > > If you have reason to believe otherwise could you explain how we might > > reasonably support ifunc? > > > > well we can add support for ifunc by.. > > calling the ifunc resolver during reloc processing when STT_GNU_IFUNC > symbol or R_*_IRELATIVE reloc is found and in case of static linking > the relocs between __rel_iplt_{start,end} should be processed somehow. This is probably a significant code size burden for static linking unless there's some way to avoid linking it when ifunc is not used. There's also the static-pie case you haven't considered, which would require its own separate implementation. Presumably that would be processing R_*_IRELATIVE since symbolic relocations are not permitted here. > the only ugliness is that passing arguments to the resolver is arch > specific.. and that there is no guarantee what the resolver might do > (but that's the same with glibc and it is something the user should > worry about) Well that's ugly too. > i think even if musl does the reloc processing in different order > than glibc, this might work in practice and if the resolver crashes > we can say that it invoked ub. It seems to me that order issues, except for circular dependencies, are less of an issue when you have a lazy resolver; if A gets resolved first but A needs B, then calling B invokes the lazy resolver and all is fine. Since musl doesn't (and won't) have lazy resolver, the whole setup seems much more fragile. Then of course there's just the general issue of having arbitrary code run in callbacks called from the dynamic linker with things in inconsistent state. Without a formal spec for what ifunc resolvers are actually allowed to do, we can easily fall into a trap of "having to" support whatever happened to work on one particular version of the implementation. Rich