ERROR: ld.so: object 'getpid.so' from LD_PRELOAD cannot be preloaded: ignored
22,163
Looks like the loader is unable to find getpid.so
as you've not mentioned the path to the library.
Try:
LD_PRELOAD=/full/path/to/getpid.so ./testpid
Author by
MetallicPriest
Updated on July 09, 2022Comments
-
MetallicPriest almost 2 years
When I try to use LD_PRELOAD as following,
LD_PRELOAD=getpid.so ./testpid
I get the following error...
ERROR: ld.so: object 'getpid.so' from LD_PRELOAD cannot be preloaded: ignored.
I compile getpid.so by using
gcc -Wall -fPIC -shared -o getpid.so getpid.c
and it contains the following code...
// getpid.c #include <sys/syscall.h> #include <sys/types.h> #include <unistd.h> #include <stdio.h> pid_t getpid(void) { printf("Hello, world!\n"); return syscall(SYS_getpid); }
tespid.c
constains code which uses getpid as shown below and which is compiled by doinggcc testpid -o testpid.c
What can be the problem here? Why is LD_PRELOAD not working?
// testpid.c #include <sys/syscall.h> #include <sys/types.h> #include <unistd.h> #include <stdio.h> int main() { printf( "pid = %d!\n", getpid() ); return 0; }
-
MetallicPriest over 12 yearsVery true! Instead of LD_PRELOAD=getpid.so ./testpid, it should be LD_PRELOAD=./getpid.so ./testpid. Now its working.
-
Alexander Malakhov over 11 yearsin my case I had to also set
LD_LIBRARY_PATH
and get 64-bit version of the library.