Fix brown-paper-bag thinko in last change.
[deliverable/binutils-gdb.git] / bfd / cpu-h8300.c
1 /* BFD library support routines for the Hitachi H8/300 architecture.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2000, 2001
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 int bfd_default_scan_num_mach ();
27
28 static boolean h8300_scan
29 PARAMS ((const struct bfd_arch_info *, const char *));
30 static const bfd_arch_info_type * compatible
31 PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
32
33 static boolean
34 h8300_scan (info, string)
35 const struct bfd_arch_info *info;
36 const char *string;
37 {
38 if (*string != 'h' && *string != 'H')
39 return false;
40
41 string++;
42 if (*string != '8')
43 return false;
44
45 string++;
46 if (*string == '/')
47 string++;
48
49 if (*string != '3')
50 return false;
51 string++;
52 if (*string != '0')
53 return false;
54 string++;
55 if (*string != '0')
56 return false;
57 string++;
58 if (*string == '-')
59 string++;
60
61 /* In ELF linker scripts, we typically express the architecture/machine
62 as architecture:machine.
63
64 So if we've matched so far and encounter a colon, try to match the
65 string following the colon. */
66 if (*string == ':')
67 {
68 string++;
69 return h8300_scan (info, string);
70 }
71
72 if (*string == 'h' || *string == 'H')
73 {
74 return (info->mach == bfd_mach_h8300h);
75 }
76 else if (*string == 's' || *string == 'S')
77 {
78 return (info->mach == bfd_mach_h8300s);
79 }
80 else
81 {
82 return info->mach == bfd_mach_h8300;
83 }
84 }
85
86 /* This routine is provided two arch_infos and works out the machine
87 which would be compatible with both and returns a pointer to its
88 info structure. */
89
90 static const bfd_arch_info_type *
91 compatible (in, out)
92 const bfd_arch_info_type *in;
93 const bfd_arch_info_type *out;
94 {
95 /* It's really not a good idea to mix and match modes. */
96 if (in->mach != out->mach)
97 return 0;
98 else
99 return in;
100 }
101
102 static const bfd_arch_info_type h8300_info_struct =
103 {
104 16, /* 16 bits in a word */
105 16, /* 16 bits in an address */
106 8, /* 8 bits in a byte */
107 bfd_arch_h8300,
108 bfd_mach_h8300,
109 "h8300", /* arch_name */
110 "h8300", /* printable name */
111 1,
112 true, /* the default machine */
113 compatible,
114 h8300_scan,
115 #if 0
116 local_bfd_reloc_type_lookup,
117 #endif
118 0,
119 };
120
121 static const bfd_arch_info_type h8300h_info_struct =
122 {
123 32, /* 32 bits in a word */
124 32, /* 32 bits in an address */
125 8, /* 8 bits in a byte */
126 bfd_arch_h8300,
127 bfd_mach_h8300h,
128 "h8300h", /* arch_name */
129 "h8300h", /* printable name */
130 1,
131 false, /* the default machine */
132 compatible,
133 h8300_scan,
134 #if 0
135 local_bfd_reloc_type_lookup,
136 #endif
137 &h8300_info_struct,
138 };
139
140 const bfd_arch_info_type bfd_h8300_arch =
141 {
142 32, /* 32 bits in a word */
143 32, /* 32 bits in an address */
144 8, /* 8 bits in a byte */
145 bfd_arch_h8300,
146 bfd_mach_h8300s,
147 "h8300s", /* arch_name */
148 "h8300s", /* printable name */
149 1,
150 false, /* the default machine */
151 compatible,
152 h8300_scan,
153 #if 0
154 local_bfd_reloc_type_lookup,
155 #endif
156 &h8300h_info_struct,
157 };
This page took 0.034595 seconds and 5 git commands to generate.