From fc69382254fcf45ced69a604adea5b6123c3c1c8 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Fri, 17 Dec 1999 07:39:13 +0000 Subject: crtstuff.c (__dso_handle): Declare. * 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. From-SVN: r30989 --- gcc/crtstuff.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/crtstuff.c') diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c index a17433a..53dae7c 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++; -- cgit v1.1