This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Use of atexit for destructors on Solaris 7.


> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]