From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14605 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Szabolcs Nagy Newsgroups: gmane.linux.lib.musl.general Subject: Re: About those weak aliases Date: Mon, 2 Sep 2019 22:10:10 +0200 Message-ID: <20190902201009.GV22009@port70.net> References: <20190902190359.GA6472@voyager> Reply-To: musl@lists.openwall.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="222180"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Mutt/1.10.1 (2018-07-13) To: musl@lists.openwall.com Original-X-From: musl-return-14621-gllmg-musl=m.gmane.org@lists.openwall.com Mon Sep 02 22:10:24 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.89) (envelope-from ) id 1i4see-000vgl-Qc for gllmg-musl@m.gmane.org; Mon, 02 Sep 2019 22:10:24 +0200 Original-Received: (qmail 15420 invoked by uid 550); 2 Sep 2019 20:10:22 -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 15402 invoked from network); 2 Sep 2019 20:10:22 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20190902190359.GA6472@voyager> Xref: news.gmane.org gmane.linux.lib.musl.general:14605 Archived-At: * Markus Wichmann [2019-09-02 21:04:48 +0200]: > I'd like to know what those weak aliases are for in the many cases where > they are used to define a public interface. Or, more to the point, by > what criteria they are handed out, and by what logic the internal > symbols are used. > > For instance, pthread_mutex_lock() et al. are weakly defined, but it's a weak alias for __pthread_mutex_lock which can be used to implement iso c apis (where pthread* is not reserved and thus may conflict with user defined symbols) __pthread_mutex_lock is not used internally right now, but e.g. __pthread_mutex_timedlock is. (could be a strong alias, weakness of public api symbols doesn't matter, you can only observe the difference by getting a link error when static linking a conflicting definition, but that is non-standard: when the symbol is reserved for the implementation user code must not use it) so following namespace rules for static linking is one reason for aliases. and musl only uses weak aliases. there are other usage of weak symbols, there was a patch that tried to cathegorize them: https://www.openwall.com/lists/musl/2013/02/15/1 > pthread_cond_wait() is not. Unlike pthread_cond_timedwait(), which is > called from pthread_cond_wait() by the public symbol that might be > interposed. Makes sense, since pthread_cond_wait() does not depend on > mutex internals (pthread_cond_timedwait() does). > > I found no C standard function with a weak definition. But I did find > crypt() being strongly defined, but it calls the internal (strong) > definition of crypt_r(), rather than the weak one. > > So I thought maybe the C standard functions get strong definitions and > all others get weak ones. But open(), close(), etc. are also defined > strongly, while fdopen() gets a weak definition. And those are all in > POSIX. Meanwhile, adjtime() gets a strong definition, as does > getdents(), and those are Linux specialities. > > So yeah,I have so far failed to identify any rhyme or reason to these > definitions. Can anyone help me? > > Ciao, > Markus