Virtualization ELF Loader

This loader is source and binary compatible with the GNU ELF loader which ships with the glibc library used in most Linux distributions. It should work out of the box on most x86 and x86-64 systems around.

Download it. There is no stable version per se but the in-development version is pretty stable and can be found in a mercurial repository at http://cutebugs.net/code/vdl. Try to run this:

$ hg clone http://cutebugs.net/code/vdl

Build it. make is your friend:

$ cd vdl
$ make
/home/mathieu/code/elf-loader/extract-system-config.py >vdl-config.h
...
$ ls -l ldso
-rwxrwxr-x 1 mathieu mathieu 2499509 Sep 16 15:44 ldso

Build the tests and run them.

$ make test
PASS run-test0
...
list=PASS

Run a program:

$ cp /bin/ls /tmp
$ cp ./ldso /tmp/
$ cp ./libvdl.so /tmp/
$ ./elfedit /tmp/ls /tmp/ldso
$ readelf -l /tmp/ls|grep interpreter
      [Requesting program interpreter: /tmp/ldso]
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/tmp
$ /tmp/ls

So, I can run ls ? What is so special about this ?

Well, now the programs that are run by this loader benefit from a couple of new features. First, dlmopen(LM_ID_NEWLM) will not be limited to only 16 namespaces. Second, there is new API you can use to control how objects are loaded and mapped in memory:


enum VdlEvent {
  VDL_EVENT_MAPPED,
  VDL_EVENT_UNMAPPED,
  VDL_EVENT_CONSTRUCTED,
  VDL_EVENT_DESTROYED
};
int dl_lmid_add_callback (Lmid_t lmid, 
                          void (*cb) (void *handle, int event, void *context),
                          void *cb_context);
int dl_lmid_add_lib_remap (Lmid_t lmid, const char *src, const char *dst);
int dl_lmid_add_symbol_remap (Lmid_t lmid,
                              const char *src_name, 
                              const char *src_ver_name, 
                              const char *src_ver_filename, 
                              const char *dst_name,
                              const char *dst_ver_name,
                              const char *dst_ver_filename);