Added ansidecl.h
[deliverable/binutils-gdb.git] / bfd / coff-i960.c
1 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
2
3 This file is part of BFD, the Binary File Diddler.
4
5 BFD is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 1, or (at your option)
8 any later version.
9
10 BFD is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with BFD; see the file COPYING. If not, write to
17 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
18
19 /* $Id$ */
20
21 #define I960 1
22 #include <ansidecl.h>
23 #include "sysdep.h"
24 #include "bfd.h"
25 #include "libbfd.h"
26 #include "libcoff.h" /* to allow easier abstraction-breaking */
27
28
29
30 #include "intel-coff.h"
31
32 #define CALLS 0x66003800 /* Template for 'calls' instruction */
33 #define BAL 0x0b000000 /* Template for 'bal' instruction */
34 #define BAL_MASK 0x00ffffff
35
36 static bfd_reloc_status_enum_type
37 optcall_callback(abfd, reloc_entry, symbol_in, data, ignore_input_section)
38 bfd *abfd;
39 arelent *reloc_entry;
40 asymbol *symbol_in;
41 unsigned char *data;
42 asection *ignore_input_section;
43 {
44 /* This item has already been relocated correctly, but we may be
45 * able to patch in yet better code - done by digging out the
46 * correct info on this symbol */
47 bfd_reloc_status_enum_type result;
48 coff_symbol_type *cs = coffsymbol(symbol_in);
49
50 /* So the target symbol has to be off coff type, and the symbol
51 has to have the correct native information within it
52 */
53 if ((cs->symbol.the_bfd->xvec->flavour != bfd_target_coff_flavour_enum)
54 || (cs->native == (struct syment *)NULL)) {
55 /* This is interesting, consider the case where we're outputting */
56 /* coff from a mix n match input, linking from coff to a symbol */
57 /* defined in a bout file will cause this match to be true. Should */
58 /* I complain ? - This will only work if the bout symbol is non */
59 /* leaf. */
60 result = bfd_reloc_dangerous;
61
62 }
63 else {
64 switch (cs->native->n_sclass)
65 {
66 case C_LEAFSTAT:
67 case C_LEAFEXT:
68 /* This is a call to a leaf procedure, replace instruction with a bal
69 to the correct location */
70 {
71 union auxent *aux = (union auxent *)(cs->native+2);
72 int word = bfd_getlong(abfd, data + reloc_entry->address);
73 BFD_ASSERT(cs->native->n_numaux==2);
74 /* We replace the original call instruction with a bal to */
75 /* the bal entry point - the offset of which is described in the */
76 /* 2nd auxent of the original symbol. We keep the native sym and */
77 /* auxents untouched, so the delta between the two is the */
78 /* offset of the bal entry point */
79 word = ((word + (aux->x_bal.x_balntry - cs->native->n_value))
80 & BAL_MASK) | BAL;
81 bfd_putlong(abfd, word, data+reloc_entry->address);
82 }
83 result = bfd_reloc_ok;
84 break;
85 case C_SCALL:
86 {
87 /* This is a call to a system call, replace with a calls to # */
88 BFD_ASSERT(0);
89 }
90 break;
91 default:
92 result = bfd_reloc_ok;
93 break;
94 }
95 }
96 return result;
97 }
98
99
100
101 static reloc_howto_type howto_table[] =
102 {
103 {0},
104 {1},
105 {2},
106 {3},
107 {4},
108 {5},
109 {6},
110 {7},
111 {8},
112 {9},
113 {10},
114 {11},
115 {12},
116 {13},
117 {14},
118 {15},
119 {16},
120
121 { (unsigned int) R_RELLONG, 0, 2, 32,false, 0, true, true, 0,"rellong", true, 0xffffffff},
122 {18},
123 {19},
124 {20},
125 {21},
126 {22},
127 {23},
128 {24},
129
130 { R_IPRMED, 0, 2, 24,true,0, true, true,0,"iprmed ", true, 0x00ffffff},
131 {26},
132
133 { R_OPTCALL, 0,2,24,true,0, true, true, optcall_callback, "optcall", true, 0x00ffffff},
134
135 };
136
137
138
139 #define BADMAG(x) I960BADMAG(x)
140 #include "coff-code.h"
141
142
143
144 bfd_target icoff_big_vec =
145 {
146 "coff-Intel-big", /* name */
147 bfd_target_coff_flavour_enum,
148 false, /* data byte order is little */
149 true, /* header byte order is big */
150
151 (HAS_RELOC | EXEC_P | /* object flags */
152 HAS_LINENO | HAS_DEBUG |
153 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
154
155 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
156 0, /* valid reloc types */
157 '/', /* ar_pad_char */
158 15, /* ar_max_namelen */
159 coff_close_and_cleanup, /* _close_and_cleanup */
160 coff_set_section_contents, /* bfd_set_section_contents */
161 coff_get_section_contents, /* bfd_get_section_contents */
162 coff_new_section_hook, /* new_section_hook */
163 _bfd_dummy_core_file_failing_command, /* _core_file_failing_command */
164 _bfd_dummy_core_file_failing_signal, /* _core_file_failing_signal */
165 _bfd_dummy_core_file_matches_executable_p, /* _core_file_matches_ex...p */
166
167 bfd_slurp_coff_armap, /* bfd_slurp_armap */
168 _bfd_slurp_extended_name_table, /* bfd_slurp_extended_name_table*/
169 #if 0 /* */
170 bfd_dont_truncate_arname, /* bfd_truncate_arname */
171 #else
172 bfd_bsd_truncate_arname,
173 #endif
174
175 coff_get_symtab_upper_bound, /* get_symtab_upper_bound */
176 coff_get_symtab, /* canonicalize_symtab */
177 (void (*)())bfd_false, /* bfd_reclaim_symbol_table */
178 coff_get_reloc_upper_bound, /* get_reloc_upper_bound */
179 coff_canonicalize_reloc, /* bfd_canonicalize_reloc */
180 (void (*)())bfd_false, /* bfd_reclaim_reloc */
181
182 coff_get_symcount_upper_bound, /* bfd_get_symcount_upper_bound */
183 coff_get_first_symbol, /* bfd_get_first_symbol */
184 coff_get_next_symbol, /* bfd_get_next_symbol */
185 coff_classify_symbol, /* bfd_classify_symbol */
186 coff_symbol_hasclass, /* bfd_symbol_hasclass */
187 coff_symbol_name, /* bfd_symbol_name */
188 coff_symbol_value, /* bfd_symbol_value */
189
190 _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
191 _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
192
193 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
194 bfd_generic_archive_p, _bfd_dummy_target},
195 {bfd_false, coff_mkobject, _bfd_generic_mkarchive, /* bfd_set_format */
196 bfd_false},
197 coff_make_empty_symbol,
198 coff_print_symbol,
199 coff_get_lineno,
200 coff_set_arch_mach,
201 coff_write_armap,
202 bfd_generic_openr_next_archived_file,
203 coff_find_nearest_line,
204 bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */
205 };
206
207
208
209 bfd_target icoff_little_vec =
210 {
211 "coff-Intel-little", /* name */
212 bfd_target_coff_flavour_enum,
213 false, /* data byte order is little */
214 false, /* header byte order is little */
215
216 (HAS_RELOC | EXEC_P | /* object flags */
217 HAS_LINENO | HAS_DEBUG |
218 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
219
220 (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
221 0, /* valid reloc types */
222 '/', /* ar_pad_char */
223 15, /* ar_max_namelen */
224 coff_close_and_cleanup, /* _close_and_cleanup */
225 coff_set_section_contents, /* bfd_set_section_contents */
226 coff_get_section_contents, /* bfd_get_section_contents */
227 coff_new_section_hook, /* new_section_hook */
228 _bfd_dummy_core_file_failing_command, /* _core_file_failing_command */
229 _bfd_dummy_core_file_failing_signal, /* _core_file_failing_signal */
230 _bfd_dummy_core_file_matches_executable_p, /* _core_file_matches_ex...p */
231
232 bfd_slurp_coff_armap, /* bfd_slurp_armap */
233 _bfd_slurp_extended_name_table, /* bfd_slurp_extended_name_table*/
234 #if 0 /* */
235 bfd_dont_truncate_arname, /* bfd_truncate_arname */
236 #else
237 bfd_bsd_truncate_arname,
238 #endif
239 coff_get_symtab_upper_bound, /* get_symtab_upper_bound */
240 coff_get_symtab, /* canonicalize_symtab */
241 (void (*)())bfd_false, /* bfd_reclaim_symbol_table */
242 coff_get_reloc_upper_bound, /* get_reloc_upper_bound */
243 coff_canonicalize_reloc, /* bfd_canonicalize_reloc */
244 (void (*)())bfd_false, /* bfd_reclaim_reloc */
245
246 coff_get_symcount_upper_bound, /* bfd_get_symcount_upper_bound */
247 coff_get_first_symbol, /* bfd_get_first_symbol */
248 coff_get_next_symbol, /* bfd_get_next_symbol */
249 coff_classify_symbol, /* bfd_classify_symbol */
250 coff_symbol_hasclass, /* bfd_symbol_hasclass */
251 coff_symbol_name, /* bfd_symbol_name */
252 coff_symbol_value, /* bfd_symbol_value */
253
254 _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
255 _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* hdrs */
256
257 {_bfd_dummy_target, coff_object_p, /* bfd_check_format */
258 bfd_generic_archive_p, _bfd_dummy_target},
259 {bfd_false, coff_mkobject, /* bfd_set_format */
260 _bfd_generic_mkarchive, bfd_false},
261 coff_make_empty_symbol,
262 coff_print_symbol,
263 coff_get_lineno,
264 coff_set_arch_mach,
265 coff_write_armap,
266 bfd_generic_openr_next_archived_file,
267 coff_find_nearest_line,
268 bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */
269 };
270
271
This page took 0.054817 seconds and 5 git commands to generate.