OSDN Git Service

(find_reloads_address_1, case POST_INC): Don't use
[pf3gnuchains/gcc-fork.git] / gcc / crtstuff.c
index f41035c..2c68243 100644 (file)
@@ -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.  */
@@ -189,6 +197,7 @@ __do_global_ctors_aux ()    /* prologue goes in .init section */
 
 #else /* defined(INIT_SECTION_ASM_OP) */
 
+#ifdef HAS_INIT_SECTION
 /* This case is used by the Irix 6 port, which supports named sections but
    not an SVR4-style .fini section.  __do_global_dtors can be non-static
    in this case because the -fini switch to ld binds strongly.  */
@@ -200,6 +209,7 @@ __do_global_dtors ()
   for (p = __DTOR_LIST__ + 1; *p; p++)
     (*p) ();
 }
+#endif
 
 #endif /* defined(INIT_SECTION_ASM_OP) */
 
@@ -314,6 +324,7 @@ __do_global_ctors_aux ()    /* prologue goes in .text section */
 
 #else /* defined(INIT_SECTION_ASM_OP) */
 
+#ifdef HAS_INIT_SECTION
 /* This case is used by the Irix 6 port, which supports named sections but
    not an SVR4-style .init section.  __do_global_ctors can be non-static
    in this case because the -init switch to ld binds strongly.  */
@@ -325,6 +336,7 @@ __do_global_ctors ()
   for (p = __CTOR_END__ - 1; *p != (func_ptr) -1; p--)
     (*p) ();
 }
+#endif
 
 #endif /* defined(INIT_SECTION_ASM_OP) */