]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - bfd/cpu-h8500.c
s/boolean/bfd_boolean/ s/true/TRUE/ s/false/FALSE/. Simplify
[thirdparty/binutils-gdb.git] / bfd / cpu-h8500.c
CommitLineData
252b5132 1/* BFD library support routines for the H8/500 architecture.
b34976b6 2 Copyright 1993, 1995, 2000, 2001, 2002 Free Software Foundation, Inc.
252b5132
RH
3 Hacked by Steve Chamberlain of Cygnus Support.
4
5This file is part of BFD, the Binary File Descriptor library.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21#include "bfd.h"
22#include "sysdep.h"
23#include "libbfd.h"
24
b34976b6
AM
25static bfd_boolean scan_mach
26 PARAMS ((const struct bfd_arch_info *, const char *));
252b5132 27
dc810e39 28#if 0
71f6b586 29/*
252b5132
RH
30Relocations for the Z8K
31
32*/
71f6b586 33static bfd_reloc_status_type
252b5132
RH
34howto16_callback (abfd, reloc_entry, symbol_in, data,
35 ignore_input_section, ignore_bfd)
36 bfd *abfd;
37 arelent *reloc_entry;
38 struct symbol_cache_entry *symbol_in;
39 PTR data;
40 asection *ignore_input_section;
41 bfd *ignore_bfd;
42{
43 long relocation = 0;
44 bfd_vma addr = reloc_entry->address;
6e301b2b 45 long x = bfd_get_16 (abfd, (bfd_byte *)data + addr);
252b5132
RH
46
47 HOWTO_PREPARE(relocation, symbol_in);
48
49 x = (x + relocation + reloc_entry->addend);
50
6e301b2b 51 bfd_put_16 (abfd, x, (bfd_byte *)data + addr);
252b5132
RH
52 return bfd_reloc_ok;
53}
54
71f6b586 55static bfd_reloc_status_type
252b5132
RH
56howto8_callback (abfd, reloc_entry, symbol_in, data,
57 ignore_input_section, ignore_bfd)
58 bfd *abfd;
59 arelent *reloc_entry;
60 struct symbol_cache_entry *symbol_in;
61 PTR data;
62 asection *ignore_input_section;
63 bfd *ignore_bfd;
64{
65 long relocation = 0;
66 bfd_vma addr = reloc_entry->address;
6e301b2b 67 long x = bfd_get_8 (abfd, (bfd_byte *)data + addr);
252b5132
RH
68
69 HOWTO_PREPARE(relocation, symbol_in);
70
71 x = (x + relocation + reloc_entry->addend);
72
6e301b2b 73 bfd_put_8 (abfd, x, (bfd_byte *)data + addr);
252b5132
RH
74 return bfd_reloc_ok;
75}
76
71f6b586 77static bfd_reloc_status_type
252b5132
RH
78howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
79 ignore_input_section, ignore_bfd)
80 bfd *abfd;
81 arelent *reloc_entry;
82 struct symbol_cache_entry *symbol_in;
83 PTR data;
84 asection *ignore_input_section;
85 bfd *ignore_bfd;
86{
87 long relocation = 0;
88 bfd_vma addr = reloc_entry->address;
89
6e301b2b 90 long x = bfd_get_8 (abfd, (bfd_byte *)data + addr);
71f6b586 91 abort ();
252b5132
RH
92 HOWTO_PREPARE(relocation, symbol_in);
93
94 x = (x + relocation + reloc_entry->addend);
95
6e301b2b 96 bfd_put_8 (abfd, x, (bfd_byte *)data + addr);
252b5132
RH
97 return bfd_reloc_ok;
98}
99
71f6b586 100static bfd_reloc_status_type
252b5132
RH
101howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
102 ignore_input_section, ignore_bfd)
103 bfd *abfd;
104 arelent *reloc_entry;
105 struct symbol_cache_entry *symbol_in;
106 PTR data;
107 asection *ignore_input_section;
108 bfd *ignore_bfd;
109{
110 long relocation = 0;
111 bfd_vma addr = reloc_entry->address;
6e301b2b 112 long x = bfd_get_8 (abfd, (bfd_byte *)data + addr);
71f6b586 113 abort ();
252b5132
RH
114 HOWTO_PREPARE(relocation, symbol_in);
115
116 x = (x + relocation + reloc_entry->addend);
117
6e301b2b 118 bfd_put_8 (abfd, x, (bfd_byte *)data + addr);
252b5132
RH
119 return bfd_reloc_ok;
120}
121
252b5132 122static reloc_howto_type howto_16
b34976b6 123 = NEWHOWTO (howto16_callback, "abs16", 1, FALSE, FALSE);
252b5132 124static reloc_howto_type howto_8
b34976b6 125 = NEWHOWTO (howto8_callback, "abs8", 0, FALSE, FALSE);
252b5132
RH
126
127static reloc_howto_type howto_8_FFnn
b34976b6 128 = NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, FALSE, FALSE);
252b5132
RH
129
130static reloc_howto_type howto_8_pcrel
b34976b6 131 = NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, FALSE, TRUE);
252b5132 132
252b5132
RH
133static reloc_howto_type *
134local_bfd_reloc_type_lookup (arch, code)
135 const struct bfd_arch_info *arch;
136 bfd_reloc_code_real_type code;
137{
138 switch (code) {
139 case BFD_RELOC_16:
140 return &howto_16;
141 case BFD_RELOC_8_FFnn:
142 return &howto_8_FFnn;
143 case BFD_RELOC_8:
144 return &howto_8;
145 case BFD_RELOC_8_PCREL:
146 return &howto_8_pcrel;
147 }
148 return (reloc_howto_type *)NULL;
149}
150#endif
151
b34976b6 152static bfd_boolean
252b5132 153scan_mach (info, string)
5f771d47 154 const struct bfd_arch_info *info ATTRIBUTE_UNUSED;
252b5132
RH
155 const char *string;
156{
b34976b6
AM
157 if (strcmp (string,"h8/500") == 0)
158 return TRUE;
159 if (strcmp (string,"H8/500") == 0)
160 return TRUE;
161 if (strcmp (string,"h8500") == 0)
162 return TRUE;
163 if (strcmp (string,"H8500") == 0)
164 return TRUE;
165 return FALSE;
252b5132
RH
166}
167
252b5132
RH
168#if 0 /* not used currently */
169/* This routine is provided two arch_infos and returns whether
170 they'd be compatible */
171
172static const bfd_arch_info_type *
173compatible (a,b)
174 const bfd_arch_info_type *a;
175 const bfd_arch_info_type *b;
176{
177 if (a->arch != b->arch || a->mach != b->mach)
178 return NULL;
179 return a;
180}
181#endif
182
183const bfd_arch_info_type bfd_h8500_arch =
184{
185 16, /* 16 bits in a word */
186 24, /* 24 bits in an address */
187 8, /* 8 bits in a byte */
188 bfd_arch_h8500,
189 0, /* only 1 machine */
190 "h8500", /* arch_name */
191 "h8500", /* printable name */
192 1,
b34976b6 193 TRUE, /* the default machine */
252b5132
RH
194 bfd_default_compatible,
195 scan_mach,
196 0,
197};