diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 5c201dd2558..2f486f7769d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +1999-12-16 Mark Mitchell + + * crtstuff.c (__dso_handle): Declare. + (__cxa_finalize): Likewise. + (do_global_dtors_aux): Call __cxa_finalize if __dso_handle is + non-NULL. + + * invoke.texi: Document -fuse-cxa-atexit. + + * tree.h (ptr_type_node): Document. + (const_ptr_type_node): Likewise. + Fri Dec 17 01:32:38 MET 1999 Jan Hubicka * regmove.c (optimize_reg_copy_1): Ignore LOOP notes. diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c index a17433a0c43..53dae7cddc2 100644 --- a/gcc/crtstuff.c +++ b/gcc/crtstuff.c @@ -129,6 +129,19 @@ typedef void (*func_ptr) (void); #ifdef OBJECT_FORMAT_ELF +/* Declare the __dso_handle variable. It should have a unique value + in every shared-object; in a main program its value is zero. */ + +#ifdef CRTSTUFFS_O +void *__dso_handle = &__dso_handle; +#else +void *__dso_handle = 0; +#endif + +/* The __cxa_finalize function may not be available so we use only a + weak declaration. */ +extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK; + /* Run all the global destructors on exit from the program. */ /* Some systems place the number of pointers in the first word of the @@ -159,6 +172,9 @@ __do_global_dtors_aux (void) if (completed) return; + if (__dso_handle && __cxa_finalize) + __cxa_finalize (__dso_handle); + while (*p) { p++; diff --git a/gcc/invoke.texi b/gcc/invoke.texi index 6f5185acc26..3fbcba6ab85 100644 --- a/gcc/invoke.texi +++ b/gcc/invoke.texi @@ -109,7 +109,7 @@ in the following sections. -fhonor-std -fhuge-objects -fno-implicit-templates -finit-priority -fno-implement-inlines -fname-mangling-version-@var{n} -fno-default-inline -foperator-names -fno-optional-diags -fpermissive -frepo -fstrict-prototype --fsquangle -ftemplate-depth-@var{n} -fvtable-thunks +-fsquangle -ftemplate-depth-@var{n} -fuse-cxa-atexit -fvtable-thunks -nostdinc++ -Wctor-dtor-privacy -Wno-deprecated -Weffc++ -Wno-non-template-friend -Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual @@ -1217,6 +1217,13 @@ A limit on the template instantiation depth is needed to detect endless recursions during template class instantiation. ANSI/ISO C++ conforming programs must not rely on a maximum depth greater than 17. +@item -fuse-cxa-atexit +Register destructors for objects with static storage duration with the +@code{__cxa_atexit} function rather than the @code{atexit} function. +This option is required for fully standards-compliant handling of static +destructors, but will only work if your C library supports +@code{__cxa_atexit}. + @item -fvtable-thunks Use @samp{thunks} to implement the virtual function dispatch table (@samp{vtable}). The traditional (cfront-style) approach to diff --git a/gcc/tree.h b/gcc/tree.h index e802e0ccc04..2703e80b77e 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1542,7 +1542,9 @@ extern tree global_trees[TI_MAX]; #define complex_long_double_type_node global_trees[TI_COMPLEX_LONG_DOUBLE_TYPE] #define void_type_node global_trees[TI_VOID_TYPE] +/* The C type `void *'. */ #define ptr_type_node global_trees[TI_PTR_TYPE] +/* The C type `const void *'. */ #define const_ptr_type_node global_trees[TI_CONST_PTR_TYPE] #define ptrdiff_type_node global_trees[TI_PTRDIFF_TYPE] #define va_list_type_node global_trees[TI_VA_LIST_TYPE]