My project depends of a third-party library that exports more symbols that it should. Some of those symbols are being, not intentionally, overwritten by other libraries and the main program.
How can I change the visibility of functions and variables of a compiled shared object?
If you can load the problematic library dynamically via dlopen
you may use the RTLD_DEEPBIND
flag to force it to prefer local symbols to the ones in main executable or other shlibs.
If you don't want to manage dlopen
and dlsym
calls manually, you can create a simple wrapper file which would contain trampolines for necessary functions. Each trampoline would internally dlopen
the library if it hasn't been loaded before and forward the call to dlsym
-ed symbol with same name. Such wrapper file can be generated automatically via Implib.so tool.