2001-02-17 Philip Blundell <philb@gnu.org>
[binutils.git] / bfd / cpu-z8k.c
blob29682c1ec4c117cb0e4521809c955116e96390f0
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.
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. */
21 #include "bfd.h"
22 #include "sysdep.h"
23 #include "libbfd.h"
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)
33 bfd *abfd;
34 arelent *reloc_entry;
35 struct symbol_cache_entry *symbol_in;
36 PTR data;
37 asection *ignore_input_section;
38 bfd *ignore_bfd;
40 long relocation = 0;
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);
49 return bfd_reloc_ok;
52 static bfd_reloc_status_type
53 howto8_callback (abfd, reloc_entry, symbol_in, data,
54 ignore_input_section, ignore_bfd)
55 bfd *abfd;
56 arelent *reloc_entry;
57 struct symbol_cache_entry *symbol_in;
58 PTR data;
59 asection *ignore_input_section;
60 bfd *ignore_bfd;
62 long relocation = 0;
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);
71 return bfd_reloc_ok;
74 static bfd_reloc_status_type
75 howto8_FFnn_callback (abfd, reloc_entry, symbol_in, data,
76 ignore_input_section, ignore_bfd)
77 bfd *abfd;
78 arelent *reloc_entry;
79 struct symbol_cache_entry *symbol_in;
80 PTR data;
81 asection *ignore_input_section;
82 bfd *ignore_bfd;
84 long relocation = 0;
85 bfd_vma addr = reloc_entry->address;
87 long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
88 abort ();
89 HOWTO_PREPARE (relocation, symbol_in);
91 x = (x + relocation + reloc_entry->addend);
93 bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
94 return bfd_reloc_ok;
97 static bfd_reloc_status_type
98 howto8_pcrel_callback (abfd, reloc_entry, symbol_in, data,
99 ignore_input_section, ignore_bfd)
100 bfd *abfd;
101 arelent *reloc_entry;
102 struct symbol_cache_entry *symbol_in;
103 PTR data;
104 asection *ignore_input_section;
105 bfd *ignore_bfd;
107 long relocation = 0;
108 bfd_vma addr = reloc_entry->address;
109 long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
110 abort ();
111 HOWTO_PREPARE (relocation, symbol_in);
113 x = (x + relocation + reloc_entry->addend);
115 bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
116 return bfd_reloc_ok;
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;
135 switch (code)
137 case BFD_RELOC_16:
138 return &howto_16;
139 case BFD_RELOC_8_FFnn:
140 return &howto_8_FFnn;
141 case BFD_RELOC_8:
142 return &howto_8;
143 case BFD_RELOC_8_PCREL:
144 return &howto_8_pcrel;
145 default:
146 return (reloc_howto_type *) NULL;
149 #endif
151 int bfd_default_scan_num_mach ();
153 static boolean
154 scan_mach (info, string)
155 const struct bfd_arch_info *info;
156 const char *string;
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;
166 return false;
169 /* This routine is provided two arch_infos and returns whether
170 they'd be compatible */
172 static const bfd_arch_info_type *
173 compatible (a, b)
174 const bfd_arch_info_type *a;
175 const bfd_arch_info_type *b;
177 if (a->arch != b->arch || a->mach != b->mach)
178 return NULL;
179 return a;
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],