This commit was generated by cvs2svn to track changes on a CVS vendor
[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,
7be1c489 3 2003, 2004, 2005 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
9 the Free Software Foundation; either version 2, or (at your option)
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
RH
21
22#include <stdio.h>
23
24#include "as.h"
25
26#include "output-file.h"
27
252b5132
RH
28#ifndef TARGET_MACH
29#define TARGET_MACH 0
30#endif
252b5132 31
252b5132
RH
32#include "bfd.h"
33bfd *stdoutput;
34
35void
24361518 36output_file_create (char *name)
252b5132
RH
37{
38 if (name[0] == '-' && name[1] == '\0')
0e389e77 39 as_fatal (_("can't open a bfd on stdout %s"), name);
f740e790 40
252b5132
RH
41 else if (!(stdoutput = bfd_openw (name, TARGET_FORMAT)))
42 {
e7bd9ea0
NC
43 if (bfd_get_error () == bfd_error_invalid_target)
44 as_perror (_("Selected target format '%s' unknown"), TARGET_FORMAT);
45 else
46 as_perror (_("FATAL: can't create %s"), name);
252b5132
RH
47 exit (EXIT_FAILURE);
48 }
f740e790 49
252b5132 50 bfd_set_format (stdoutput, bfd_object);
252b5132 51 bfd_set_arch_mach (stdoutput, TARGET_ARCH, TARGET_MACH);
252b5132
RH
52 if (flag_traditional_format)
53 stdoutput->flags |= BFD_TRADITIONAL_FORMAT;
54}
55
56void
24361518 57output_file_close (char *filename)
252b5132 58{
252b5132
RH
59 /* Close the bfd. */
60 if (bfd_close (stdoutput) == 0)
61 {
62 bfd_perror (filename);
0e389e77 63 as_perror (_("FATAL: can't close %s\n"), filename);
252b5132
RH
64 exit (EXIT_FAILURE);
65 }
f740e790 66 stdoutput = NULL; /* Trust nobody! */
252b5132 67}
This page took 0.371086 seconds and 4 git commands to generate.