]>
Commit | Line | Data |
---|---|---|
3b4f1a5d SC |
1 | /* Intel 960 COFF support for BFD. |
2 | Copyright (C) 1990-1991 Free Software Foundation, Inc. | |
3 | Written by Cygnus Support. | |
fc723380 | 4 | |
3b4f1a5d | 5 | This file is part of BFD, the Binary File Descriptor library. |
4a81b561 | 6 | |
3b4f1a5d | 7 | This program is free software; you can redistribute it and/or modify |
4a81b561 | 8 | it under the terms of the GNU General Public License as published by |
3b4f1a5d SC |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | |
4a81b561 | 11 | |
3b4f1a5d | 12 | This program is distributed in the hope that it will be useful, |
4a81b561 DHW |
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 | |
3b4f1a5d SC |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
4a81b561 DHW |
20 | |
21 | /* $Id$ */ | |
22 | ||
23 | #define I960 1 | |
fc723380 JG |
24 | #define BADMAG(x) I960BADMAG(x) |
25 | ||
4a81b561 | 26 | #include "bfd.h" |
3b4f1a5d | 27 | #include "sysdep.h" |
4a81b561 | 28 | #include "libbfd.h" |
9872a49c | 29 | #include "obstack.h" |
3b4f1a5d SC |
30 | #include "coff-i960.h" |
31 | #include "internalcoff.h" | |
4a81b561 DHW |
32 | #include "libcoff.h" /* to allow easier abstraction-breaking */ |
33 | ||
34 | ||
4a81b561 DHW |
35 | #define CALLS 0x66003800 /* Template for 'calls' instruction */ |
36 | #define BAL 0x0b000000 /* Template for 'bal' instruction */ | |
37 | #define BAL_MASK 0x00ffffff | |
38 | ||
3b4f1a5d | 39 | static bfd_reloc_status_type |
4a81b561 DHW |
40 | optcall_callback(abfd, reloc_entry, symbol_in, data, ignore_input_section) |
41 | bfd *abfd; | |
42 | arelent *reloc_entry; | |
43 | asymbol *symbol_in; | |
44 | unsigned char *data; | |
45 | asection *ignore_input_section; | |
46 | { | |
47 | /* This item has already been relocated correctly, but we may be | |
48 | * able to patch in yet better code - done by digging out the | |
49 | * correct info on this symbol */ | |
3b4f1a5d | 50 | bfd_reloc_status_type result; |
4a81b561 DHW |
51 | coff_symbol_type *cs = coffsymbol(symbol_in); |
52 | ||
fc723380 JG |
53 | /* So the target symbol has to be of coff type, and the symbol |
54 | has to have the correct native information within it */ | |
3b4f1a5d SC |
55 | if ((cs->symbol.the_bfd->xvec->flavour != bfd_target_coff_flavour) |
56 | || (cs->native == (combined_entry_type *)NULL)) { | |
4a81b561 DHW |
57 | /* This is interesting, consider the case where we're outputting */ |
58 | /* coff from a mix n match input, linking from coff to a symbol */ | |
59 | /* defined in a bout file will cause this match to be true. Should */ | |
60 | /* I complain ? - This will only work if the bout symbol is non */ | |
61 | /* leaf. */ | |
62 | result = bfd_reloc_dangerous; | |
4a81b561 DHW |
63 | } |
64 | else { | |
3b4f1a5d | 65 | switch (cs->native->u.syment.n_sclass) |
4a81b561 DHW |
66 | { |
67 | case C_LEAFSTAT: | |
68 | case C_LEAFEXT: | |
69 | /* This is a call to a leaf procedure, replace instruction with a bal | |
70 | to the correct location */ | |
71 | { | |
3b4f1a5d | 72 | union internal_auxent *aux = &((cs->native+2)->u.auxent); |
19b03b7a | 73 | int word = bfd_get_32(abfd, data + reloc_entry->address); |
3b4f1a5d SC |
74 | int olf = (aux->x_bal.x_balntry - cs->native->u.syment.n_value); |
75 | BFD_ASSERT(cs->native->u.syment.n_numaux==2); | |
4a81b561 DHW |
76 | /* We replace the original call instruction with a bal to */ |
77 | /* the bal entry point - the offset of which is described in the */ | |
78 | /* 2nd auxent of the original symbol. We keep the native sym and */ | |
79 | /* auxents untouched, so the delta between the two is the */ | |
80 | /* offset of the bal entry point */ | |
8e3c8f47 SC |
81 | |
82 | word = ((word + olf) & BAL_MASK) | BAL; | |
19b03b7a | 83 | bfd_put_32(abfd, word, data+reloc_entry->address); |
4a81b561 DHW |
84 | } |
85 | result = bfd_reloc_ok; | |
86 | break; | |
87 | case C_SCALL: | |
3b4f1a5d SC |
88 | /* This is a call to a system call, replace with a calls to # */ |
89 | BFD_ASSERT(0); | |
90 | result = bfd_reloc_ok; | |
4a81b561 DHW |
91 | break; |
92 | default: | |
93 | result = bfd_reloc_ok; | |
94 | break; | |
95 | } | |
96 | } | |
97 | return result; | |
98 | } | |
99 | ||
100 | ||
101 | ||
102 | static reloc_howto_type howto_table[] = | |
103 | { | |
104 | {0}, | |
105 | {1}, | |
106 | {2}, | |
107 | {3}, | |
108 | {4}, | |
109 | {5}, | |
110 | {6}, | |
111 | {7}, | |
112 | {8}, | |
113 | {9}, | |
114 | {10}, | |
115 | {11}, | |
116 | {12}, | |
117 | {13}, | |
118 | {14}, | |
119 | {15}, | |
120 | {16}, | |
121 | ||
9872a49c SC |
122 | { (unsigned int) R_RELLONG, 0, 2, 32,false, 0, true, true, |
123 | 0,"rellong", true, 0xffffffff, 0xffffffff}, | |
4a81b561 DHW |
124 | {18}, |
125 | {19}, | |
126 | {20}, | |
127 | {21}, | |
128 | {22}, | |
129 | {23}, | |
130 | {24}, | |
131 | ||
9872a49c SC |
132 | { R_IPRMED, 0, 2, 24,true,0, true, true,0,"iprmed ", true, |
133 | 0x00ffffff, 0x00ffffff}, | |
4a81b561 DHW |
134 | {26}, |
135 | ||
9872a49c SC |
136 | { R_OPTCALL, 0,2,24,true,0, true, true, optcall_callback, |
137 | "optcall", true, 0x00ffffff, 0x00ffffff}, | |
4a81b561 DHW |
138 | |
139 | }; | |
140 | ||
924bbb38 | 141 | /* The real code is in coffcode.h */ |
4a81b561 | 142 | |
3b4f1a5d SC |
143 | #define RTYPE2HOWTO(cache_ptr, dst) \ |
144 | cache_ptr->howto = howto_table + dst.r_type; | |
145 | ||
7ed4093a | 146 | #include "coffcode.h" |
4a81b561 | 147 | |
9872a49c | 148 | bfd_target icoff_little_vec = |
4a81b561 | 149 | { |
9872a49c | 150 | "coff-Intel-little", /* name */ |
3b4f1a5d | 151 | bfd_target_coff_flavour, |
4a81b561 | 152 | false, /* data byte order is little */ |
9872a49c | 153 | false, /* header byte order is little */ |
4a81b561 DHW |
154 | |
155 | (HAS_RELOC | EXEC_P | /* object flags */ | |
156 | HAS_LINENO | HAS_DEBUG | | |
157 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), | |
158 | ||
159 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
4a81b561 DHW |
160 | '/', /* ar_pad_char */ |
161 | 15, /* ar_max_namelen */ | |
4a81b561 | 162 | |
3b4f1a5d | 163 | 3, /* minimum alignment power */ |
19b03b7a SC |
164 | _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ |
165 | _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* hdrs */ | |
4a81b561 | 166 | |
19b03b7a SC |
167 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ |
168 | bfd_generic_archive_p, _bfd_dummy_target}, | |
169 | {bfd_false, coff_mkobject, /* bfd_set_format */ | |
170 | _bfd_generic_mkarchive, bfd_false}, | |
171 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
172 | _bfd_write_archive_contents, bfd_false}, | |
fc723380 | 173 | JUMP_TABLE(coff) |
19b03b7a | 174 | }; |
4a81b561 DHW |
175 | |
176 | ||
9872a49c | 177 | bfd_target icoff_big_vec = |
4a81b561 | 178 | { |
9872a49c | 179 | "coff-Intel-big", /* name */ |
3b4f1a5d | 180 | bfd_target_coff_flavour, |
4a81b561 | 181 | false, /* data byte order is little */ |
9872a49c | 182 | true, /* header byte order is big */ |
4a81b561 DHW |
183 | |
184 | (HAS_RELOC | EXEC_P | /* object flags */ | |
185 | HAS_LINENO | HAS_DEBUG | | |
186 | HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT), | |
187 | ||
188 | (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
4a81b561 DHW |
189 | '/', /* ar_pad_char */ |
190 | 15, /* ar_max_namelen */ | |
4a81b561 | 191 | |
3b4f1a5d | 192 | 3, /* minimum alignment power */ |
19b03b7a SC |
193 | _do_getl64, _do_putl64, _do_getl32, _do_putl32, _do_getl16, _do_putl16, /* data */ |
194 | _do_getb64, _do_putb64, _do_getb32, _do_putb32, _do_getb16, _do_putb16, /* hdrs */ | |
4a81b561 | 195 | |
2b1d8a50 JG |
196 | {_bfd_dummy_target, coff_object_p, /* bfd_check_format */ |
197 | bfd_generic_archive_p, _bfd_dummy_target}, | |
198 | {bfd_false, coff_mkobject, /* bfd_set_format */ | |
199 | _bfd_generic_mkarchive, bfd_false}, | |
200 | {bfd_false, coff_write_object_contents, /* bfd_write_contents */ | |
201 | _bfd_write_archive_contents, bfd_false}, | |
2700c3c7 SC |
202 | JUMP_TABLE(coff), |
203 | COFF_SWAP_TABLE | |
fc723380 | 204 | }; |