Only in trivial cases. The problem is when another part of the program holds a function pointer into the library which has been unloaded. This can happen in particular when you combine libraries and threads:
libvirt has long been linked with -Wl,-z -Wl,nodelete to avoid this:
rwmj|1 year ago
libvirt has long been linked with -Wl,-z -Wl,nodelete to avoid this:
https://gitlab.com/libvirt/libvirt/-/commit/8e44e5593eb9b89f...
Another case in libnbd which really demonstrates how hard this is:
https://gitlab.com/nbdkit/libnbd/-/commit/368e3d0d5a8871aad5...
alexey-salmin|1 year ago
How is this different from holding a pointer to an object being deleted?