* configure.in (host==solaris): Pass only the first word of $CC
[deliverable/binutils-gdb.git] / bfd / cpu-z8k.c
1 /* BFD library support routines for the Z800n architecture.
2 Copyright (C) 1992 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
20
21 #include "bfd.h"
22 #include "sysdep.h"
23 #include "libbfd.h"
24
25
26 /*
27 Relocations for the Z8K
28
29 */
30 static bfd_reloc_status_type
31 DEFUN(howto16_callback,(abfd, reloc_entry, symbol_in, data,
32 ignore_input_section, ignore_bfd),
33 bfd *abfd AND
34 arelent *reloc_entry AND
35 struct symbol_cache_entry *symbol_in AND
36 PTR data AND
37 asection *ignore_input_section AND
38 bfd *ignore_bfd)
39 {
40 long relocation = 0;
41 bfd_vma addr = reloc_entry->address;
42 long x = bfd_get_16(abfd, (bfd_byte *)data + addr);
43
44 HOWTO_PREPARE(relocation, symbol_in);
45
46 x = (x + relocation + reloc_entry->addend);
47
48 bfd_put_16(abfd, x, (bfd_byte *)data + addr);
49 return bfd_reloc_ok;
50 }
51
52
53 static bfd_reloc_status_type
54 DEFUN(howto8_callback,(abfd, reloc_entry, symbol_in, data,
55 ignore_input_section, ignore_bfd),
56 bfd *abfd AND
57 arelent *reloc_entry AND
58 struct symbol_cache_entry *symbol_in AND
59 PTR data AND
60 asection *ignore_input_section AND
61 bfd *ignore_bfd)
62 {
63 long relocation = 0;
64 bfd_vma addr = reloc_entry->address;
65 long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
66
67 HOWTO_PREPARE(relocation, symbol_in);
68
69 x = (x + relocation + reloc_entry->addend);
70
71 bfd_put_8(abfd, x, (bfd_byte *)data + addr);
72 return bfd_reloc_ok;
73 }
74
75
76 static bfd_reloc_status_type
77 DEFUN(howto8_FFnn_callback,(abfd, reloc_entry, symbol_in, data,
78 ignore_input_section, ignore_bfd),
79 bfd *abfd AND
80 arelent *reloc_entry AND
81 struct symbol_cache_entry *symbol_in AND
82 PTR data AND
83 asection *ignore_input_section AND
84 bfd *ignore_bfd)
85 {
86 long relocation = 0;
87 bfd_vma addr = reloc_entry->address;
88
89 long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
90 abort();
91 HOWTO_PREPARE(relocation, symbol_in);
92
93 x = (x + relocation + reloc_entry->addend);
94
95 bfd_put_8(abfd, x, (bfd_byte *)data + addr);
96 return bfd_reloc_ok;
97 }
98
99 static bfd_reloc_status_type
100 DEFUN(howto8_pcrel_callback,(abfd, reloc_entry, symbol_in, data,
101 ignore_input_section, ignore_bfd),
102 bfd *abfd AND
103 arelent *reloc_entry AND
104 struct symbol_cache_entry *symbol_in AND
105 PTR data AND
106 asection *ignore_input_section AND
107 bfd *ignore_bfd)
108 {
109 long relocation = 0;
110 bfd_vma addr = reloc_entry->address;
111 long x = bfd_get_8(abfd, (bfd_byte *)data + addr);
112 abort();
113 HOWTO_PREPARE(relocation, symbol_in);
114
115 x = (x + relocation + reloc_entry->addend);
116
117 bfd_put_8(abfd, x, (bfd_byte *)data + addr);
118 return bfd_reloc_ok;
119 }
120
121
122
123 static reloc_howto_type howto_16
124 = NEWHOWTO(howto16_callback,"abs16",1,false,false);
125 static reloc_howto_type howto_8
126 = NEWHOWTO(howto8_callback,"abs8",0,false,false);
127
128 static reloc_howto_type howto_8_FFnn
129 = NEWHOWTO(howto8_FFnn_callback,"ff00+abs8",0,false,false);
130
131 static reloc_howto_type howto_8_pcrel
132 = NEWHOWTO(howto8_pcrel_callback,"pcrel8",0,false,true);
133
134
135 static CONST struct reloc_howto_struct *
136 DEFUN(local_bfd_reloc_type_lookup,(arch, code),
137 CONST struct bfd_arch_info *arch AND
138 bfd_reloc_code_real_type code)
139 {
140 switch (code) {
141 case BFD_RELOC_16:
142 return &howto_16;
143 case BFD_RELOC_8_FFnn:
144 return &howto_8_FFnn;
145 case BFD_RELOC_8:
146 return &howto_8;
147 case BFD_RELOC_8_PCREL:
148 return &howto_8_pcrel;
149 }
150 return (reloc_howto_type *)NULL;
151 }
152
153 int bfd_default_scan_num_mach();
154
155 static boolean
156 DEFUN(scan_mach,(info, string),
157 CONST struct bfd_arch_info *info AND
158 CONST char *string)
159 {
160 if (strcmp(string,"z8001") == 0 || strcmp(string,"z8k") == 0)
161 {
162 return bfd_mach_z8001 == info->mach;
163 }
164 if (strcmp(string,"z8002") == 0)
165 {
166 return bfd_mach_z8002 == info->mach;
167 }
168 return false;
169 }
170
171
172 /* This routine is provided two arch_infos and returns whether
173 they'd be compatible */
174
175 CONST bfd_arch_info_type *
176 DEFUN(compatible,(a,b),
177 CONST bfd_arch_info_type *a AND
178 CONST bfd_arch_info_type *b)
179 {
180 if (a->arch != b->arch || a->mach != b->mach)
181 return NULL;
182 return a;
183 }
184
185
186 static bfd_arch_info_type arch_info_struct[] =
187 {
188 { 32, 16, 8,bfd_arch_z8k, bfd_mach_z8002,"z8k","z8002",1,0,compatible,scan_mach,0,},
189 { 32, 32, 8,bfd_arch_z8k, bfd_mach_z8001,"z8k","z8001",1,1,compatible,scan_mach,0,},
190 };
191
192
193
194 void
195 DEFUN_VOID(bfd_z8k_arch)
196 {
197 bfd_arch_linkin(&arch_info_struct[0]);
198 bfd_arch_linkin(&arch_info_struct[1]);
199 }
200
201
This page took 0.035367 seconds and 4 git commands to generate.