1 /* BFD library support routines for the Hitachi H8/300 architecture.
2 Copyright (C) 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
3 Hacked by Steve Chamberlain of Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 #if 0 /* not used currently */
27 Relocations for the H8
30 static bfd_reloc_status_type
31 howto16_callback (abfd, reloc_entry, symbol_in, data,
32 ignore_input_section, ignore_bfd)
34 arelent * reloc_entry;
35 struct symbol_cache_entry *symbol_in;
37 asection * ignore_input_section;
41 bfd_vma addr = reloc_entry->address;
42 long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
44 HOWTO_PREPARE (relocation, symbol_in);
46 x = (x + relocation + reloc_entry->addend);
48 bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
53 static bfd_reloc_status_type
54 howto8_callback (abfd, reloc_entry, symbol_in, data,
55 ignore_input_section, ignore_bfd)
57 arelent * reloc_entry;
58 struct symbol_cache_entry *symbol_in;
60 asection * ignore_input_section;
64 bfd_vma addr = reloc_entry->address;
65 long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
67 HOWTO_PREPARE (relocation, symbol_in);
69 x = (x + relocation + reloc_entry->addend);
71 bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
76 static bfd_reloc_status_type
77 howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
78 ignore_input_section, ignore_bfd)
80 arelent * reloc_entry;
81 struct symbol_cache_entry *symbol_in;
83 asection * ignore_input_section;
87 bfd_vma addr = reloc_entry->address;
89 long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
91 HOWTO_PREPARE (relocation, symbol_in);
93 x = (x + relocation + reloc_entry->addend);
95 bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
99 static bfd_reloc_status_type
100 howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
101 ignore_input_section, ignore_bfd)
103 arelent * reloc_entry;
104 struct symbol_cache_entry *symbol_in;
106 asection * ignore_input_section;
110 bfd_vma addr = reloc_entry->address;
111 long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
113 HOWTO_PREPARE (relocation, symbol_in);
115 x = (x + relocation + reloc_entry->addend);
117 bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
121 static reloc_howto_type howto_16
122 = NEWHOWTO (howto16_callback, "abs16", 1, false, false);
123 static reloc_howto_type howto_8
124 = NEWHOWTO (howto8_callback, "abs8", 0, false, false);
126 static reloc_howto_type howto_8_FFnn
127 = NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
129 static reloc_howto_type howto_8_pcrel
130 = NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
132 static reloc_howto_type *
133 local_bfd_reloc_type_lookup (arch, code)
134 CONST struct bfd_arch_info *arch;
135 bfd_reloc_code_real_type code;
141 case BFD_RELOC_8_FFnn:
142 return &howto_8_FFnn;
145 case BFD_RELOC_8_PCREL:
146 return &howto_8_pcrel;
148 return (reloc_howto_type *) NULL;
153 int bfd_default_scan_num_mach ();
156 h8300_scan (info, string)
157 CONST struct bfd_arch_info *info;
160 if (*string != 'h' && *string != 'H')
182 if (*string == 'h' || *string == 'H')
184 return (info->mach == bfd_mach_h8300h);
188 return info->mach == bfd_mach_h8300;
193 /* This routine is provided two arch_infos and works out the
194 machine which would be compatible with both and returns a pointer
195 to its info structure */
197 static CONST bfd_arch_info_type *
199 CONST bfd_arch_info_type * in;
200 CONST bfd_arch_info_type * out;
202 /* If the output is non-H and the input is -H, that's bad */
203 if (in->mach == bfd_mach_h8300h &&
204 out->mach == bfd_mach_h8300)
207 /* If either is an -H, the answer is -H */
208 if (in->mach == bfd_mach_h8300h)
213 static bfd_arch_info_type h8300_info_struct =
215 16, /* 16 bits in a word */
216 16, /* 16 bits in an address */
217 8, /* 8 bits in a byte */
220 "H8/300", /* arch_name */
221 "H8/300", /* printable name */
223 true, /* the default machine */
227 /* local_bfd_reloc_type_lookup, */
232 static bfd_arch_info_type h8300h_info_struct =
234 32, /* 32 bits in a word */
235 32, /* 32 bits in an address */
236 8, /* 8 bits in a byte */
239 "H8/300H", /* arch_name */
240 "H8/300H", /* printable name */
242 false, /* the default machine */
246 /* local_bfd_reloc_type_lookup, */
253 bfd_arch_linkin (&h8300_info_struct);
254 bfd_arch_linkin (&h8300h_info_struct);