Using LD_PRELOAD mixed 64bit/32bit environment in Linux
<p>I would like to set LD_PRELOAD to point to a shared library where I might run either a 64bit or 32bit application.  It is obvious that the shared library and the executable have to match in bit-ness.  </p>

<pre><code>$ LD_PRELOAD=/lib64/lib_init.so ./hello32
ERROR: ld.so: object '/lib64/lib_init.so' from LD_PRELOAD cannot be preloaded (wrong ELF class: ELFCLASS64): ignored
</code></pre>

<p>where hello32 is a 32 bit application. There are some pages out in the world that say that I should be able to do:</p>

<pre><code>$ LD_PRELOAD='/$LIB/lib_init.so' ./hello32
ERROR: ld.so: object '/$LIB/lib_init.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored
</code></pre>

<p>Where $LIB will automatically switch between lib and lib64 depending on whether the application is 32 or 64bit. But obviously this doesn't work.</p>

<p>Is there some trick to make this work? LD_PRELOAD_32, LD_PRELOAD_64?
Thanks!</p>