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 22:19:18 +0200
From: "piranna@...il.com" <piranna@...il.com>
To: musl@...ts.openwall.com
Subject: Re: static build and dlopen

>> Yes, I though about this option before, has a dumb statically linked
>> executable to work as PID 1 that just only exec Node.js and wait until
>> it finishes, so I can use a standard dynamically linked one and do
>> whatever I want
>
>  I don't understand why you can't do whatever you want anyway.
>  You can run Node.js as PID 1 even if it is dynamically linked - you
> just need to have the libc (and ld-musl.so) in the filesystem. It
> will work. You can run anything as PID 1 provided all its dependencies
> are there at boot time. Traditional inits are usually dynamically
> linked - which I think is a very bad idea, but that's another subject.
> If Node.js is a special case that cannot be treated that way, then I'm
> interested in hearing why.

I tried to do it that way, but didn't worked. Seems on Linux when you
are using a dynamically linked executable this is not run directly,
but instead it is exec internally /lib/ld-linux.so.2, that's a program
that load and link your executable and it's dynamic libraries and
later exec it, so it takes the PID 1 and when it finish and give
control to your dynamically linked executable (Node.js in this case),
then since PID 1 has exited, the kernel has a kernel panic. The same
happens if using /usr/bin/env as she-bang, since it will get the PID 1
and fail. You can read all that I have learned about this topics on
https://github.com/NodeOS/NodeOS-Docker/pull/12.

By the way, based on this example
(http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#SEC410)
I've done a dumb /init program that just exec the dynamically linked
Node.js with the real /init in Javascript and it worked. Ugly hack,
but at least it does its job :-)


-- 
"Si quieres viajar alrededor del mundo y ser invitado a hablar en un
monton de sitios diferentes, simplemente escribe un sistema operativo
Unix."
– Linus Tordvals, creador del sistema operativo Linux

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.