__cxa_atexit()defined in Italium C ++ ABI. The document explains the motivation for this function :
The C ++ standard requires that destructors be called for global objects when a program exits in the opposite order of construction. Most implementations did this by calling the C library routine atexitto register destructors. This is problematic because the 1999 C standard only requires an implementation to support 32 registered functions, although most implementations support many others. More importantly, it generally does not have the ability in most implementations to remove [Dynamic shared objects] from the executable image of the program, calling it dlclosebefore the program terminates.
API, , , atexit - - DSO (, dlclose).
:
__cxa_atexit() 32 .__cxa_atexit() , .
-fuse-cxa-atexit, , libc (, glibc, musl). , gcc, , ( , , libc ).
, __cxa_atexit : , / (__dso_handle).
... __cxa_atexit, atexit DSO.
MSVC, -, atexit()- . dlclose MSVC dlclose().