Marvee Amasi
DIIDevHeads IoT Integration Server
•Created by Marvee Amasi on 7/23/2024 in #middleware-and-os
LD_PRELOAD Not Working with Custom getpid Function
I'm trying to use the LD_PRELOAD to inject my custom function in a program. I've compiled a shared library
getpid.so
having a modified getpid function that prints a message:
I've also compiled a program testpid.c that calls the regular getpid function:
When I run the command:
I get the following error:
I've compiled both files with gcc -Wall -fPIC -shared -o getpid.so getpid.c
and gcc testpid -o testpid.c
Can anyone help me understand why LD_PRELOAD is not working and how to fix the issue?5 replies