On Sun, Aug 5, 2012 at 6:56 AM, Perry Smith <pedz...@gmail.com> wrote: > > Part of my confusion / concern is "why have two methods?" > Does the spec say that dtors much be called at different times?
The use of _GLOBAL_FD in GCC is AIX-specific, and appears to be required to get destructors in shared libraries to run correctly when the entire program exits. The use of atexit instead of __cxa_atexit is not AIX specific, but is an attempt to make shared library destructors work correctly on systems without __cxa_atexit, when there is no chance to run them at dlclose time. I don't know the history here, but it's quite possible that the two ideas were implemented separately, and that nobody has ever really tried to make dlclose run destructors correctly on AIX. Ian