I have a quite large C application consisting of several shared libraries. One of the core libraries has a function
void common_function(const char * arg) { ... }
Which is called by all the other libraries. During testing I would like to use a different test implementation of the common_function.
My plan has been to create a test library containing the alternate implementation of common_function; is it at all possible to replace the default common_function runtime using dlopen() / dlsym() trickery, or alternatively would this link line:
gcc -o test.c -ltest -lcommon
ensure that the common_function implementation in libtest.so was used also in the libcommon.so - altough the latter has it's own implementation of common_function.
Read Drepper's paper: How To Write Shared Libraries and wikipage on dynamic linker.
You probably want to play the LD_PRELOAD trick (assuming all your libraries are shared, not static).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With