Question about LD_PRELOAD and /etc/ld.preload

Alan Modra amodra at
Tue May 11 14:32:13 EST 2004

On Fri, May 07, 2004 at 04:33:32PM -0400, Theodore Y. Ts'o wrote:
> I have an LD_PRELOAD shared library that accellerates programs that do
> readdir/stat scans by intercepting the opendir() and readdir() calls,
> reading all directory entries, sorting them in inode number, and then
> returning the directory entries in sorted order.
> The pathname to this shared library can be placed in /etc/ld.preload, or
> by setting the LD_PRELOAD environment variable.  There's only one
> problem.  On 32/64-bit platforms, you need to have a different preload
> library depending on whether the executable is 32-bit or 64-bit.
> So depending on whether I use LD_PRELOAD=/usr/local/lib/
> or LD_PRELOAD=/usr/local/lib/, either /bin/ls (which is
> a 32-bit executable) or /bin/ps (which is a 64-bit executable) will work
> correctly.
> This seems to be a real misfeature.  Is there a 32/64-bit sensitive
> environment variable I can use?  What about for /etc/ld.preload?

Not that I know of.  Try specifying the preload .so without an absolute
path, and arrange for it to be found in a path specified in
Since you can have a different for the 64-bit, that
should allow the right lib to be preloaded.

Alan Modra
IBM OzLabs - Linux Technology Centre

** Sent via the linuxppc64-dev mail list. See

More information about the Linuxppc64-dev mailing list