Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* BFD library support routines for the Hitachi H8/300 architecture. |
0a83638b | 2 | Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2000, 2001 |
7898deda | 3 | Free Software Foundation, Inc. |
252b5132 RH |
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 | ||
0a83638b JL |
26 | static 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 | ||
252b5132 RH |
31 | static 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++; | |
0a83638b JL |
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++; | |
eea78af1 | 67 | return h8300_scan (info, string); |
0a83638b JL |
68 | } |
69 | ||
252b5132 RH |
70 | if (*string == 'h' || *string == 'H') |
71 | { | |
72 | return (info->mach == bfd_mach_h8300h); | |
73 | } | |
74 | else if (*string == 's' || *string == 'S') | |
75 | { | |
76 | return (info->mach == bfd_mach_h8300s); | |
77 | } | |
78 | else | |
79 | { | |
80 | return info->mach == bfd_mach_h8300; | |
81 | } | |
82 | } | |
83 | ||
cc040812 NC |
84 | /* This routine is provided two arch_infos and works out the machine |
85 | which would be compatible with both and returns a pointer to its | |
86 | info structure. */ | |
252b5132 RH |
87 | |
88 | static const bfd_arch_info_type * | |
89 | compatible (in, out) | |
cc040812 NC |
90 | const bfd_arch_info_type *in; |
91 | const bfd_arch_info_type *out; | |
252b5132 RH |
92 | { |
93 | /* It's really not a good idea to mix and match modes. */ | |
b74fa2cd | 94 | if (in->arch != out->arch || in->mach != out->mach) |
252b5132 RH |
95 | return 0; |
96 | else | |
97 | return in; | |
98 | } | |
99 | ||
100 | static const bfd_arch_info_type h8300_info_struct = | |
101 | { | |
102 | 16, /* 16 bits in a word */ | |
103 | 16, /* 16 bits in an address */ | |
104 | 8, /* 8 bits in a byte */ | |
105 | bfd_arch_h8300, | |
106 | bfd_mach_h8300, | |
107 | "h8300", /* arch_name */ | |
108 | "h8300", /* printable name */ | |
109 | 1, | |
110 | true, /* the default machine */ | |
111 | compatible, | |
112 | h8300_scan, | |
cc040812 NC |
113 | #if 0 |
114 | local_bfd_reloc_type_lookup, | |
115 | #endif | |
252b5132 RH |
116 | 0, |
117 | }; | |
118 | ||
119 | static const bfd_arch_info_type h8300h_info_struct = | |
120 | { | |
121 | 32, /* 32 bits in a word */ | |
122 | 32, /* 32 bits in an address */ | |
123 | 8, /* 8 bits in a byte */ | |
124 | bfd_arch_h8300, | |
125 | bfd_mach_h8300h, | |
126 | "h8300h", /* arch_name */ | |
127 | "h8300h", /* printable name */ | |
128 | 1, | |
129 | false, /* the default machine */ | |
130 | compatible, | |
131 | h8300_scan, | |
cc040812 NC |
132 | #if 0 |
133 | local_bfd_reloc_type_lookup, | |
134 | #endif | |
252b5132 RH |
135 | &h8300_info_struct, |
136 | }; | |
137 | ||
138 | const bfd_arch_info_type bfd_h8300_arch = | |
139 | { | |
140 | 32, /* 32 bits in a word */ | |
141 | 32, /* 32 bits in an address */ | |
142 | 8, /* 8 bits in a byte */ | |
143 | bfd_arch_h8300, | |
144 | bfd_mach_h8300s, | |
145 | "h8300s", /* arch_name */ | |
146 | "h8300s", /* printable name */ | |
147 | 1, | |
148 | false, /* the default machine */ | |
149 | compatible, | |
150 | h8300_scan, | |
cc040812 NC |
151 | #if 0 |
152 | local_bfd_reloc_type_lookup, | |
153 | #endif | |
252b5132 RH |
154 | &h8300h_info_struct, |
155 | }; |