This is the mail archive of the gcc@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: p2736.C Is dtor order guaranteed?


> > 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.


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