* cpu-pj.c (scan_mach, compatible, arch_info_struct): Remove.
[deliverable/binutils-gdb.git] / bfd / cpu-z8k.c
1 /* BFD library support routines for the Z800n architecture.
2 Copyright 1992, 1993, 1994, 2000, 2001 Free Software Foundation, Inc.
3 Hacked by Steve Chamberlain of Cygnus Support.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
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.
11
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.
16
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. */
20
21 #include "bfd.h"
22 #include "sysdep.h"
23 #include "libbfd.h"
24
25 static const bfd_arch_info_type *compatible
26 PARAMS ((const bfd_arch_info_type *, const bfd_arch_info_type *));
27
28 #if 0 /* not used currently */
29 /*
30 Relocations for the Z8K
31
32 */
33 static bfd_reloc_status_type
34 howto16_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;
45 long x = bfd_get_16 (abfd, (bfd_byte *) data + addr);
46
47 HOWTO_PREPARE (relocation, symbol_in);
48
49 x = (x + relocation + reloc_entry->addend);
50
51 bfd_put_16 (abfd, x, (bfd_byte *) data + addr);
52 return bfd_reloc_ok;
53 }
54
55 static bfd_reloc_status_type
56 howto8_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;
67 long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
68
69 HOWTO_PREPARE (relocation, symbol_in);
70
71 x = (x + relocation + reloc_entry->addend);
72
73 bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
74 return bfd_reloc_ok;
75 }
76
77 static bfd_reloc_status_type
78 howto8_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
90 long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
91 abort ();
92 HOWTO_PREPARE (relocation, symbol_in);
93
94 x = (x + relocation + reloc_entry->addend);
95
96 bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
97 return bfd_reloc_ok;
98 }
99
100 static bfd_reloc_status_type
101 howto8_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;
112 long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
113 abort ();
114 HOWTO_PREPARE (relocation, symbol_in);
115
116 x = (x + relocation + reloc_entry->addend);
117
118 bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
119 return bfd_reloc_ok;
120 }
121
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);
126
127 static reloc_howto_type howto_8_FFnn
128 = NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
129
130 static reloc_howto_type howto_8_pcrel
131 = NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
132
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;
137 {
138 switch (code)
139 {
140 case BFD_RELOC_16:
141 return &howto_16;
142 case BFD_RELOC_8_FFnn:
143 return &howto_8_FFnn;
144 case BFD_RELOC_8:
145 return &howto_8;
146 case BFD_RELOC_8_PCREL:
147 return &howto_8_pcrel;
148 default:
149 return (reloc_howto_type *) NULL;
150 }
151 }
152 #endif
153
154 /* This routine is provided two arch_infos and returns whether
155 they'd be compatible */
156
157 static const bfd_arch_info_type *
158 compatible (a, b)
159 const bfd_arch_info_type *a;
160 const bfd_arch_info_type *b;
161 {
162 if (a->arch != b->arch || a->mach != b->mach)
163 return NULL;
164 return a;
165 }
166
167 static const bfd_arch_info_type arch_info_struct[] =
168 {
169 { 32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, false,
170 compatible, bfd_default_scan, 0 }
171 };
172
173 const bfd_arch_info_type bfd_z8k_arch =
174 {
175 32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, true,
176 compatible, bfd_default_scan, &arch_info_struct[0]
177 };
This page took 0.060547 seconds and 5 git commands to generate.