1 /* BFD library support routines for the H8/500 architecture.
2 Copyright 1993, 1995, 2000, 2001, 2002 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
25 static bfd_boolean scan_mach
26 PARAMS ((const struct bfd_arch_info
*, const char *));
30 Relocations for the Z8K
33 static bfd_reloc_status_type
34 howto16_callback (abfd
, reloc_entry
, symbol_in
, data
,
35 ignore_input_section
, ignore_bfd
)
38 struct symbol_cache_entry
*symbol_in
;
40 asection
*ignore_input_section
;
44 bfd_vma addr
= reloc_entry
->address
;
45 long x
= bfd_get_16 (abfd
, (bfd_byte
*)data
+ addr
);
47 HOWTO_PREPARE(relocation
, symbol_in
);
49 x
= (x
+ relocation
+ reloc_entry
->addend
);
51 bfd_put_16 (abfd
, x
, (bfd_byte
*)data
+ addr
);
55 static bfd_reloc_status_type
56 howto8_callback (abfd
, reloc_entry
, symbol_in
, data
,
57 ignore_input_section
, ignore_bfd
)
60 struct symbol_cache_entry
*symbol_in
;
62 asection
*ignore_input_section
;
66 bfd_vma addr
= reloc_entry
->address
;
67 long x
= bfd_get_8 (abfd
, (bfd_byte
*)data
+ addr
);
69 HOWTO_PREPARE(relocation
, symbol_in
);
71 x
= (x
+ relocation
+ reloc_entry
->addend
);
73 bfd_put_8 (abfd
, x
, (bfd_byte
*)data
+ addr
);
77 static bfd_reloc_status_type
78 howto8_FFnn_callback (abfd
, reloc_entry
, symbol_in
, data
,
79 ignore_input_section
, ignore_bfd
)
82 struct symbol_cache_entry
*symbol_in
;
84 asection
*ignore_input_section
;
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 howto8_pcrel_callback (abfd
, reloc_entry
, symbol_in
, data
,
102 ignore_input_section
, ignore_bfd
)
104 arelent
*reloc_entry
;
105 struct symbol_cache_entry
*symbol_in
;
107 asection
*ignore_input_section
;
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
);
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
);
133 static reloc_howto_type
*
134 local_bfd_reloc_type_lookup (arch
, code
)
135 const struct bfd_arch_info
*arch
;
136 bfd_reloc_code_real_type code
;
141 case BFD_RELOC_8_FFnn
:
142 return &howto_8_FFnn
;
145 case BFD_RELOC_8_PCREL
:
146 return &howto_8_pcrel
;
148 return (reloc_howto_type
*)NULL
;
153 scan_mach (info
, string
)
154 const struct bfd_arch_info
*info ATTRIBUTE_UNUSED
;
157 if (strcmp (string
,"h8/500") == 0)
159 if (strcmp (string
,"H8/500") == 0)
161 if (strcmp (string
,"h8500") == 0)
163 if (strcmp (string
,"H8500") == 0)
168 #if 0 /* not used currently */
169 /* This routine is provided two arch_infos and returns whether
170 they'd be compatible */
172 static const bfd_arch_info_type
*
174 const bfd_arch_info_type
*a
;
175 const bfd_arch_info_type
*b
;
177 if (a
->arch
!= b
->arch
|| a
->mach
!= b
->mach
)
183 const bfd_arch_info_type bfd_h8500_arch
=
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 "h8500", /* arch_name */
191 "h8500", /* printable name */
193 TRUE
, /* the default machine */
194 bfd_default_compatible
,