Touches most files in bfd/, so likely will be blamed for everything..
[deliverable/binutils-gdb.git] / bfd / cpu-h8500.c
CommitLineData
252b5132 1/* BFD library support routines for the H8/500 architecture.
dc810e39 2 Copyright 1993, 1995, 2000, 2001 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
dc810e39 25static boolean scan_mach PARAMS ((const struct bfd_arch_info *, const char *));
252b5132 26
dc810e39 27#if 0
71f6b586 28/*
252b5132
RH
29Relocations for the Z8K
30
31*/
71f6b586 32static bfd_reloc_status_type
252b5132
RH
33howto16_callback (abfd, reloc_entry, symbol_in, data,
34 ignore_input_section, ignore_bfd)
35 bfd *abfd;
36 arelent *reloc_entry;
37 struct symbol_cache_entry *symbol_in;
38 PTR data;
39 asection *ignore_input_section;
40 bfd *ignore_bfd;
41{
42 long relocation = 0;
43 bfd_vma addr = reloc_entry->address;
6e301b2b 44 long x = bfd_get_16 (abfd, (bfd_byte *)data + addr);
252b5132
RH
45
46 HOWTO_PREPARE(relocation, symbol_in);
47
48 x = (x + relocation + reloc_entry->addend);
49
6e301b2b 50 bfd_put_16 (abfd, x, (bfd_byte *)data + addr);
252b5132
RH
51 return bfd_reloc_ok;
52}
53
71f6b586 54static bfd_reloc_status_type
252b5132
RH
55howto8_callback (abfd, reloc_entry, symbol_in, data,
56 ignore_input_section, ignore_bfd)
57 bfd *abfd;
58 arelent *reloc_entry;
59 struct symbol_cache_entry *symbol_in;
60 PTR data;
61 asection *ignore_input_section;
62 bfd *ignore_bfd;
63{
64 long relocation = 0;
65 bfd_vma addr = reloc_entry->address;
6e301b2b 66 long x = bfd_get_8 (abfd, (bfd_byte *)data + addr);
252b5132
RH
67
68 HOWTO_PREPARE(relocation, symbol_in);
69
70 x = (x + relocation + reloc_entry->addend);
71
6e301b2b 72 bfd_put_8 (abfd, x, (bfd_byte *)data + addr);
252b5132
RH
73 return bfd_reloc_ok;
74}
75
71f6b586 76static bfd_reloc_status_type
252b5132
RH
77howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
78 ignore_input_section, ignore_bfd)
79 bfd *abfd;
80 arelent *reloc_entry;
81 struct symbol_cache_entry *symbol_in;
82 PTR data;
83 asection *ignore_input_section;
84 bfd *ignore_bfd;
85{
86 long relocation = 0;
87 bfd_vma addr = reloc_entry->address;
88
6e301b2b 89 long x = bfd_get_8 (abfd, (bfd_byte *)data + addr);
71f6b586 90 abort ();
252b5132
RH
91 HOWTO_PREPARE(relocation, symbol_in);
92
93 x = (x + relocation + reloc_entry->addend);
94
6e301b2b 95 bfd_put_8 (abfd, x, (bfd_byte *)data + addr);
252b5132
RH
96 return bfd_reloc_ok;
97}
98
71f6b586 99static bfd_reloc_status_type
252b5132
RH
100howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
101 ignore_input_section, ignore_bfd)
102 bfd *abfd;
103 arelent *reloc_entry;
104 struct symbol_cache_entry *symbol_in;
105 PTR data;
106 asection *ignore_input_section;
107 bfd *ignore_bfd;
108{
109 long relocation = 0;
110 bfd_vma addr = reloc_entry->address;
6e301b2b 111 long x = bfd_get_8 (abfd, (bfd_byte *)data + addr);
71f6b586 112 abort ();
252b5132
RH
113 HOWTO_PREPARE(relocation, symbol_in);
114
115 x = (x + relocation + reloc_entry->addend);
116
6e301b2b 117 bfd_put_8 (abfd, x, (bfd_byte *)data + addr);
252b5132
RH
118 return bfd_reloc_ok;
119}
120
252b5132
RH
121static reloc_howto_type howto_16
122 = NEWHOWTO(howto16_callback,"abs16",1,false,false);
123static reloc_howto_type howto_8
124 = NEWHOWTO(howto8_callback,"abs8",0,false,false);
125
126static reloc_howto_type howto_8_FFnn
127 = NEWHOWTO(howto8_FFnn_callback,"ff00+abs8",0,false,false);
128
129static reloc_howto_type howto_8_pcrel
130 = NEWHOWTO(howto8_pcrel_callback,"pcrel8",0,false,true);
131
252b5132
RH
132static reloc_howto_type *
133local_bfd_reloc_type_lookup (arch, code)
134 const struct bfd_arch_info *arch;
135 bfd_reloc_code_real_type code;
136{
137 switch (code) {
138 case BFD_RELOC_16:
139 return &howto_16;
140 case BFD_RELOC_8_FFnn:
141 return &howto_8_FFnn;
142 case BFD_RELOC_8:
143 return &howto_8;
144 case BFD_RELOC_8_PCREL:
145 return &howto_8_pcrel;
146 }
147 return (reloc_howto_type *)NULL;
148}
149#endif
150
71f6b586 151static boolean
252b5132 152scan_mach (info, string)
5f771d47 153 const struct bfd_arch_info *info ATTRIBUTE_UNUSED;
252b5132
RH
154 const char *string;
155{
156 if (strcmp(string,"h8/500") == 0) return true;
157 if (strcmp(string,"H8/500") == 0) return true;
158 if (strcmp(string,"h8500") == 0) return true;
159 if (strcmp(string,"H8500") == 0) return true;
160 return false;
161}
162
252b5132
RH
163#if 0 /* not used currently */
164/* This routine is provided two arch_infos and returns whether
165 they'd be compatible */
166
167static const bfd_arch_info_type *
168compatible (a,b)
169 const bfd_arch_info_type *a;
170 const bfd_arch_info_type *b;
171{
172 if (a->arch != b->arch || a->mach != b->mach)
173 return NULL;
174 return a;
175}
176#endif
177
178const bfd_arch_info_type bfd_h8500_arch =
179{
180 16, /* 16 bits in a word */
181 24, /* 24 bits in an address */
182 8, /* 8 bits in a byte */
183 bfd_arch_h8500,
184 0, /* only 1 machine */
185 "h8500", /* arch_name */
186 "h8500", /* printable name */
187 1,
188 true, /* the default machine */
189 bfd_default_compatible,
190 scan_mach,
191 0,
192};
This page took 0.099004 seconds and 4 git commands to generate.