Add support for DragonFlyBSD target.
[binutils.git] / ld / emultempl / z80.em
blobeeb32138f35d1aeeba5b16240f92f7947cdb0647
1 # This shell script emits C code -*- C -*-
2 # to keep track of the machine type of Z80 object files
3 # It does some substitutions.
4 #   Copyright 2005, 2007, 2008 Free Software Foundation, Inc.
5 # This file is part of the GNU Binutils.
7 # This program 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 3 of the License, or
10 # (at your option) any later version.
12 # This program 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.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20 # MA 02110-1301, USA.
22 LDEMUL_BEFORE_PARSE=gldz80_before_parse
23 LDEMUL_RECOGNIZED_FILE=gldz80_recognized_file
24 LDEMUL_AFTER_OPEN=gldz80_after_open
26 fragment <<EOF
27 /* --- \begin{z80.em} */
28 /* Codes for machine types, bitwise or gives the code to use for the
29    output.  */
30 #define M_Z80STRICT 1
31 #define M_Z80 3
32 #define M_Z80FULL 7
33 #define M_R800 11
34 #define M_Z80ANY 15
36 /* Bitwise or of the machine types seen so far.  */
37 static int result_mach_type;
39 static void
40 ${LDEMUL_BEFORE_PARSE} (void)
42 #ifndef TARGET_                 /* I.e., if not generic.  */
43   ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
44 #endif /* not TARGET_ */
45   result_mach_type = M_Z80STRICT;
49 /* Update result_mach_type.  */
50 static bfd_boolean
51 ${LDEMUL_RECOGNIZED_FILE} (lang_input_statement_type *entry)
53   unsigned long mach_type;
55   mach_type = bfd_get_mach (entry->the_bfd);
56   switch (mach_type)
57     {
58     case bfd_mach_z80strict:
59       result_mach_type |= M_Z80STRICT;
60       break;
61     case bfd_mach_z80:
62       result_mach_type |= M_Z80;
63       break;
64     case bfd_mach_z80full:
65       result_mach_type |= M_Z80FULL;
66       break;
67     case bfd_mach_r800:
68       result_mach_type |= M_R800;
69       break;
70     default:
71       result_mach_type |= M_Z80ANY;
72     }
73   return FALSE;
76 /* Set the machine type of the output file based on result_mach_type.  */
77 static void
78 gldz80_after_open (void)
80   unsigned long mach_type;
82   after_open_default ();
84   switch (result_mach_type)
85     {
86     case M_Z80STRICT:
87       mach_type = bfd_mach_z80strict;
88       break;
89     case M_Z80:
90       mach_type = bfd_mach_z80;
91       break;
92     case M_Z80FULL:
93       mach_type = bfd_mach_z80full;
94       break;
95     case M_R800:
96       mach_type = bfd_mach_r800;
97       break;
98     default:
99       mach_type = 0;
100     }
101   bfd_set_arch_mach (link_info.output_bfd, bfd_arch_z80, mach_type);
103 /* --- \end{z80.em} */