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.
|
---|
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 | #if 0 /* not used currently */
|
---|
26 | /*
|
---|
27 | Relocations for the Z8K
|
---|
28 |
|
---|
29 | */
|
---|
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;
|
---|
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 | 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;
|
---|
61 | {
|
---|
62 | long relocation = 0;
|
---|
63 | bfd_vma addr = reloc_entry->address;
|
---|
64 | long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
---|
65 |
|
---|
66 | HOWTO_PREPARE (relocation, symbol_in);
|
---|
67 |
|
---|
68 | x = (x + relocation + reloc_entry->addend);
|
---|
69 |
|
---|
70 | bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
---|
71 | return bfd_reloc_ok;
|
---|
72 | }
|
---|
73 |
|
---|
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;
|
---|
83 | {
|
---|
84 | long relocation = 0;
|
---|
85 | bfd_vma addr = reloc_entry->address;
|
---|
86 |
|
---|
87 | long x = bfd_get_8 (abfd, (bfd_byte *) data + addr);
|
---|
88 | abort ();
|
---|
89 | HOWTO_PREPARE (relocation, symbol_in);
|
---|
90 |
|
---|
91 | x = (x + relocation + reloc_entry->addend);
|
---|
92 |
|
---|
93 | bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
---|
94 | return bfd_reloc_ok;
|
---|
95 | }
|
---|
96 |
|
---|
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;
|
---|
106 | {
|
---|
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);
|
---|
112 |
|
---|
113 | x = (x + relocation + reloc_entry->addend);
|
---|
114 |
|
---|
115 | bfd_put_8 (abfd, x, (bfd_byte *) data + addr);
|
---|
116 | return bfd_reloc_ok;
|
---|
117 | }
|
---|
118 |
|
---|
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);
|
---|
123 |
|
---|
124 | static reloc_howto_type howto_8_FFnn
|
---|
125 | = NEWHOWTO (howto8_FFnn_callback, "ff00+abs8", 0, false, false);
|
---|
126 |
|
---|
127 | static reloc_howto_type howto_8_pcrel
|
---|
128 | = NEWHOWTO (howto8_pcrel_callback, "pcrel8", 0, false, true);
|
---|
129 |
|
---|
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;
|
---|
134 | {
|
---|
135 | switch (code)
|
---|
136 | {
|
---|
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;
|
---|
147 | }
|
---|
148 | }
|
---|
149 | #endif
|
---|
150 |
|
---|
151 | int bfd_default_scan_num_mach ();
|
---|
152 |
|
---|
153 | static boolean
|
---|
154 | scan_mach (info, string)
|
---|
155 | const struct bfd_arch_info *info;
|
---|
156 | const char *string;
|
---|
157 | {
|
---|
158 | if (strcmp (string, "z8001") == 0 || strcmp (string, "z8k") == 0)
|
---|
159 | {
|
---|
160 | return bfd_mach_z8001 == info->mach;
|
---|
161 | }
|
---|
162 | if (strcmp (string, "z8002") == 0)
|
---|
163 | {
|
---|
164 | return bfd_mach_z8002 == info->mach;
|
---|
165 | }
|
---|
166 | return false;
|
---|
167 | }
|
---|
168 |
|
---|
169 | /* This routine is provided two arch_infos and returns whether
|
---|
170 | they'd be compatible */
|
---|
171 |
|
---|
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;
|
---|
176 | {
|
---|
177 | if (a->arch != b->arch || a->mach != b->mach)
|
---|
178 | return NULL;
|
---|
179 | return a;
|
---|
180 | }
|
---|
181 |
|
---|
182 | static const bfd_arch_info_type arch_info_struct[] =
|
---|
183 | {
|
---|
184 | {32, 32, 8, bfd_arch_z8k, bfd_mach_z8001, "z8k", "z8001", 1, false, compatible, scan_mach, 0,},
|
---|
185 | };
|
---|
186 |
|
---|
187 | const bfd_arch_info_type bfd_z8k_arch =
|
---|
188 | {
|
---|
189 | 32, 16, 8, bfd_arch_z8k, bfd_mach_z8002, "z8k", "z8002", 1, true, compatible, scan_mach, &arch_info_struct[0],
|
---|
190 | };
|
---|