1 /* BFD library support routines for the H8/500 architecture.
2 Copyright 1993, 1995, 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. */
26 static bfd_boolean scan_mach
27 PARAMS ((const struct bfd_arch_info *, const char *));
31 Relocations for the Z8K
34 static bfd_reloc_status_type
35 howto16_callback (abfd, reloc_entry, symbol_in, data,
36 ignore_input_section, ignore_bfd)
39 struct bfd_symbol *symbol_in;
41 asection *ignore_input_section;
45 bfd_vma addr = reloc_entry->address;
46 long x = bfd_get_16 (abfd, (bfd_byte *)data + addr);
48 HOWTO_PREPARE(relocation, symbol_in);
50 x = (x + relocation + reloc_entry->addend);
52 bfd_put_16 (abfd, x, (bfd_byte *)data + addr);
56 static bfd_reloc_status_type
57 howto8_callback (abfd, reloc_entry, symbol_in, data,
58 ignore_input_section, ignore_bfd)
61 struct bfd_symbol *symbol_in;
63 asection *ignore_input_section;
67 bfd_vma addr = reloc_entry->address;
68 long x = bfd_get_8 (abfd, (bfd_byte *)data + addr);
70 HOWTO_PREPARE(relocation, symbol_in);
72 x = (x + relocation + reloc_entry->addend);
74 bfd_put_8 (abfd, x, (bfd_byte *)data + addr);
78 static bfd_reloc_status_type
79 howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
80 ignore_input_section, ignore_bfd)
83 struct bfd_symbol *symbol_in;
85 asection *ignore_input_section;
89 bfd_vma addr = reloc_entry->address;
91 long x = bfd_get_8 (abfd, (bfd_byte *)data + addr);
93 HOWTO_PREPARE(relocation, symbol_in);
95 x = (x + relocation + reloc_entry->addend);
97 bfd_put_8 (abfd, x, (bfd_byte *)data + addr);
101 static bfd_reloc_status_type
102 howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
103 ignore_input_section, ignore_bfd)
105 arelent *reloc_entry;
106 struct bfd_symbol *symbol_in;
108 asection *ignore_input_section;
112 bfd_vma addr = reloc_entry->address;
113 long x = bfd_get_8 (abfd, (bfd_byte *)data + addr);
115 HOWTO_PREPARE(relocation, symbol_in);
117 x = (x + relocation + reloc_entry->addend);
119 bfd_put_8 (abfd, x, (bfd_byte *)data + addr);
123 static reloc_howto_type howto_16
124 = NEWHOWTO (howto16_callback, "abs16", 1, FALSE, FALSE);
125 static reloc_howto_type howto_8
126 = NEWHOWTO (howto8_callback, "abs8", 0, FALSE, FALSE);
128 static reloc_howto_type howto_8_FFnn
129 = NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, FALSE, FALSE);
131 static reloc_howto_type howto_8_pcrel
132 = NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, FALSE, TRUE);
134 static reloc_howto_type *
135 local_bfd_reloc_type_lookup (arch, code)
136 const struct bfd_arch_info *arch;
137 bfd_reloc_code_real_type code;
142 case BFD_RELOC_8_FFnn:
143 return &howto_8_FFnn;
146 case BFD_RELOC_8_PCREL:
147 return &howto_8_pcrel;
149 return (reloc_howto_type *)NULL;
154 scan_mach (info, string)
155 const struct bfd_arch_info *info ATTRIBUTE_UNUSED;
158 if (strcmp (string,"h8/500") == 0)
160 if (strcmp (string,"H8/500") == 0)
162 if (strcmp (string,"h8500") == 0)
164 if (strcmp (string,"H8500") == 0)
169 #if 0 /* not used currently */
170 /* This routine is provided two arch_infos and returns whether
171 they'd be compatible */
173 static const bfd_arch_info_type *
175 const bfd_arch_info_type *a;
176 const bfd_arch_info_type *b;
178 if (a->arch != b->arch || a->mach != b->mach)
184 const bfd_arch_info_type bfd_h8500_arch =
186 16, /* 16 bits in a word */
187 24, /* 24 bits in an address */
188 8, /* 8 bits in a byte */
190 0, /* only 1 machine */
191 "h8500", /* arch_name */
192 "h8500", /* printable name */
194 TRUE, /* the default machine */
195 bfd_default_compatible,