1 /* Copyright (C) 1990, 1991 Free Software Foundation, Inc.
3 This file is part of BFD, the Binary File Diddler.
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)
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.
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. */
26 #include "libcoff.h" /* to allow easier abstraction-breaking */
30 #include "intel-coff.h"
32 #define CALLS 0x66003800 /* Template for 'calls' instruction */
33 #define BAL 0x0b000000 /* Template for 'bal' instruction */
34 #define BAL_MASK 0x00ffffff
36 static bfd_reloc_status_enum_type
37 optcall_callback(abfd, reloc_entry, symbol_in, data, ignore_input_section)
42 asection *ignore_input_section;
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);
50 /* So the target symbol has to be off coff type, and the symbol
51 has to have the correct native information within it
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 */
60 result = bfd_reloc_dangerous;
64 switch (cs->native->n_sclass)
68 /* This is a call to a leaf procedure, replace instruction with a bal
69 to the correct location */
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))
81 bfd_putlong(abfd, word, data+reloc_entry->address);
83 result = bfd_reloc_ok;
87 /* This is a call to a system call, replace with a calls to # */
92 result = bfd_reloc_ok;
101 static reloc_howto_type howto_table[] =
121 { (unsigned int) R_RELLONG, 0, 2, 32,false, 0, true, true, 0,"rellong", true, 0xffffffff},
130 { R_IPRMED, 0, 2, 24,true,0, true, true,0,"iprmed ", true, 0x00ffffff},
133 { R_OPTCALL, 0,2,24,true,0, true, true, optcall_callback, "optcall", true, 0x00ffffff},
139 #define BADMAG(x) I960BADMAG(x)
140 #include "coff-code.h"
144 bfd_target icoff_big_vec =
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 */
151 (HAS_RELOC | EXEC_P | /* object flags */
152 HAS_LINENO | HAS_DEBUG |
153 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
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 */
167 bfd_slurp_coff_armap, /* bfd_slurp_armap */
168 _bfd_slurp_extended_name_table, /* bfd_slurp_extended_name_table*/
170 bfd_dont_truncate_arname, /* bfd_truncate_arname */
172 bfd_bsd_truncate_arname,
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 */
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 */
190 _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
191 _do_getblong, _do_putblong, _do_getbshort, _do_putbshort, /* hdrs */
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 */
197 coff_make_empty_symbol,
202 bfd_generic_openr_next_archived_file,
203 coff_find_nearest_line,
204 bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */
209 bfd_target icoff_little_vec =
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 */
216 (HAS_RELOC | EXEC_P | /* object flags */
217 HAS_LINENO | HAS_DEBUG |
218 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT),
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 */
232 bfd_slurp_coff_armap, /* bfd_slurp_armap */
233 _bfd_slurp_extended_name_table, /* bfd_slurp_extended_name_table*/
235 bfd_dont_truncate_arname, /* bfd_truncate_arname */
237 bfd_bsd_truncate_arname,
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 */
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 */
254 _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* data */
255 _do_getllong, _do_putllong, _do_getlshort, _do_putlshort, /* hdrs */
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,
266 bfd_generic_openr_next_archived_file,
267 coff_find_nearest_line,
268 bfd_generic_stat_arch_elt /* bfd_stat_arch_elt */