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.
6 This file is part of BFD, the Binary File Descriptor library.
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.
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.
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. */
27 h8300_scan (const struct bfd_arch_info *info, const char *string)
29 if (*string != 'h' && *string != 'H')
52 /* In ELF linker scripts, we typically express the architecture/machine
53 as architecture:machine.
55 So if we've matched so far and encounter a colon, try to match the
56 string following the colon. */
60 return h8300_scan (info, string);
63 if (*string == 'h' || *string == 'H')
66 if (*string == 'n' || *string == 'N')
67 return (info->mach == bfd_mach_h8300hn);
69 return (info->mach == bfd_mach_h8300h);
71 else if (*string == 's' || *string == 'S')
74 if (*string == 'n' || *string == 'N')
75 return (info->mach == bfd_mach_h8300sn);
77 if (*string == 'x' || *string == 'X')
80 if (*string == 'n' || *string == 'N')
81 return (info->mach == bfd_mach_h8300sxn);
83 return (info->mach == bfd_mach_h8300sx);
86 return (info->mach == bfd_mach_h8300s);
89 return info->mach == bfd_mach_h8300;
92 /* This routine is provided two arch_infos and works out the machine
93 which would be compatible with both and returns a pointer to its
96 static const bfd_arch_info_type *
97 compatible (const bfd_arch_info_type *in, const bfd_arch_info_type *out)
99 /* It's really not a good idea to mix and match modes. */
100 if (in->arch != out->arch || in->mach != out->mach)
106 static const bfd_arch_info_type h8300sxn_info_struct =
108 32, /* 32 bits in a word */
109 16, /* 16 bits in an address */
110 8, /* 8 bits in a byte */
113 "h8300sxn", /* arch_name */
114 "h8300sxn", /* printable name */
116 FALSE, /* the default machine */
122 static const bfd_arch_info_type h8300sx_info_struct =
124 32, /* 32 bits in a word */
125 32, /* 32 bits in an address */
126 8, /* 8 bits in a byte */
129 "h8300sx", /* arch_name */
130 "h8300sx", /* printable name */
132 FALSE, /* the default machine */
135 &h8300sxn_info_struct
138 static const bfd_arch_info_type h8300sn_info_struct =
140 32, /* 32 bits in a word. */
141 16, /* 16 bits in an address. */
142 8, /* 8 bits in a byte. */
145 "h8300sn", /* Architecture name. */
146 "h8300sn", /* Printable name. */
148 FALSE, /* The default machine. */
154 static const bfd_arch_info_type h8300hn_info_struct =
156 32, /* 32 bits in a word. */
157 16, /* 16 bits in an address. */
158 8, /* 8 bits in a byte. */
161 "h8300hn", /* Architecture name. */
162 "h8300hn", /* Printable name. */
164 FALSE, /* The default machine. */
170 static const bfd_arch_info_type h8300s_info_struct =
172 32, /* 32 bits in a word. */
173 32, /* 32 bits in an address. */
174 8, /* 8 bits in a byte. */
177 "h8300s", /* Architecture name. */
178 "h8300s", /* Printable name. */
180 FALSE, /* The default machine. */
183 & h8300hn_info_struct
186 static const bfd_arch_info_type h8300h_info_struct =
188 32, /* 32 bits in a word. */
189 32, /* 32 bits in an address. */
190 8, /* 8 bits in a byte. */
193 "h8300h", /* Architecture name. */
194 "h8300h", /* Printable name. */
196 FALSE, /* The default machine. */
202 const bfd_arch_info_type bfd_h8300_arch =
204 16, /* 16 bits in a word. */
205 16, /* 16 bits in an address. */
206 8, /* 8 bits in a byte. */
209 "h8300", /* Architecture name. */
210 "h8300", /* Printable name. */
212 TRUE, /* The default machine. */
218 /* Pad the given address to 32 bits, converting 16-bit and 24-bit
219 addresses into the values they would have had on a h8s target. */
222 bfd_h8300_pad_address (bfd *abfd, bfd_vma address)
224 /* Cope with bfd_vma's larger than 32 bits. */
225 address &= 0xffffffffu;
227 switch (bfd_get_mach (abfd))
230 case bfd_mach_h8300hn:
231 case bfd_mach_h8300sn:
232 case bfd_mach_h8300sxn:
233 /* Sign extend a 16-bit address. */
234 if (address >= 0x8000)
235 return address | 0xffff0000u;
238 case bfd_mach_h8300h:
239 /* Sign extend a 24-bit address. */
240 if (address >= 0x800000)
241 return address | 0xff000000u;
244 case bfd_mach_h8300s:
245 case bfd_mach_h8300sx: