1 /* BFD library support routines for the H8/500 architecture.
2 Copyright (C) 1993 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. */
28 Relocations for the Z8K
31 static bfd_reloc_status_type
32 DEFUN(howto16_callback,(abfd, reloc_entry, symbol_in, data,
33 ignore_input_section, ignore_bfd),
35 arelent *reloc_entry AND
36 struct symbol_cache_entry *symbol_in AND
38 asection *ignore_input_section AND
42 bfd_vma addr = reloc_entry->address;
43 long x = bfd_get_16(abfd, (bfd_byte *)data + addr);
45 HOWTO_PREPARE(relocation, symbol_in);
47 x = (x + relocation + reloc_entry->addend);
49 bfd_put_16(abfd, x, (bfd_byte *)data + addr);
54 static bfd_reloc_status_type
55 DEFUN(howto8_callback,(abfd, reloc_entry, symbol_in, data,
56 ignore_input_section, ignore_bfd),
58 arelent *reloc_entry AND
59 struct symbol_cache_entry *symbol_in AND
61 asection *ignore_input_section AND
65 bfd_vma addr = reloc_entry->address;
66 long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
68 HOWTO_PREPARE(relocation, symbol_in);
70 x = (x + relocation + reloc_entry->addend);
72 bfd_put_8(abfd, x, (bfd_byte *)data + addr);
77 static bfd_reloc_status_type
78 DEFUN(howto8_FFnn_callback,(abfd, reloc_entry, symbol_in, data,
79 ignore_input_section, ignore_bfd),
81 arelent *reloc_entry AND
82 struct symbol_cache_entry *symbol_in AND
84 asection *ignore_input_section AND
88 bfd_vma addr = reloc_entry->address;
90 long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
92 HOWTO_PREPARE(relocation, symbol_in);
94 x = (x + relocation + reloc_entry->addend);
96 bfd_put_8(abfd, x, (bfd_byte *)data + addr);
100 static bfd_reloc_status_type
101 DEFUN(howto8_pcrel_callback,(abfd, reloc_entry, symbol_in, data,
102 ignore_input_section, ignore_bfd),
104 arelent *reloc_entry AND
105 struct symbol_cache_entry *symbol_in AND
107 asection *ignore_input_section AND
111 bfd_vma addr = reloc_entry->address;
112 long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
114 HOWTO_PREPARE(relocation, symbol_in);
116 x = (x + relocation + reloc_entry->addend);
118 bfd_put_8(abfd, x, (bfd_byte *)data + addr);
124 static reloc_howto_type howto_16
125 = NEWHOWTO(howto16_callback,"abs16",1,false,false);
126 static reloc_howto_type howto_8
127 = NEWHOWTO(howto8_callback,"abs8",0,false,false);
129 static reloc_howto_type howto_8_FFnn
130 = NEWHOWTO(howto8_FFnn_callback,"ff00+abs8",0,false,false);
132 static reloc_howto_type howto_8_pcrel
133 = NEWHOWTO(howto8_pcrel_callback,"pcrel8",0,false,true);
136 static CONST struct reloc_howto_struct *
137 DEFUN(local_bfd_reloc_type_lookup,(arch, code),
138 CONST struct bfd_arch_info *arch AND
139 bfd_reloc_code_real_type code)
144 case BFD_RELOC_8_FFnn:
145 return &howto_8_FFnn;
148 case BFD_RELOC_8_PCREL:
149 return &howto_8_pcrel;
151 return (reloc_howto_type *)NULL;
155 int bfd_default_scan_num_mach();
158 DEFUN(scan_mach,(info, string),
159 CONST struct bfd_arch_info *info AND
162 if (strcmp(string,"h8/500") == 0) return true;
163 if (strcmp(string,"H8/500") == 0) return true;
164 if (strcmp(string,"h8500") == 0) return true;
165 if (strcmp(string,"H8500") == 0) return true;
169 /* This routine is provided two arch_infos and returns whether
170 they'd be compatible */
172 static CONST bfd_arch_info_type *
173 DEFUN(compatible,(a,b),
174 CONST bfd_arch_info_type *a AND
175 CONST bfd_arch_info_type *b)
177 if (a->arch != b->arch || a->mach != b->mach)
183 static bfd_arch_info_type arch_info_struct[] =
185 16, /* 16 bits in a word */
186 24, /* 24 bits in an address */
187 8, /* 8 bits in a byte */
189 0, /* only 1 machine */
190 "H8/500", /* arch_name */
191 "H8/500", /* printable name */
193 true, /* the default machine */
194 bfd_default_compatible,
203 DEFUN_VOID(bfd_h8500_arch)
205 bfd_arch_linkin(&arch_info_struct[0]);