include/elf/
[deliverable/binutils-gdb.git] / bfd / cpu-h8300.c
1 /* BFD library support routines for the Renesas H8/300 architecture.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
4 Hacked by Steve Chamberlain of Cygnus Support.
5
6 This file is part of BFD, the Binary File Descriptor library.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include "libbfd.h"
25
26 static bfd_boolean h8300_scan
27 PARAMS ((const struct bfd_arch_info *, const char *));
28 static const bfd_arch_info_type * compatible
29 PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
30
31 static bfd_boolean
32 h8300_scan (info, string)
33 const struct bfd_arch_info *info;
34 const char *string;
35 {
36 if (*string != 'h' && *string != 'H')
37 return FALSE;
38
39 string++;
40 if (*string != '8')
41 return FALSE;
42
43 string++;
44 if (*string == '/')
45 string++;
46
47 if (*string != '3')
48 return FALSE;
49 string++;
50 if (*string != '0')
51 return FALSE;
52 string++;
53 if (*string != '0')
54 return FALSE;
55 string++;
56 if (*string == '-')
57 string++;
58
59 /* In ELF linker scripts, we typically express the architecture/machine
60 as architecture:machine.
61
62 So if we've matched so far and encounter a colon, try to match the
63 string following the colon. */
64 if (*string == ':')
65 {
66 string++;
67 return h8300_scan (info, string);
68 }
69
70 if (*string == 'h' || *string == 'H')
71 {
72 string++;
73 if (*string == 'n' || *string == 'N')
74 return (info->mach == bfd_mach_h8300hn);
75
76 return (info->mach == bfd_mach_h8300h);
77 }
78 else if (*string == 's' || *string == 'S')
79 {
80 string++;
81 if (*string == 'n' || *string == 'N')
82 return (info->mach == bfd_mach_h8300sn);
83
84 if (*string == 'x' || *string == 'X')
85 {
86 string++;
87 if (*string == 'n' || *string == 'N')
88 return (info->mach == bfd_mach_h8300sxn);
89
90 return (info->mach == bfd_mach_h8300sx);
91 }
92
93 return (info->mach == bfd_mach_h8300s);
94 }
95 else
96 return info->mach == bfd_mach_h8300;
97 }
98
99 /* This routine is provided two arch_infos and works out the machine
100 which would be compatible with both and returns a pointer to its
101 info structure. */
102
103 static const bfd_arch_info_type *
104 compatible (in, out)
105 const bfd_arch_info_type *in;
106 const bfd_arch_info_type *out;
107 {
108 /* It's really not a good idea to mix and match modes. */
109 if (in->arch != out->arch || in->mach != out->mach)
110 return 0;
111 else
112 return in;
113 }
114
115 static const bfd_arch_info_type h8300sxn_info_struct =
116 {
117 32, /* 32 bits in a word */
118 32, /* 32 bits in an address */
119 8, /* 8 bits in a byte */
120 bfd_arch_h8300,
121 bfd_mach_h8300sxn,
122 "h8300sxn", /* arch_name */
123 "h8300sxn", /* printable name */
124 1,
125 FALSE, /* the default machine */
126 compatible,
127 h8300_scan,
128 0
129 };
130
131 static const bfd_arch_info_type h8300sx_info_struct =
132 {
133 32, /* 32 bits in a word */
134 32, /* 32 bits in an address */
135 8, /* 8 bits in a byte */
136 bfd_arch_h8300,
137 bfd_mach_h8300sx,
138 "h8300sx", /* arch_name */
139 "h8300sx", /* printable name */
140 1,
141 FALSE, /* the default machine */
142 compatible,
143 h8300_scan,
144 &h8300sxn_info_struct
145 };
146
147 static const bfd_arch_info_type h8300sn_info_struct =
148 {
149 32, /* 32 bits in a word. */
150 32, /* 32 bits in an address. */
151 8, /* 8 bits in a byte. */
152 bfd_arch_h8300,
153 bfd_mach_h8300sn,
154 "h8300sn", /* Architecture name. */
155 "h8300sn", /* Printable name. */
156 1,
157 FALSE, /* The default machine. */
158 compatible,
159 h8300_scan,
160 &h8300sx_info_struct
161 };
162
163
164 static const bfd_arch_info_type h8300hn_info_struct =
165 {
166 32, /* 32 bits in a word. */
167 32, /* 32 bits in an address. */
168 8, /* 8 bits in a byte. */
169 bfd_arch_h8300,
170 bfd_mach_h8300hn,
171 "h8300hn", /* Architecture name. */
172 "h8300hn", /* Printable name. */
173 1,
174 FALSE, /* The default machine. */
175 compatible,
176 h8300_scan,
177 &h8300sn_info_struct
178 };
179
180 static const bfd_arch_info_type h8300s_info_struct =
181 {
182 32, /* 32 bits in a word. */
183 32, /* 32 bits in an address. */
184 8, /* 8 bits in a byte. */
185 bfd_arch_h8300,
186 bfd_mach_h8300s,
187 "h8300s", /* Architecture name. */
188 "h8300s", /* Printable name. */
189 1,
190 FALSE, /* The default machine. */
191 compatible,
192 h8300_scan,
193 & h8300hn_info_struct
194 };
195
196 static const bfd_arch_info_type h8300h_info_struct =
197 {
198 32, /* 32 bits in a word. */
199 32, /* 32 bits in an address. */
200 8, /* 8 bits in a byte. */
201 bfd_arch_h8300,
202 bfd_mach_h8300h,
203 "h8300h", /* Architecture name. */
204 "h8300h", /* Printable name. */
205 1,
206 FALSE, /* The default machine. */
207 compatible,
208 h8300_scan,
209 &h8300s_info_struct
210 };
211
212 const bfd_arch_info_type bfd_h8300_arch =
213 {
214 16, /* 16 bits in a word. */
215 16, /* 16 bits in an address. */
216 8, /* 8 bits in a byte. */
217 bfd_arch_h8300,
218 bfd_mach_h8300,
219 "h8300", /* Architecture name. */
220 "h8300", /* Printable name. */
221 1,
222 TRUE, /* The default machine. */
223 compatible,
224 h8300_scan,
225 &h8300h_info_struct
226 };
This page took 0.045171 seconds and 5 git commands to generate.