Unload LD_PRELOAD without restart process

Viewed 171

I using LD_PRELOAD to hook function like LD_PRELOAD=my_lib.so ./my_exec

How can I unload my_lib.so when the hook function called without restart the process?

1 Answers

You can't unload a preloaded libraray.

However what you could do is implement a my_lib_shim.so as wrapper-shim that later on loads the library proper using dlopen and populate the hooks with dlsym. Unloading then was possible with dlclose.

Related