This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: p2736.C Is dtor order guaranteed?
- To: drepper at cygnus dot com
- Subject: Re: p2736.C Is dtor order guaranteed?
- From: hjl at lucon dot org (H.J. Lu)
- Date: Thu, 23 Jul 1998 16:49:05 -0700 (PDT)
- Cc: martin at mira dot isdn dot cs dot tu-berlin dot de, jason at cygnus dot com, egcs at cygnus dot com
> > Ulrich, can we expend the dynamic linker in glibc to let the shared
> > library know if it is loaded via dlopen? If we can do that, the change
> > to egcs will be simple:
> >
> > static func_ptr __CTOR_END__[];
> > static func_ptr __DTOR_END__[];
> > static void
> > __do_global_ctors_aux ()
> > {
> > func_ptr *p;
> > if (dlopened)
> > for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
> > (*p) ();
> > else
> > {
> > func_ptr *dp = __CTOR_END__ - 1;
>
> I assume you means __DTOR_END__ ^^^ here.
Oooops. Yes.
>
> > for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--, dp--)
> > {
> > (*p) ();
> > atexit (dp);
> > }
> > *(dp + 1) = NULL;
> > }
> > }
>
> I think the code should look like this:
>
Sorry about the subject. p2736.C works fine on Linux. I fixed it by
1997-11-10 07:40 H.J. Lu <hjl@gnu.ai.mit.edu>
* stdlib/exit.c (exit): Handle recursive calls to exit ().
in both libc 5 and glibc 2. That is why you didn't see failure on
Linux. We are talking g++.other/init5.C here. That is a little
bit different. I think my patches for egcs and glibc may fix it.
H.J.