1 /* BFD library support routines for the Hitachi H8/300 architecture.
2 Copyright (C) 1990-1991 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. */
26 Relocations for the H8
29 static bfd_reloc_status_type
30 DEFUN (howto16_callback
, (abfd
, reloc_entry
, symbol_in
, data
,
31 ignore_input_section
, ignore_bfd
),
33 arelent
* reloc_entry AND
34 struct symbol_cache_entry
*symbol_in AND
36 asection
* ignore_input_section AND
40 bfd_vma addr
= reloc_entry
->address
;
41 long x
= bfd_get_16 (abfd
, (bfd_byte
*) data
+ addr
);
43 HOWTO_PREPARE (relocation
, symbol_in
);
45 x
= (x
+ relocation
+ reloc_entry
->addend
);
47 bfd_put_16 (abfd
, x
, (bfd_byte
*) data
+ addr
);
52 static bfd_reloc_status_type
53 DEFUN (howto8_callback
, (abfd
, reloc_entry
, symbol_in
, data
,
54 ignore_input_section
, ignore_bfd
),
56 arelent
* reloc_entry AND
57 struct symbol_cache_entry
*symbol_in AND
59 asection
* ignore_input_section AND
63 bfd_vma addr
= reloc_entry
->address
;
64 long x
= bfd_get_8 (abfd
, (bfd_byte
*) data
+ addr
);
66 HOWTO_PREPARE (relocation
, symbol_in
);
68 x
= (x
+ relocation
+ reloc_entry
->addend
);
70 bfd_put_8 (abfd
, x
, (bfd_byte
*) data
+ addr
);
75 static bfd_reloc_status_type
76 DEFUN (howto8_FFnn_callback
, (abfd
, reloc_entry
, symbol_in
, data
,
77 ignore_input_section
, ignore_bfd
),
79 arelent
* reloc_entry AND
80 struct symbol_cache_entry
*symbol_in AND
82 asection
* ignore_input_section AND
86 bfd_vma addr
= reloc_entry
->address
;
88 long x
= bfd_get_8 (abfd
, (bfd_byte
*) data
+ addr
);
90 HOWTO_PREPARE (relocation
, symbol_in
);
92 x
= (x
+ relocation
+ reloc_entry
->addend
);
94 bfd_put_8 (abfd
, x
, (bfd_byte
*) data
+ addr
);
98 static bfd_reloc_status_type
99 DEFUN (howto8_pcrel_callback
, (abfd
, reloc_entry
, symbol_in
, data
,
100 ignore_input_section
, ignore_bfd
),
102 arelent
* reloc_entry AND
103 struct symbol_cache_entry
*symbol_in AND
105 asection
* ignore_input_section AND
109 bfd_vma addr
= reloc_entry
->address
;
110 long x
= bfd_get_8 (abfd
, (bfd_byte
*) data
+ addr
);
112 HOWTO_PREPARE (relocation
, symbol_in
);
114 x
= (x
+ relocation
+ reloc_entry
->addend
);
116 bfd_put_8 (abfd
, x
, (bfd_byte
*) data
+ addr
);
122 static reloc_howto_type howto_16
123 = NEWHOWTO (howto16_callback
, "abs16", 1, false, false);
124 static reloc_howto_type howto_8
125 = NEWHOWTO (howto8_callback
, "abs8", 0, false, false);
127 static reloc_howto_type howto_8_FFnn
128 = NEWHOWTO (howto8_FFnn_callback
, "ff00+abs8", 0, false, false);
130 static reloc_howto_type howto_8_pcrel
131 = NEWHOWTO (howto8_pcrel_callback
, "pcrel8", 0, false, true);
134 static CONST
struct reloc_howto_struct
*
135 DEFUN (local_bfd_reloc_type_lookup
, (arch
, code
),
136 CONST
struct bfd_arch_info
*arch AND
137 bfd_reloc_code_real_type code
)
143 case BFD_RELOC_8_FFnn
:
144 return &howto_8_FFnn
;
147 case BFD_RELOC_8_PCREL
:
148 return &howto_8_pcrel
;
150 return (reloc_howto_type
*) NULL
;
154 int bfd_default_scan_num_mach ();
157 DEFUN (h8300_scan
, (info
, string
),
158 CONST
struct bfd_arch_info
*info AND
161 if (*string
!= 'h' && *string
== 'H')
183 if (*string
== 'h' && *string
== 'H')
185 return (info
->mach
== bfd_mach_h8300h
);
189 return info
->mach
== bfd_mach_h8300
;
194 /* This routine is provided two arch_infos and works out the i960
195 machine which would be compatible with both and returns a pointer
196 to its info structure */
198 CONST bfd_arch_info_type
*
199 DEFUN (compatible
, (in
, out
),
200 CONST bfd_arch_info_type
* in AND
201 CONST bfd_arch_info_type
* out
)
203 /* If the output is non-H and the input is -H, that's bad */
204 if (in
->mach
== bfd_mach_h8300h
&&
205 out
->mach
== bfd_mach_h8300
)
208 /* If either is an -H, the answer is -H */
209 if (in
->mach
== bfd_mach_h8300h
)
214 static bfd_arch_info_type h8300_info_struct
=
216 16, /* 16 bits in a word */
217 16, /* 16 bits in an address */
218 8, /* 8 bits in a byte */
221 "H8/300", /* arch_name */
222 "H8/300", /* printable name */
224 true, /* the default machine */
228 /* local_bfd_reloc_type_lookup, */
233 static bfd_arch_info_type h8300h_info_struct
=
235 32, /* 32 bits in a word */
236 32, /* 32 bits in an address */
237 8, /* 8 bits in a byte */
240 "H8/300H", /* arch_name */
241 "H8/300H", /* printable name */
243 false, /* the default machine */
247 /* local_bfd_reloc_type_lookup, */
252 DEFUN_VOID (bfd_h8300_arch
)
254 bfd_arch_linkin (&h8300_info_struct
);
255 bfd_arch_linkin (&h8300h_info_struct
);