Replace remove_output with ld_cleanup in comments.
[deliverable/binutils-gdb.git] / gas / output-file.c
CommitLineData
252b5132 1/* output-file.c - Deal with the output file
2da5c037 2 Copyright 1987, 1990, 1991, 1992, 1993, 1994, 1996, 1998, 1999, 2001,
ec2655a6 3 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
252b5132
RH
4
5 This file is part of GAS, the GNU Assembler.
6
7 GAS is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
ec2655a6 9 the Free Software Foundation; either version 3, or (at your option)
252b5132
RH
10 any later version.
11
12 GAS is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GAS; see the file COPYING. If not, write to
4b4da160
NC
19 the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
20 02110-1301, USA. */
252b5132 21
252b5132 22#include "as.h"
252b5132
RH
23#include "output-file.h"
24
252b5132
RH
25#ifndef TARGET_MACH
26#define TARGET_MACH 0
27#endif
252b5132 28
252b5132
RH
29bfd *stdoutput;
30
31void
24361518 32output_file_create (char *name)
252b5132
RH
33{
34 if (name[0] == '-' && name[1] == '\0')
0e389e77 35 as_fatal (_("can't open a bfd on stdout %s"), name);
f740e790 36
252b5132
RH
37 else if (!(stdoutput = bfd_openw (name, TARGET_FORMAT)))
38 {
885afe7b
AM
39 bfd_error_type err = bfd_get_error ();
40
41 if (err == bfd_error_invalid_target)
42 as_fatal (_("selected target format '%s' unknown"), TARGET_FORMAT);
e7bd9ea0 43 else
885afe7b 44 as_fatal (_("can't create %s: %s"), name, bfd_errmsg (err));
252b5132 45 }
f740e790 46
252b5132 47 bfd_set_format (stdoutput, bfd_object);
252b5132 48 bfd_set_arch_mach (stdoutput, TARGET_ARCH, TARGET_MACH);
252b5132
RH
49 if (flag_traditional_format)
50 stdoutput->flags |= BFD_TRADITIONAL_FORMAT;
51}
52
53void
24361518 54output_file_close (char *filename)
252b5132 55{
df3ca5a3
NC
56 bfd_boolean res;
57
58 if (stdoutput == NULL)
59 return;
60
252b5132 61 /* Close the bfd. */
df3ca5a3
NC
62 res = bfd_close (stdoutput);
63
64 /* Prevent an infinite loop - if the close failed we will call as_fatal
65 which will call xexit() which may call this function again... */
66 stdoutput = NULL;
67
68 if (! res)
885afe7b
AM
69 as_fatal (_("can't close %s: %s"), filename,
70 bfd_errmsg (bfd_get_error ()));
252b5132 71}
This page took 0.543617 seconds and 4 git commands to generate.