mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Sebastien Bourdeauducq <sb@m-labs.hk>
To: musl@lists.openwall.com
Subject: Re: [musl] building statically linked DSOs with musl
Date: Mon, 3 Jan 2022 09:37:00 +0800	[thread overview]
Message-ID: <98176a37-92c6-0da5-c14a-f61b4f8b13ec@m-labs.hk> (raw)
In-Reply-To: <YdBPdmFLDFeMB/Ik@wirbelwind.zhasha.com>

On 1/1/22 20:56, Joakim Sindholt wrote:
> Musl will set up its own internal global libc structure
> with a bunch of values during the initial dynamic loading phase; among
> the members is libc.auxv, which is what __vdsosym will look through when
> trying to find the VDSO. Since you never ran musl's dynamic linker (and
> even if your host binary was musl-based, not the one that would have
> initialized the libc.auxv baked in to your statically linked DSO) it
> won't have set up this and a whole host of other things.

Thanks for the hint.

libc.auxv seems to be set up by __dls2b, which itself is called by 
__dls2 via find_sym(&ldso, "__dls2b", 0).
How does this code work when a program is statically linked against musl?

On 1/3/22 05:41, Markus Wichmann wrote:
 > There can be different heaps, but not different brk heaps. Basically,
 > brk() manages a global variable generated by the kernel. You can work
 > around that problem by installing a seccomp filter that makes brk()
 > always fail, forcing the allocators to fall back to mmap().

mimalloc exclusively uses mmap() already, so that will be OK and will 
not require a workaround. It shouldn't matter if the other allocator 
uses brk().

 > The thread pointer does not match up,

Seems it does (okay, probably by accident):
https://git.musl-libc.org/cgit/musl/tree/arch/x86_64/pthread_arch.h?id=cfdfd5ea3ce14c6abf7fb22a531f3d99518b5a1b#n4
https://github.com/bminor/glibc/blob/b92a49359f33a461db080a33940d73f47c756126/sysdeps/x86/nptl/thread_pointer.h#L30

 > and so no functions accessing the thread pointers will work. That
 > includes functions that read the current thread pointer, so you cannot
 > know in advance which those are. All the implementation-defined
 > structures mismatch, so none of the locking functions work, and neither
 > do the semaphore functions.

AFAIK I would not need to share locks or semaphores across the plugin. I 
need to see if the rest of this thread business has other consequences.

Sébastien

  parent reply	other threads:[~2022-01-03  1:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-01  9:32 Sebastien Bourdeauducq
2022-01-01 12:56 ` Joakim Sindholt
2022-01-01 13:58   ` Alex Xu (Hello71)
2022-01-01 14:31     ` Sebastien Bourdeauducq
2022-01-02 21:41       ` Markus Wichmann
2022-01-03  1:37   ` Sebastien Bourdeauducq [this message]
2022-01-03  7:05     ` Markus Wichmann

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=98176a37-92c6-0da5-c14a-f61b4f8b13ec@m-labs.hk \
    --to=sb@m-labs.hk \
    --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).