aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMike Stump <mrs@gcc.gnu.org>1996-10-24 01:23:43 +0000
committerMike Stump <mrs@gcc.gnu.org>1996-10-24 01:23:43 +0000
commitb40b9d932c075e9eecc655230882360e989c7af8 (patch)
tree765fea06aca0dd565a7fa30ba548abb4380d5198 /gcc
parent3e943b598427255b7501e41339f09ca52e3eae2c (diff)
downloadgcc-b40b9d932c075e9eecc655230882360e989c7af8.zip
gcc-b40b9d932c075e9eecc655230882360e989c7af8.tar.gz
gcc-b40b9d932c075e9eecc655230882360e989c7af8.tar.bz2
crtstuff.c (__do_global_dtors_aux): Allow finalization code to be run more than once.
* crtstuff.c (__do_global_dtors_aux): Allow finalization code to be run more than once. * libgcc2.c (__do_global_dtors): Ditto. From-SVN: r13023
Diffstat (limited to 'gcc')
-rw-r--r--gcc/crtstuff.c16
-rw-r--r--gcc/libgcc2.c9
2 files changed, 18 insertions, 7 deletions
diff --git a/gcc/crtstuff.c b/gcc/crtstuff.c
index f41035c..6cbb82b 100644
--- a/gcc/crtstuff.c
+++ b/gcc/crtstuff.c
@@ -111,15 +111,23 @@ typedef void (*func_ptr) (void);
functions in each root executable and one in each shared library, but
although they all have the same code, each one is unique in that it
refers to one particular associated `__DTOR_LIST__' which belongs to the
- same particular root executable or shared library file. */
+ same particular root executable or shared library file.
+
+ On some systems, this routine is run more than once from the .fini,
+ when exit is called recursively, so we arrange to remember where in
+ the list we left off processing, and we resume at that point,
+ should we be re-invoked. */
static func_ptr __DTOR_LIST__[];
static void
__do_global_dtors_aux ()
{
- func_ptr *p;
- for (p = __DTOR_LIST__ + 1; *p; p++)
- (*p) ();
+ static func_ptr *p = __DTOR_LIST__ + 1;
+ while (*p)
+ {
+ p++;
+ (*(p-1)) ();
+ }
}
/* Stick a call to __do_global_dtors_aux into the .fini section. */
diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c
index 9ccb1a5..69cb7e4 100644
--- a/gcc/libgcc2.c
+++ b/gcc/libgcc2.c
@@ -2829,9 +2829,12 @@ __do_global_dtors ()
#ifdef DO_GLOBAL_DTORS_BODY
DO_GLOBAL_DTORS_BODY;
#else
- func_ptr *p;
- for (p = __DTOR_LIST__ + 1; *p; )
- (*p++) ();
+ static func_ptr *p = __DTOR_LIST__ + 1;
+ while (*p)
+ {
+ p++;
+ (*(p-1)) ();
+ }
#endif
}
#endif