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: martin at mira dot isdn dot cs dot tu-berlin dot de (Martin von Loewis)
- Subject: Re: p2736.C Is dtor order guaranteed?
- From: hjl at lucon dot org (H.J. Lu)
- Date: Wed, 22 Jul 1998 15:36:22 -0700 (PDT)
- Cc: jason at cygnus dot com, egcs at cygnus dot com, drepper at cygnus dot com (Ulrich Drepper)
>
> > As far as I can tell, the only complete solution involves replacing atexit.
>
> Yes, I've seen this restriction. I think that autoconf could determine
> whether the system accepts at least 64 or so atexit calls; in
> addition, we could make a list of systems where atexit is known to be
> broken.
>
> Alternatively, we could make a list of systems where we know that
> atexit has no such restriction.
>
I believe Linux has no such restriction. However, I'd like to revert
back to __DTOR_LIST__ if a shared library is loaded via dlopen.
Otherwise, we will get a core dump after dlclose when the program
exits. We can put a restriction on dlopened objects that they cannot
call atexit explicitly or implicitly in C or C++.
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;
for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--, dp--)
{
(*p) ();
atexit (dp);
}
*(dp + 1) = NULL;
}
}
Can we fill up a specific data section with 1 in dynamic linker? If
we can do that, we can put a static variable in the ".dlopened" section
and dlopen will fill it up with 1.
Thanks.
H.J.