LD_PRELOAD in a multilib environment

Adam Kellas adam.kellas@gmail.com
Fri Mar 4 02:27:00 GMT 2011

On Wed, Mar 2, 2011 at 7:43 PM, Adam Kellas <adam.kellas@gmail.com> wrote:
> 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?

For the archives, the answer turns out to be what Ulrich Drepper calls
a "dynamic string token", or DST, called $LIB. I.e. if you set

export LD_PRELOAD=.../$LIB/libfoo.so

then the runtime linker will set $LIB to "/lib" when running a 32-bit
binary and to "/lib64" when running a 64-bit program. Works more or
less the same as on Solaris, arguably a bit more elegant. Documented
in http://www.akkadia.org/drepper/dsohowto.pdf.


More information about the Libc-help mailing list