1 /* BFD library support routines for the Z800n architecture.
2 Copyright 1992, 1993, 1994, 2000 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 #if 0 /* not used currently */
27 Relocations for the Z8K
30 static bfd_reloc_status_type
31 howto16_callback (abfd
, reloc_entry
, symbol_in
, data
,
32 ignore_input_section
, ignore_bfd
)
35 struct symbol_cache_entry
*symbol_in
;
37 asection
*ignore_input_section
;
41 bfd_vma addr
= reloc_entry
->address
;
42 long x
= bfd_get_16 (abfd
, (bfd_byte
*) data
+ addr
);
44 HOWTO_PREPARE (relocation
, symbol_in
);
46 x
= (x
+ relocation
+ reloc_entry
->addend
);
48 bfd_put_16 (abfd
, x
, (bfd_byte
*) data
+ addr
);
52 static bfd_reloc_status_type
53 howto8_callback (abfd
, reloc_entry
, symbol_in
, data
,
54 ignore_input_section
, ignore_bfd
)
57 struct symbol_cache_entry
*symbol_in
;
59 asection
*ignore_input_section
;
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
);
74 static bfd_reloc_status_type
75 howto8_FFnn_callback (abfd
, reloc_entry
, symbol_in
, data
,
76 ignore_input_section
, ignore_bfd
)
79 struct symbol_cache_entry
*symbol_in
;
81 asection
*ignore_input_section
;
85 bfd_vma addr
= reloc_entry
->address
;
87 long x
= bfd_get_8 (abfd
, (bfd_byte
*) data
+ addr
);
89 HOWTO_PREPARE (relocation
, symbol_in
);
91 x
= (x
+ relocation
+ reloc_entry
->addend
);
93 bfd_put_8 (abfd
, x
, (bfd_byte
*) data
+ addr
);
97 static bfd_reloc_status_type
98 howto8_pcrel_callback (abfd
, reloc_entry
, symbol_in
, data
,
99 ignore_input_section
, ignore_bfd
)
101 arelent
*reloc_entry
;
102 struct symbol_cache_entry
*symbol_in
;
104 asection
*ignore_input_section
;
108 bfd_vma addr
= reloc_entry
->address
;
109 long x
= bfd_get_8 (abfd
, (bfd_byte
*) data
+ addr
);
111 HOWTO_PREPARE (relocation
, symbol_in
);
113 x
= (x
+ relocation
+ reloc_entry
->addend
);
115 bfd_put_8 (abfd
, x
, (bfd_byte
*) data
+ addr
);
119 static reloc_howto_type howto_16
120 = NEWHOWTO (howto16_callback
, "abs16", 1, false, false);
121 static reloc_howto_type howto_8
122 = NEWHOWTO (howto8_callback
, "abs8", 0, false, false);
124 static reloc_howto_type howto_8_FFnn
125 = NEWHOWTO (howto8_FFnn_callback
, "ff00+abs8", 0, false, false);
127 static reloc_howto_type howto_8_pcrel
128 = NEWHOWTO (howto8_pcrel_callback
, "pcrel8", 0, false, true);
130 static reloc_howto_type
*
131 local_bfd_reloc_type_lookup (arch
, code
)
132 const struct bfd_arch_info
*arch
;
133 bfd_reloc_code_real_type code
;
139 case BFD_RELOC_8_FFnn
:
140 return &howto_8_FFnn
;
143 case BFD_RELOC_8_PCREL
:
144 return &howto_8_pcrel
;
146 return (reloc_howto_type
*) NULL
;
151 int bfd_default_scan_num_mach ();
154 scan_mach (info
, string
)
155 const struct bfd_arch_info
*info
;
158 if (strcmp (string
, "z8001") == 0 || strcmp (string
, "z8k") == 0)
160 return bfd_mach_z8001
== info
->mach
;
162 if (strcmp (string
, "z8002") == 0)
164 return bfd_mach_z8002
== info
->mach
;
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
)
182 static const bfd_arch_info_type arch_info_struct
[] =
184 {32, 32, 8, bfd_arch_z8k
, bfd_mach_z8001
, "z8k", "z8001", 1, false, compatible
, scan_mach
, 0,},
187 const bfd_arch_info_type bfd_z8k_arch
=
189 32, 16, 8, bfd_arch_z8k
, bfd_mach_z8002
, "z8k", "z8002", 1, true, compatible
, scan_mach
, &arch_info_struct
[0],