mailing list of musl libc
 help / color / mirror / code / Atom feed
From: "writeonce@midipix.org" <writeonce@midipix.org>
To: musl@lists.openwall.com
Subject: Re: pthread_key_create bug?
Date: Tue, 8 Jan 2019 17:40:41 -0500	[thread overview]
Message-ID: <20190108224041.unjv3ml45vs3ljdw@midipix.org> (raw)
In-Reply-To: <20190108193454.GE29911@voyager>

On 01/08/2019 20:34, Markus Wichmann wrote:
> On Tue, Jan 08, 2019 at 09:43:10AM +0100, u-uy74@aetey.se wrote:
> > On Mon, Jan 07, 2019 at 07:00:18PM -0500, Rich Felker wrote:
> > > >  
> > > > +extern hidden weak void __pthread_key_delete_synccall(void (*f)(void *), void *p);
> > 
> > > 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).
> > 
> > Thanks. That's no doubt, the less the reliance on toolchain features,
> > the easier to use, especially in the ways/areas not known in advance.
> > 
> > Rune
> > 
> 
> Well, what happens on midipix with this patch? Worst case scenario is,
> the toolchain doesn't do weak references, and the reference becomes
> strong. So that would leave you no worse than the current situation. Or
> am I missing the point?

Weak/hidden symbols and references as used in the patch are actually supported. Generally speaking, default visibility means that a register (say, rax) is going to have the address of a function's .got entry (.got entries in PE are specific to midipix and are part of the toolchain's customization), and the call will thus take the form of callq *%rax. With hidden visibility, rax would contain the actual function address, and the call would accordingly become callq %rax. Weak references on midipix provide most of everything that ELF provides. With your patch applied, and linking libc.so with pthread_key_delete.lo (and thus also tss_delete.lo) left out, the resuling image contains the following as expected (callq 0 being the bit of interest):

6bc4d0f3:     48 8d 0d 46 c7 00 00    lea    0xc746(%rip),%rcx        # 6bc59840 <clean_dirty_tsd_callback>
6bc4d0fa:     48 89 44 24 20          mov    %rax,0x20(%rsp)
6bc4d0ff:     c7 44 24 28 0b 00 00    movl   $0xb,0x28(%rsp)
6bc4d106:     00 
6bc4d107:     e8 f4 2e 3b 94          callq  0 <__dll__>

To complete the picture, the one weak/hidden trick that's currently not supported on midipix consists in musl's src/errno/__errno_location.c and src/include/errno.h, where you end up with "call ___errno_location" (because of the hidden attribute) in many translation units, yet a strongly defined ___errno_location in none (for which the workaround is to provide a strong ___errno_location() function).


> 
> Ciao,
> Markus
> 

-- 


  reply	other threads:[~2019-01-08 22:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-06 14:35 Nathaniel Pierce
2019-01-06 14:50 ` A. Wilcox
2019-01-06 16:28   ` Szabolcs Nagy
2019-01-07  2:11   ` Rich Felker
2019-01-07 12:24     ` A. Wilcox
2019-01-07 14:12       ` Rich Felker
2019-01-07 17:13     ` Markus Wichmann
2019-01-08  0:00       ` Rich Felker
2019-01-08  8:43         ` u-uy74
2019-01-08 19:34           ` Markus Wichmann
2019-01-08 22:40             ` writeonce [this message]
2019-01-08 22:10         ` Markus Wichmann
2019-01-08 23:07           ` A. Wilcox
2019-01-09  0:29           ` Rich Felker
2019-01-09 11:45             ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190108224041.unjv3ml45vs3ljdw@midipix.org \
    --to=writeonce@midipix.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).