Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140827152735.GB22308@port70.net>
Date: Wed, 27 Aug 2014 17:27:36 +0200
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: static build and dlopen

* piranna@...il.com <piranna@...il.com> [2014-08-27 16:14:07 +0200]:
...
> thought libuv is calling to the system dlopen() function, it's said,
> the musl stub for static builds, making it impossible to load the
> Node.js compiled modules :-(

dlopen does not work from a statically linked binary

(it can be made to work but it's more complicated than it seems:
the entire libc should be linked into the application so all
interfaces are present a loaded module may require which partly
defeats the purpose of static linking and there are toolchain
issues with this so it is not implemented)

> 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)?
> 

if the loaded modules depend on the libc api (or transitively any
external dependency) then naive dlopen cannot work with static
linking and there is no way around this

(btw the same applies to all module systems that can load libraries
written in c, eg. if you tried a statically linked python you would
have the same issue: it works if all dependencies are linked in, it
fails if you load libraries at runtime)

> Oh, and if you are thinking about it: yes, this is a farily similar
> use case as when compiling OS kernels (at least hybrid ones, like
> Linux) where you need to compile them statically so it can boot and
> also has support to load compiled modules on runtime, since in this
> case, Node.js is in fact the "kernel" and Linux is just a somewhat HAL
> layer :-P

neither the kernel nor the loaded kernel modules depend on the libc

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.