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