I have to call functions in the main executable from a shared library loaded with LD_PRELOAD.
The executable exports all symbols and contains debug information. Unfortunately I don’t have access to it’s source code.
Currently I’m getting undefined symbol errors when trying to load that shared library.
Is there a way to do this?
PS:
Target platform is FreeBSD/x86.
Can you create a function pointer by doing a typedef and use ‘dlsym()’ to get the address
of the symbol. You can then invoke the function through the function pointer like a normal
function call. Note: You do not need dlopen() since the main executable with symbols exported
is loaded into process address space.
Prototype:
Assume the exported function is:
Your function pointer:
In you code: