Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Valgrind and LD_PRELOAD - object cannot be preloaded

Tags:

linux

valgrind

ld

I am attempting to run my program, which requires a library to be in the LD_PRELOAD environment variable, with valgrind. When I do this I get the following error:

ERROR: ld.so: object '/path/to/lib/libLIBRARY.so' from LD_PRELOAD cannot
be preloaded: ignored.

However, if I am to run the program WITHOUT valgrind, it happily uses the LD_PRELOADed library.

Why is this the case? And is there a way to fix it?

(P.S. The system is 64-bit scientific linux 5, I believe)

like image 851
V.S. Avatar asked Nov 14 '22 18:11

V.S.


1 Answers

This can happen if valgrind is 64-bit, and both the shared library and the application are 32-bit. valgrind itself can't load the library, but it should load for the application itself.

Edit: Oh, and ... you really shouldn't be using LD_PRELOAD for required libraries for your own programs, only for debugging or otherwise overriding libraries. Instead, embed an rpath/runpath in the executable.

like image 86
o11c Avatar answered Nov 17 '22 07:11

o11c