This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Use of atexit for destructors on Solaris 7.
- To: mrs at windriver dot com
- Subject: Re: Use of atexit for destructors on Solaris 7.
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Wed, 22 Mar 2000 01:30:12 +0100
- CC: ghazi at caip dot rutgers dot edu, gcc-bugs at gcc dot gnu dot org, ross dot s at ihug dot co dot nz
- References: <200003220016.QAA27179@kankakee.wrs.com>
> And did they spec a two argument form of atexit for modules, so that
> you can remove a whole slew of them in one call?
Yes, that's __cxa_atexit:
# int __cxa_atexit ( void (*f)(void *), void *p, dso_handle d );
# This registration, e.g. __cxa_atexit(f,p,d), is intended to cause
# the call f(p) when DSO d is unloaded, before all such termination
# calls registered before this one. It returns zero if registration is
# successful, nonzero on failure.
Since destructors only take a single argument in this ABI, you can
pass the destructor pointer here.
# When linking any DSO containing a call to __cxa_atexit, the linker
# should define a hidden symbol __dso_handle, with a value which is an
# address in one of the object's segments. (It doesn't matter what
# address, as long as they are different in different DSOs.) It should
# also include a call to the following function in the FINI list (to
# be executed first):
# void __cxa_finalize ( dso_handle d );
It's all at http://reality.sgi.com/dehnert_engr/cxx/cxx-summary.html
(actually, this one is in the closed issue D-3).
Of course, implementing hidden symbols now is the tricky part...
Regards,
Martin