In *nix .so libraries, is there an entry point that\'s invoked by the system when the library is loaded and unloaded?
On a more practical note: if the .so was writte
No, there is no equivalent to DllMain.
For JNI libraries, e.g. on Android, there may be a special entry JNI_OnLoad which is intended to fill JNI function table.
GCC defines special attribute constructor to allow some code to run on shared library load.
C++ guarantees that the constructors for global and static objects will be performed, no matter if the code that loaded the .so was aware of these classes, or had notion of construction.
Same holds for destructors, but there may be unhappy circumstances when at least some destructors have no chance to run - e.g. when there is a sigfault and exceptions are disabled.