p2736.C Is dtor order guaranteed?
Mike Stump
mrs@wrs.com
Fri Jul 24 13:31:00 GMT 1998
> To: hjl@lucon.org (H.J. Lu)
> Cc: martin@mira.isdn.cs.tu-berlin.de (Martin von Loewis), jason@cygnus.com,
> egcs@cygnus.com
> From: Ulrich Drepper <drepper@cygnus.com>
> Date: 22 Jul 1998 16:03:26 -0700
> hjl@lucon.org (H.J. Lu) writes:
> This restriction always exists if the function to be started is in the
> dynamically loaded object.
I feel this restriction should go. The new sematics should be run at
exit time, or at unload time, which ever comes first.
> I think the code should look like this:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> static func_ptr __CTOR_END__[];
> static func_ptr __DTOR_END__[];
> static int last_initialized;
> static void
> __do_global_ctors_aux ()
> {
> func_ptr *p;
> for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
> {
> (*p) ();
> ++last_initialized;
> }
> }
> static void
> __do_global_dtors_aux ()
> {
> func_ptr *p = __DTOR_END__ - last_initialized;
> while (last_initialized > 0)
> {
> (*p) ();
> --last_initialized;
> }
> }
This code features a fixed list, no fixed list can work, therefore
this isn't a solution to the problem. See my other posts as to why we
shouldn't implement non-solutions.
More information about the Gcc
mailing list