Update year range in copyright notice of binutils files
[deliverable/binutils-gdb.git] / ld / emultempl / z80.em
CommitLineData
3c9b82ba
NC
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.
b3adc24a 4# Copyright (C) 2005-2020 Free Software Foundation, Inc.
f96b4a7b
NC
5# This file is part of the GNU Binutils.
6#
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.
11#
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.
16#
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.
3c9b82ba
NC
21
22LDEMUL_BEFORE_PARSE=gldz80_before_parse
23LDEMUL_RECOGNIZED_FILE=gldz80_recognized_file
24LDEMUL_AFTER_OPEN=gldz80_after_open
25
92b93329 26fragment <<EOF
3c9b82ba
NC
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
35
36/* Bitwise or of the machine types seen so far. */
37static int result_mach_type;
38
92b93329 39static void
3c9b82ba
NC
40${LDEMUL_BEFORE_PARSE} (void)
41{
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;
46}
47
48
49/* Update result_mach_type. */
50static bfd_boolean
51${LDEMUL_RECOGNIZED_FILE} (lang_input_statement_type *entry)
52{
53 unsigned long mach_type;
54
55 mach_type = bfd_get_mach (entry->the_bfd);
92b93329 56 switch (mach_type)
3c9b82ba 57 {
92b93329
RM
58 case bfd_mach_z80strict:
59 result_mach_type |= M_Z80STRICT;
3c9b82ba
NC
60 break;
61 case bfd_mach_z80:
92b93329 62 result_mach_type |= M_Z80;
3c9b82ba
NC
63 break;
64 case bfd_mach_z80full:
92b93329 65 result_mach_type |= M_Z80FULL;
3c9b82ba
NC
66 break;
67 case bfd_mach_r800:
92b93329 68 result_mach_type |= M_R800;
3c9b82ba
NC
69 break;
70 default:
71 result_mach_type |= M_Z80ANY;
72 }
73 return FALSE;
74}
75
76/* Set the machine type of the output file based on result_mach_type. */
77static void
78gldz80_after_open (void)
79{
80 unsigned long mach_type;
81
5c3049d2
AM
82 after_open_default ();
83
3c9b82ba
NC
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 }
f13a99db 101 bfd_set_arch_mach (link_info.output_bfd, bfd_arch_z80, mach_type);
3c9b82ba
NC
102}
103/* --- \end{z80.em} */
104EOF
This page took 0.648932 seconds and 4 git commands to generate.