p2736.C Is dtor order guaranteed?
Bill Currie
bcurrie@mailhost.tssc.co.nz
Thu Jul 23 00:50:00 GMT 1998
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
More information about the Gcc
mailing list