Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 27 Aug 2014 12:43:09 -0400
From: Rich Felker <>
Subject: Re: static build and dlopen

On Wed, Aug 27, 2014 at 04:14:07PM +0200, wrote:
> So I ask, does the dlopen() stub really makes sense (the linker is
> intelligent enought to remove unused code on static builds...)? Is
> there any alternative I can do? Is there a flag to allow to use the
> real dlopen() function on static builds, or could it be possible to
> add it? If not, could I be able to use an external dlopen library (and
> could I be able to integrate it easily)?

As nsz explained, it's not that simple. At some point we want to have
a solution for usage cases like what you want, but it's actually quite
difficult to make it work correctly, and rather than using static
linking directly, it might actually be preferable, for supporting your
usage case, to have a tool which merges the main program, dynamic
linker/libc, and any .so's you want to include statically into one big
file. But this is not entirely trivial either.

As for a possible workaround, you can link your program dynamically
(possibly including most of the libraries that your modules _won't_
need to reference as static-linked in the main program binary) and
include a wrapper script, or wrapper static-linked-binary, to exec
your program explicitly via the dynamic linker, as in:

    /path/to/ -- /path/to/your/node "$@"

or similar. This avoids the need to have musl "installed" on the
target system; everything can be in a self-contained directory. I know
some users are already doing something like this for deployments;
maybe at some point we'll think about making some official tools to
make it easier.


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.