I have an executable in linux - exe
This executable has some functions in it, that are used throughout the code:
sendMsg
debugPrint
I then want to dynamically load a .so
that provides extra functionality to my executable.
In this shared library I include the headers for sendMsg
and debugPrint
.
I load this shared library with dlopen()
and create an API with dlsym()
.
However, at dlopen()
I use RTLD_NOW
to resolve all symbols at load time.
It fails stating that it cannot find sendMsg
symbol.
This symbol must be in the executable as the sendMsg.c
is compiled in there.
However, my executable is stripped by the make
process. As such, it would make sense that dlopen
cannot find the symbol.
How can i solve this situation?
- I could build the shared functions into a static library and link that static library into both
exe
and the.so
. This would increase code size :( - I could remove the stripping of the
exe
so the symbols can be found - Do some compile time linking magic that I don't know about so the
.so
knows where the symbols are inexe