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: "H.J. Lu" <hjl at lucon dot org>
- Subject: Re: p2736.C Is dtor order guaranteed?
- From: Bill Currie <bcurrie at mailhost dot tssc dot co dot nz>
- Date: Thu, 23 Jul 1998 18:08:14 +1200
- CC: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>, jason at cygnus dot com, egcs at cygnus dot com, Ulrich Drepper <drepper at cygnus dot com>
- Organization: Telecommunication Systems Support Centre
- References: <m0yz7Uk-00038iC@ocean.lucon.org>
H.J. Lu wrote:
>
> 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--)
Shouldn't the last two lines be __DTOR_END__ instead of __CTOR_END__?
Also, how are the constructors supposed to be called when the shared lib
is not dlopened, or am I missing something?
Bill
--
Leave others their otherness