* ldlang.c (init_os): Ensure sections mentioned in load_base
[binutils.git] / bfd / cpu-h8300.c
blobeafcb9806dcaf26bd5acd247f5c3338de81f6b13
1 /* BFD library support routines for the Hitachi H8/300 architecture.
2 Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 2000, 2001, 2002
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. */
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include "libbfd.h"
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 *));
31 static bfd_boolean
32 h8300_scan (info, string)
33 const struct bfd_arch_info *info;
34 const char *string;
36 if (*string != 'h' && *string != 'H')
37 return FALSE;
39 string++;
40 if (*string != '8')
41 return FALSE;
43 string++;
44 if (*string == '/')
45 string++;
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++;
59 /* In ELF linker scripts, we typically express the architecture/machine
60 as architecture:machine.
62 So if we've matched so far and encounter a colon, try to match the
63 string following the colon. */
64 if (*string == ':')
66 string++;
67 return h8300_scan (info, string);
70 if (*string == 'h' || *string == 'H')
72 return (info->mach == bfd_mach_h8300h);
74 else if (*string == 's' || *string == 'S')
76 return (info->mach == bfd_mach_h8300s);
78 else
80 return info->mach == bfd_mach_h8300;
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. */
88 static const bfd_arch_info_type *
89 compatible (in, out)
90 const bfd_arch_info_type *in;
91 const bfd_arch_info_type *out;
93 /* It's really not a good idea to mix and match modes. */
94 if (in->arch != out->arch || in->mach != out->mach)
95 return 0;
96 else
97 return in;
100 static const bfd_arch_info_type h8300s_info_struct =
102 32, /* 32 bits in a word */
103 32, /* 32 bits in an address */
104 8, /* 8 bits in a byte */
105 bfd_arch_h8300,
106 bfd_mach_h8300s,
107 "h8300s", /* arch_name */
108 "h8300s", /* printable name */
110 FALSE, /* the default machine */
111 compatible,
112 h8300_scan,
116 static const bfd_arch_info_type h8300h_info_struct =
118 32, /* 32 bits in a word */
119 32, /* 32 bits in an address */
120 8, /* 8 bits in a byte */
121 bfd_arch_h8300,
122 bfd_mach_h8300h,
123 "h8300h", /* arch_name */
124 "h8300h", /* printable name */
126 FALSE, /* the default machine */
127 compatible,
128 h8300_scan,
129 &h8300s_info_struct
132 const bfd_arch_info_type bfd_h8300_arch =
134 16, /* 16 bits in a word */
135 16, /* 16 bits in an address */
136 8, /* 8 bits in a byte */
137 bfd_arch_h8300,
138 bfd_mach_h8300,
139 "h8300", /* arch_name */
140 "h8300", /* printable name */
142 TRUE, /* the default machine */
143 compatible,
144 h8300_scan,
145 &h8300h_info_struct