From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/14612 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: Thu, 5 Sep 2019 18:58:22 +0200 Message-ID: <20190905165822.GA22009@port70.net> References: <20190902190359.GA6472@voyager> <20190902201009.GV22009@port70.net> <20190905165008.GA9317@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="63981"; 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-14628-gllmg-musl=m.gmane.org@lists.openwall.com Thu Sep 05 18:58:40 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 1i5v5h-000GPa-3w for gllmg-musl@m.gmane.org; Thu, 05 Sep 2019 18:58:37 +0200 Original-Received: (qmail 1843 invoked by uid 550); 5 Sep 2019 16:58:34 -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 1825 invoked from network); 5 Sep 2019 16:58:34 -0000 Mail-Followup-To: musl@lists.openwall.com Content-Disposition: inline In-Reply-To: <20190905165008.GA9317@voyager> Xref: news.gmane.org gmane.linux.lib.musl.general:14612 Archived-At: * Markus Wichmann [2019-09-05 18:50:08 +0200]: > On Mon, Sep 02, 2019 at 10:10:10PM +0200, Szabolcs Nagy wrote: > > * 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) > > > > Yes, namespacing, I thought so. But this style is not used consistently. > For example, open() does not go that route, even though the name is not > reserved in ISO 9899. can you show an example use of open in musl code where it is called form an api implementation that is defined by iso c? > > The other issue is, if two versions of a symbol exist, which one is > referenced internally. It seems musl mostly tries to use the internal > (strong) symbol, but not always. mmap() has the same mechanism in use, > but the dynamic linker references the weak version. since it is for namespacing, which one is used is determined by the namespace rules. for the dynamic linker it does not matter which one is used, unless that code can get static linked into an executable (dlstart.c or in the future if dlopen is supported with static linking), then the namespace clean variant (__mmap) must be used. > > > 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 > > > > That thread talks about pretty much every use of weak aliases except the > type at issue here. > > Ciao, > Markus