make-static

A tool for creating statically linked executables from dynamically linked ones

Ever had the need to create a statically linked executable from only the dynamically linked executable? I did, and after much futzing around with ld and objcopy, I gave in.

Instead I took cryopid and hacked it up to capture the state of a freshly spawned process into a file. It executes the program, stops it after ld.so has done the work of loading shared libraries, and dumps a copy of the process image into a file. This file is an ELF executable which loads the memory segments back into place, and starts the executable.

The files it generates aren't impressively small, but it appears to work.

It disables NPTL, as TLS segments aren't currently restored, and this also makes the resulting binary portable to non-NPTL kernels.

The code is not pretty, but works for me. YMMV.

dagobah@ucc