|
Message-ID: <CAKfGGh16bu6Lhc+EF0d1EiNzhs4V0LxShA3iiw-z50NwbfNQPw@mail.gmail.com> Date: Wed, 27 Aug 2014 16:14:07 +0200 From: "piranna@...il.com" <piranna@...il.com> To: musl@...ts.openwall.com Subject: static build and dlopen I have read that when an executable is compiled fully statically linked with musl, a stub dlopen() is used instead of the real function (http://www.openwall.com/lists/musl/2012/12/09/19), and seems it's done in purpose since normally if you compile an executable as statically linked is because you don't want to load dynamica libraries (http://openwall.com/lists/musl/2012/12/08/4), but I've achieved an use case where I need to do both things. I'm working with others as a hobby on NodeOS (http://node-os.com/), an operating system where Node.js is running on top of a naked Linux kernel. To be able to use Node.js from the begging (as the '/init' executable) it needs to be compiled as a fully statically linked executable, and except for the OpenSSL support, so far so good thanks to musl I was able to do it and worked as a charm :-) Problem came when trying to use a Node.js compiled module ('.node' files) so /init could be able to capture zombie processes (https://github.com/piranna/node-century), since it was throwing an error: module.js:355 Module._extensions[extension](this, filename); ^ Error: Module did not self-register. at Error (native) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Module.require (module.js:365:17) at require (module.js:384:17) at Object.<anonymous> (/tmp/ROOT/lib/node_modules/century/demo.js:3:15) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) Since I had installed in my machine the same version of Node.js that I compiled statically with musl (an Ubuntu package one, compiled dynamically with glibc) and it worked, digging down I get to the point that the problem was on the Node.js module loader (https://github.com/joyent/node/blob/master/lib/module.js#L355), and looking for the error message (https://github.com/joyent/node/blob/master/src/node.cc#L2092), I found it was the Node.js DLOpen() function (https://github.com/joyent/node/blob/master/src/node.cc#L2056), that 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 :-( 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)? 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 -- "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.