LD_PRELOAD in a multilib environment

Adam Kellas adam.kellas@gmail.com
Thu Mar 3 00:43:00 GMT 2011


I'm porting a piece of software that uses LD_PRELOAD to Linux.
Unfortunately Linux (in particular ld.so) seems to have an
architectural flaw in this area. Setting LD_PRELOAD=foobar.so
essentially says "map foobar.so into every new process within the
scope of this environment variable". But in the modern world where
many systems have both 32- and 64-bit libraries, a single variable
cannot possibly be sufficient; you're almost certainly going to
eventually try to load a 32-bit library into a 64-bit process space or
vice versa, which will fail.

Solaris solved this many years ago by adding alternate variables
LD_PRELOAD_32 and LD_PRELOAD_64; as long as you point LD_PRELOAD_32 to
the 32-bit version of libfoo and LD_PRELOAD_64 to the 64-bit version,
things continue to work. I'm surprised to see that this system, or a
different solution, has not been brought into the Linux world. What am
I missing? How do people solve this in Linux?


More information about the Libc-help mailing list