/* 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),
\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);
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
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;
signal (SIGCHLD, SIG_DFL);
#endif
+ if (atexit (collect_atexit) != 0)
+ fatal_error ("atexit failed");
+
/* Unlock the stdio streams. */
unlock_std_streams ();
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);
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))
if (ret != 0)
{
error ("%s returned %d exit status", prog, ret);
- collect_exit (ret);
+ exit (ret);
}
if (response_file)
/* 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