OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / collect2.c
index 9240bc8..8870b7c 100644 (file)
@@ -1,7 +1,7 @@
 /* Collect static initialization info into data structures that can be
    traversed by C++ initialization and finalization routines.
    Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011, 2013
    Free Software Foundation, Inc.
    Contributed by Chris Smith (csmith@convex.com).
    Heavily modified by Michael Meissner (meissner@cygnus.com),
@@ -384,8 +384,8 @@ static void scan_prog_file (const char *, scanpass, scanfilter);
 \f
 /* Delete tempfiles and exit function.  */
 
-void
-collect_exit (int status)
+static void
+collect_atexit (void)
 {
   if (c_file != 0 && c_file[0])
     maybe_unlink (c_file);
@@ -413,13 +413,8 @@ collect_exit (int status)
       maybe_unlink (lderrout);
     }
 
-  if (status != 0 && output_file != 0 && output_file[0])
-    maybe_unlink (output_file);
-
   if (response_file)
     maybe_unlink (response_file);
-
-  exit (status);
 }
 
 \f
@@ -1091,7 +1086,9 @@ main (int argc, char **argv)
   const char **ld2;
   char **object_lst;
   const char **object;
+#ifdef TARGET_AIX_VERSION
   int object_nbr = argc;
+#endif
   int first_file;
   int num_c_args;
   char **old_argv;
@@ -1130,6 +1127,9 @@ main (int argc, char **argv)
   signal (SIGCHLD, SIG_DFL);
 #endif
 
+  if (atexit (collect_atexit) != 0)
+    fatal_error ("atexit failed");
+
   /* Unlock the stdio streams.  */
   unlock_std_streams ();
 
@@ -1479,11 +1479,14 @@ main (int argc, char **argv)
                         extra space for remaining arguments.  */
                      if (add_nbr >= add_max)
                        {
-                         int pos = object - (const char **)object_lst;
+                         int pos =
+                           object - CONST_CAST2 (const char **, char **,
+                                                 object_lst);
                          add_max = (add_max == 0) ? 16 : add_max * 2;
                          object_lst = XRESIZEVEC (char *, object_lst,
                                                    object_nbr + add_max);
-                         object = (const char **) object_lst + pos;
+                         object = CONST_CAST2 (const char **, char **,
+                                               object_lst) + pos;
                          object_nbr += add_max;
                        }
                      *object++ = xstrdup (buf);
@@ -1968,7 +1971,7 @@ collect_wait (const char *prog, struct pex_obj *pex)
          error ("%s terminated with signal %d [%s]%s",
                 prog, sig, strsignal(sig),
                 WCOREDUMP(status) ? ", core dumped" : "");
-         collect_exit (FATAL_EXIT_CODE);
+         exit (FATAL_EXIT_CODE);
        }
 
       if (WIFEXITED (status))
@@ -1984,7 +1987,7 @@ do_wait (const char *prog, struct pex_obj *pex)
   if (ret != 0)
     {
       error ("%s returned %d exit status", prog, ret);
-      collect_exit (ret);
+      exit (ret);
     }
 
   if (response_file)
@@ -2927,12 +2930,14 @@ scan_libraries (const char *prog_name)
 /* 0757 = U803XTOCMAGIC (AIX 4.3) and 0767 = U64_TOCMAGIC (AIX V5) */
 #if TARGET_AIX_VERSION >= 51
 #   define GCC_CHECK_HDR(X) \
-     ((HEADER (X).f_magic == U802TOCMAGIC && ! aix64_flag) \
-      || (HEADER (X).f_magic == 0767 && aix64_flag))
+     (((HEADER (X).f_magic == U802TOCMAGIC && ! aix64_flag) \
+       || (HEADER (X).f_magic == 0767 && aix64_flag)) \
+      && !(HEADER (X).f_flags & F_LOADONLY))
 #else
 #   define GCC_CHECK_HDR(X) \
-     ((HEADER (X).f_magic == U802TOCMAGIC && ! aix64_flag) \
-      || (HEADER (X).f_magic == 0757 && aix64_flag))
+     (((HEADER (X).f_magic == U802TOCMAGIC && ! aix64_flag) \
+       || (HEADER (X).f_magic == 0757 && aix64_flag)) \
+      && !(HEADER (X).f_flags & F_LOADONLY))
 #endif
 
 #endif