From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Subject: Re: [musl] building statically linked DSOs with musl
Date: Mon, 3 Jan 2022 08:05:27 +0100 [thread overview]
Message-ID: <20220103070527.GB2629@voyager> (raw)
In-Reply-To: <98176a37-92c6-0da5-c14a-f61b4f8b13ec@m-labs.hk>
On Mon, Jan 03, 2022 at 09:37:00AM +0800, Sebastien Bourdeauducq wrote:
> 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?
>
It doesn't. This code only runs in the dynamic linking case. In the
static linking one, the program is linked against crt0.c, which contains
_start and _start_c, which will call __libc_start_main, which itself
will call __init_libc. Note that you cannot call __init_libc, because
for that you need the original stack pointer, which you don't have.
Ciao,
Markus
prev parent reply other threads:[~2022-01-03 7:05 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
2022-01-03 7:05 ` Markus Wichmann [this message]
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=20220103070527.GB2629@voyager \
--to=nullplan@gmx.net \
--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).