Example: If the PT_INTERP
of an executable a.elf is /2.2.4-24/rtldi (instead of /lib/ld-linux.so.2), then the
executable runs effectively as if it were invoked via
/2.2.4-24/ld-linux.so.2 --library-path /2.2.4-24:$LD_LIBRARY_PATH /path/of/execve/a.elf args...
and will use /2.2.4-24/libc.so.6 for its glibc6. rtldi uses its own path prefix in PT_INTERP as the prefix for ld-linux.so.2, and as the first directory path in the colon-separated list argument following --library-path. The --library-path argument replaces LD_LIBRARY_PATH for a.elf only, without modifying LD_LIBRARY_PATH for a.elf or for any children that a.elf may invoke. (This is a feature of ld-linux.so.2.) Also, the process name remains "a.elf".
New ELF executables can specify the runtime loader by building with -Wl,--dynamic-linker=/path/to/rtldi. Old executables that specify /lib/ld-linux.so.2 for their PT_INTERP can be modified by using a binary file editor. Find the Offset of the INTERP string by using readelf --program-headers a.elf. The replacement string cannot be longer, and must be terminated by '\0'; thus the limit is 18 bytes.
Strategy for old executables: Choose a naming convention. The examples above use the version string of the glibc6 distribution .rpm file. The final component name of the PT_INTERP does not matter; choosing a one-character name such as ',' [comma: "/path/,"] allows using more characters elsewhere in the path.
Version 0.94 of rtldi sets argv to the complete path that was specified to execve(), unless argv already contains a '/'. ld-linux.so.2 needs this because it does not search $PATH. As a result, rtldi does not work for programs that interpret argv as something else. There is a race in the double interpretation of the path to the executable (once by execve and once by ld-linux.so.2), so don't move, remove or modify the executable while using rtldi.
Version 0.93 of rtldi works better with gdb than previous versions. (gdb) set stop-on-solib-events 1 appears to work, although some versions of gdb give complaints which should be ignored. The next and step commands of gdb-5.3post-0.20021129.18rh do not work; use explicit breakpoints instead. This bug in gdb is fixed in gdb-5.3.90-0.20030710.41rh. Version 0.93 of rtldi manages to preserve a good symlink /proc/pid/exe most of the time.
Note: the full glibc6 environment includes many .so files. The safest is
to include a copy or link to each file in the glibc package that
normally lives in /lib.
For example, rpm -ql
glibc-2.3.2-27.9.7 shows these files: