From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/13590 Path: news.gmane.org!.POSTED!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: pthread_key_create bug? Date: Wed, 9 Jan 2019 12:45:37 +0100 Message-ID: <20190109114536.GI21289@port70.net> References: <84B22C11-AA93-47FD-8352-A4F18B19F689@gmail.com> <5c1d9cf6-1b53-7082-5dee-8673ed4c55e9@adelielinux.org> <20190107021128.GW23599@brightrain.aerifal.cx> <20190107171327.GD29911@voyager> <20190108000018.GZ23599@brightrain.aerifal.cx> <20190108221006.GF29911@voyager> <20190109002953.GA23599@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1547034226 8958 195.159.176.226 (9 Jan 2019 11:43:46 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 9 Jan 2019 11:43:46 +0000 (UTC) User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-13606-gllmg-musl=m.gmane.org@lists.openwall.com Wed Jan 09 12:43:42 2019 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1ghCGr-0002Cb-Oj for gllmg-musl@m.gmane.org; Wed, 09 Jan 2019 12:43:41 +0100 Original-Received: (qmail 9294 invoked by uid 550); 9 Jan 2019 11:45:50 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 9274 invoked from network); 9 Jan 2019 11:45:50 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20190109002953.GA23599@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:13590 Archived-At: * Rich Felker [2019-01-08 19:29:53 -0500]: > On Tue, Jan 08, 2019 at 11:10:06PM +0100, Markus Wichmann wrote: > > On Mon, Jan 07, 2019 at 07:00:18PM -0500, Rich Felker wrote: > > > I think you're right, though we don't generally use weak references in > > > musl on the basis (perhaps somewhat dubious) that they're an > > > additional toolchain feature that might cause problems reusing the > > > code in non-ELF contexts (this may affect midipix; I'm not sure). > > > That's why weak aliases to dummy functions are used for this purpose > > > everywhere else. > > > > > > > I don't quite get you. Weak aliases are just weak references with a > > non-zero default value. Any toolchain being able to handle weak aliases > > should be able to handle weak references, right? > > No, not necessarily, and no they're not equivalent to weak definitions > with a zero value. A weak definition with a zero value would provide a > definition for other translation units to see/use, preventing one > with a non-weak reference from pulling in the real definition. Weak > references are a property of the reference. Weak definitions are a > property of the definition. They are not in any way equivalent. > > In any case, the policy is that we don't use weak references (*). If > there were a strong reason to want them, we could review the reasons > and see if they are still relevant. > > (*) This is only partly true. There are weak references to some > special ELF symbols defined by the linker, because providing a weak > definition would override the linker-provided value. For these, there > will never be definitions provided by source files, so the weak > reference is mostly equivalent to a weak definition by your above > logic. Furthermore, we know they'll always be defined for > position-independent linking (_DYNAMIC has to exist for shared > libraries and PIE) so there is no concern about the issue below > (PC-relative references to an undefined weakly-referenced symbol). note that weak references are not even well supported on elf targets: weak references can be undefined and then the symbol address is 0 at runtime, which should be possible to check with if (weakref == 0).., but this does not work reliably, see e.g. https://groups.google.com/forum/#!topic/generic-abi/eZv8VQskSD0 so the specified weak reference semantics is broken in important use cases: tls, copy reloc, plt address.