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 2007 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,
22 LDEMUL_BEFORE_PARSE=gldz80_before_parse
23 LDEMUL_RECOGNIZED_FILE=gldz80_recognized_file
24 LDEMUL_AFTER_OPEN=gldz80_after_open
27 /* --- \begin{z80.em} */
28 /* Codes for machine types, bitwise or gives the code to use for the
36 /* Bitwise or of the machine types seen so far. */
37 static int result_mach_type;
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. */
51 ${LDEMUL_RECOGNIZED_FILE} (lang_input_statement_type *entry)
53 unsigned long mach_type;
55 mach_type = bfd_get_mach (entry->the_bfd);
58 case bfd_mach_z80strict:
59 result_mach_type |= M_Z80STRICT;
62 result_mach_type |= M_Z80;
64 case bfd_mach_z80full:
65 result_mach_type |= M_Z80FULL;
68 result_mach_type |= M_R800;
71 result_mach_type |= M_Z80ANY;
76 /* Set the machine type of the output file based on result_mach_type. */
78 gldz80_after_open (void)
80 unsigned long mach_type;
82 switch (result_mach_type)
85 mach_type = bfd_mach_z80strict;
88 mach_type = bfd_mach_z80;
91 mach_type = bfd_mach_z80full;
94 mach_type = bfd_mach_r800;
99 bfd_set_arch_mach (output_bfd, bfd_arch_z80, mach_type);
101 /* --- \end{z80.em} */