How do I change the library from which a function is loaded at runtime?
For example, let's say I want to replace the standard printf function with something new, I can write my own version and compile it into a shared library, and then put "LD_PRELOAD = / my / library.so" in the environment before running my executable file.
But let's say that instead I want to change this connection from the program itself. Of course, this should be possible ... right?
EDIT
And no, the following does not work (but if you can tell me how to do this, then that will be enough).
void* mylib = dlopen("/path/to/library.so",RTLD_NOW); printf = dlsym(mylib,"printf");
c linux shared-libraries
tylerl
source share