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. */
25 #include "libcoff.h" /* to allow easier abstraction-breaking */
29 #include "intel-coff.h"
31 #define CALLS 0x66003800 /* Template for 'calls' instruction */
32 #define BAL 0x0b000000 /* Template for 'bal' instruction */
33 #define BAL_MASK 0x00ffffff
35 static bfd_reloc_status_enum_type
36 optcall_callback(abfd
, reloc_entry
, symbol_in
, data
, ignore_input_section
)
41 asection
*ignore_input_section
;
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
);
49 /* So the target symbol has to be off coff type, and the symbol
50 has to have the correct native information within it
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 */
59 result
= bfd_reloc_dangerous
;
63 switch (cs
->native
->n_sclass
)
67 /* This is a call to a leaf procedure, replace instruction with a bal
68 to the correct location */
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
))
80 bfd_putlong(abfd
, word
, data
+reloc_entry
->address
);
82 result
= bfd_reloc_ok
;
86 /* This is a call to a system call, replace with a calls to # */
91 result
= bfd_reloc_ok
;
100 static reloc_howto_type howto_table
[] =
120 { (unsigned int) R_RELLONG
, 0, 2, 32,false, 0, true, true, 0,"rellong", true, 0xffffffff},
129 { R_IPRMED
, 0, 2, 24,true,0, true, true,0,"iprmed ", true, 0x00ffffff},
132 { R_OPTCALL
, 0,2,24,true,0, true, true, optcall_callback
, "optcall", true, 0x00ffffff},
138 #define BADMAG(x) I960BADMAG(x)
139 #include "coff-code.h"
143 bfd_target icoff_big_vec
=
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 */
150 (HAS_RELOC
| EXEC_P
| /* object flags */
151 HAS_LINENO
| HAS_DEBUG
|
152 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
),
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 */
166 bfd_slurp_coff_armap
, /* bfd_slurp_armap */
167 _bfd_slurp_extended_name_table
, /* bfd_slurp_extended_name_table*/
169 bfd_dont_truncate_arname
, /* bfd_truncate_arname */
171 bfd_bsd_truncate_arname
,
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 */
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 */
189 _do_getllong
, _do_putllong
, _do_getlshort
, _do_putlshort
, /* data */
190 _do_getblong
, _do_putblong
, _do_getbshort
, _do_putbshort
, /* hdrs */
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 */
196 coff_make_empty_symbol
,
201 bfd_generic_openr_next_archived_file
,
202 coff_find_nearest_line
,
203 bfd_generic_stat_arch_elt
/* bfd_stat_arch_elt */
208 bfd_target icoff_little_vec
=
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 */
215 (HAS_RELOC
| EXEC_P
| /* object flags */
216 HAS_LINENO
| HAS_DEBUG
|
217 HAS_SYMS
| HAS_LOCALS
| DYNAMIC
| WP_TEXT
),
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 */
231 bfd_slurp_coff_armap
, /* bfd_slurp_armap */
232 _bfd_slurp_extended_name_table
, /* bfd_slurp_extended_name_table*/
234 bfd_dont_truncate_arname
, /* bfd_truncate_arname */
236 bfd_bsd_truncate_arname
,
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 */
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 */
253 _do_getllong
, _do_putllong
, _do_getlshort
, _do_putlshort
, /* data */
254 _do_getllong
, _do_putllong
, _do_getlshort
, _do_putlshort
, /* hdrs */
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
,
265 bfd_generic_openr_next_archived_file
,
266 coff_find_nearest_line
,
267 bfd_generic_stat_arch_elt
/* bfd_stat_arch_elt */