summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/gas/output-file.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/binutils/gas/output-file.c')
-rw-r--r--contrib/binutils/gas/output-file.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/contrib/binutils/gas/output-file.c b/contrib/binutils/gas/output-file.c
index f94359a..9603dc4 100644
--- a/contrib/binutils/gas/output-file.c
+++ b/contrib/binutils/gas/output-file.c
@@ -1,6 +1,6 @@
/* output-file.c - Deal with the output file
Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1996, 1998, 1999, 2001,
- 2003, 2004, 2005 Free Software Foundation, Inc.
+ 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
@@ -19,17 +19,13 @@
the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
-#include <stdio.h>
-
#include "as.h"
-
#include "output-file.h"
#ifndef TARGET_MACH
#define TARGET_MACH 0
#endif
-#include "bfd.h"
bfd *stdoutput;
void
@@ -40,11 +36,12 @@ output_file_create (char *name)
else if (!(stdoutput = bfd_openw (name, TARGET_FORMAT)))
{
- if (bfd_get_error () == bfd_error_invalid_target)
- as_perror (_("Selected target format '%s' unknown"), TARGET_FORMAT);
+ bfd_error_type err = bfd_get_error ();
+
+ if (err == bfd_error_invalid_target)
+ as_fatal (_("selected target format '%s' unknown"), TARGET_FORMAT);
else
- as_perror (_("FATAL: can't create %s"), name);
- exit (EXIT_FAILURE);
+ as_fatal (_("can't create %s: %s"), name, bfd_errmsg (err));
}
bfd_set_format (stdoutput, bfd_object);
@@ -56,12 +53,19 @@ output_file_create (char *name)
void
output_file_close (char *filename)
{
+ bfd_boolean res;
+
+ if (stdoutput == NULL)
+ return;
+
/* Close the bfd. */
- if (bfd_close (stdoutput) == 0)
- {
- bfd_perror (filename);
- as_perror (_("FATAL: can't close %s\n"), filename);
- exit (EXIT_FAILURE);
- }
- stdoutput = NULL; /* Trust nobody! */
+ res = bfd_close (stdoutput);
+
+ /* Prevent an infinite loop - if the close failed we will call as_fatal
+ which will call xexit() which may call this function again... */
+ stdoutput = NULL;
+
+ if (! res)
+ as_fatal (_("can't close %s: %s"), filename,
+ bfd_errmsg (bfd_get_error ()));
}
OpenPOWER on IntegriCloud