__cxa_finalize and `on_exit'

Mark Mitchell mark at codesourcery.com
Sun Dec 19 20:53:42 UTC 1999


>>>>> "Jason" == Jason Merrill <jason at cygnus.com> writes:

    Jason> How so?  I would think you could just register
    Jason> __cxa_finalize (NULL) (or equivalent) with the C atexit.
    Jason> Then exit runs all the destructors, and the calls in .fini
    Jason> do nothing, because everything has already been
    Jason> deregistered.  The atexit chain is run before .fini stuff,
    Jason> I'm pretty sure.

Perhaps you missed the earlier thread.  The problem is that
__cxa_finalize does not take the exit code, so it cannot call on_exit
functions.  In general, if the system `exit' routine wants to do other
work, calling functions registered by means other than atexit or
__cxa_atexit, and interleaved with calls to those functions, we need
to let `exit' do its thing, rather than trying to push everything into
__cxa_finalize.

There's no need to call __cxa_finalize in the main program; just
specify that functions registered with __cxa_atexit, but not already
called by __cxa_finalize from DSOs, are called, interleaved
appropriately with atexit functions, by `exit'.

--
Mark Mitchell                   mark at codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com




More information about the cxx-abi-dev mailing list