+2013-06-21 David Edelsohn <dje.gcc@gmail.com>
+
+ Backport from mainline
+ 2013-06-19 David Edelsohn <dje.gcc@gmail.com>
+
+ PR driver/57652
+ * collect2.c (collect_atexit): New.
+ (collect_exit): Delete.
+ (main): Register collect_atexit with atexit.
+ (collect_wait): Change collect_exit to exit.
+ (do_wait): Same.
+ * collect2.h (collect_exit): Delete.
+ * tlink.c (do_tlink): Rename exit to ret. Change collect_exit to exit.
+
2013-06-07 Uros Bizjak <ubizjak@gmail.com>
Backport from mainline
/* 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
signal (SIGCHLD, SIG_DFL);
#endif
+ if (atexit (collect_atexit) != 0)
+ fatal_error ("atexit failed");
+
/* Unlock the stdio streams. */
unlock_std_streams ();
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)
/* Header file for collect/tlink routines.
- Copyright (C) 1998, 2003, 2004, 2005, 2007, 2010, 2011
+ Copyright (C) 1998, 2003, 2004, 2005, 2007, 2010, 2011, 2013
Free Software Foundation, Inc.
This file is part of GCC.
extern struct pex_obj *collect_execute (const char *, char **, const char *,
const char *, int flags);
-extern void collect_exit (int) ATTRIBUTE_NORETURN;
-
extern int collect_wait (const char *, struct pex_obj *);
extern void dump_file (const char *, FILE *);
them.
Copyright (C) 1995, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2007, 2008,
- 2009, 2010, 2011 Free Software Foundation, Inc.
+ 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
Contributed by Jason Merrill (jason@cygnus.com).
This file is part of GCC.
void
do_tlink (char **ld_argv, char **object_lst ATTRIBUTE_UNUSED)
{
- int exit = tlink_execute ("ld", ld_argv, ldout, lderrout);
+ int ret = tlink_execute ("ld", ld_argv, ldout, lderrout);
tlink_init ();
- if (exit)
+ if (ret)
{
int i = 0;
/* Until collect does a better job of figuring out which are object
files, assume that everything on the command line could be. */
if (read_repo_files (ld_argv))
- while (exit && i++ < MAX_ITERATIONS)
+ while (ret && i++ < MAX_ITERATIONS)
{
if (tlink_verbose >= 3)
{
break;
if (tlink_verbose)
fprintf (stderr, _("collect: relinking\n"));
- exit = tlink_execute ("ld", ld_argv, ldout, lderrout);
+ ret = tlink_execute ("ld", ld_argv, ldout, lderrout);
}
}
unlink (ldout);
dump_file (lderrout, stderr);
unlink (lderrout);
- if (exit)
+ if (ret)
{
- error ("ld returned %d exit status", exit);
- collect_exit (exit);
+ error ("ld returned %d exit status", ret);
+ exit (ret);
}
}