Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Mon, 3 Jan 2022 08:05:27 +0100
From: Markus Wichmann <>
Subject: Re: building statically linked DSOs with musl

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.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.