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.
$ 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
where hello32 is a 32 bit application. There are some pages out in the world that say that I should be able to do:
$ 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
Where $LIB will automatically switch between lib and lib64 depending on whether the application is 32 or 64bit. But obviously this doesn't work.
Is there some trick to make this work? LD_PRELOAD_32, LD_PRELOAD_64? Thanks!