Commit | Line | Data |
---|---|---|
aff6e0b4 | 1 | /* BFD back-end for ieee-695 objects. |
f8254a3c | 2 | Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. |
b2c91bd9 | 3 | Written by Steve Chamberlain of Cygnus Support. |
d0ec7a8e | 4 | |
b2c91bd9 | 5 | This file is part of BFD, the Binary File Descriptor library. |
87f86b4e | 6 | |
b2c91bd9 | 7 | This program is free software; you can redistribute it and/or modify |
9b4641a6 | 8 | it under the terms of the GNU General Public License as published by |
b2c91bd9 SC |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. | |
87f86b4e | 11 | |
b2c91bd9 | 12 | This program is distributed in the hope that it will be useful, |
9b4641a6 JG |
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. | |
87f86b4e | 16 | |
9b4641a6 | 17 | You should have received a copy of the GNU General Public License |
b2c91bd9 | 18 | along with this program; if not, write to the Free Software |
c3246d9b | 19 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
87f86b4e | 20 | |
aff6e0b4 | 21 | #define KEEPMINUSPCININST 0 |
9465d03e | 22 | |
b2c91bd9 SC |
23 | /* IEEE 695 format is a stream of records, which we parse using a simple one- |
24 | token (which is one byte in this lexicon) lookahead recursive decent | |
25 | parser. */ | |
d0ec7a8e | 26 | |
87f86b4e | 27 | #include "bfd.h" |
01dd1b2b | 28 | #include "sysdep.h" |
87f86b4e | 29 | #include "libbfd.h" |
87f86b4e DHW |
30 | #include "ieee.h" |
31 | #include "libieee.h" | |
14578105 | 32 | |
6c58561e | 33 | static boolean ieee_write_byte PARAMS ((bfd *, int)); |
14578105 ILT |
34 | static boolean ieee_write_2bytes PARAMS ((bfd *, int)); |
35 | static boolean ieee_write_int PARAMS ((bfd *, bfd_vma)); | |
36 | static boolean ieee_write_id PARAMS ((bfd *, const char *)); | |
37 | static boolean ieee_write_expression | |
38 | PARAMS ((bfd *, bfd_vma, asymbol *, boolean, unsigned int)); | |
39 | static void ieee_write_int5 PARAMS ((bfd_byte *, bfd_vma)); | |
40 | static boolean ieee_write_int5_out PARAMS ((bfd *, bfd_vma)); | |
41 | static boolean ieee_write_section_part PARAMS ((bfd *)); | |
42 | static boolean do_with_relocs PARAMS ((bfd *, asection *)); | |
43 | static boolean do_as_repeat PARAMS ((bfd *, asection *)); | |
44 | static boolean do_without_relocs PARAMS ((bfd *, asection *)); | |
45 | static boolean ieee_write_external_part PARAMS ((bfd *)); | |
46 | static boolean ieee_write_data_part PARAMS ((bfd *)); | |
efa77952 | 47 | static boolean ieee_write_debug_part PARAMS ((bfd *)); |
14578105 | 48 | static boolean ieee_write_me_part PARAMS ((bfd *)); |
e4d27380 | 49 | static boolean ieee_write_processor PARAMS ((bfd *)); |
9465d03e | 50 | |
f8254a3c | 51 | static boolean ieee_slurp_debug PARAMS ((bfd *)); |
e4d27380 | 52 | static boolean ieee_slurp_section_data PARAMS ((bfd *)); |
f8254a3c | 53 | |
ce3f6d51 JG |
54 | /* Functions for writing to ieee files in the strange way that the |
55 | standard requires. */ | |
87f86b4e | 56 | |
14578105 | 57 | static boolean |
6c58561e | 58 | ieee_write_byte (abfd, barg) |
57a1867e | 59 | bfd *abfd; |
6c58561e | 60 | int barg; |
87f86b4e | 61 | { |
6c58561e ILT |
62 | bfd_byte byte; |
63 | ||
64 | byte = barg; | |
14578105 ILT |
65 | if (bfd_write ((PTR) &byte, 1, 1, abfd) != 1) |
66 | return false; | |
67 | return true; | |
b2c91bd9 SC |
68 | } |
69 | ||
14578105 | 70 | static boolean |
57a1867e DM |
71 | ieee_write_2bytes (abfd, bytes) |
72 | bfd *abfd; | |
73 | int bytes; | |
87f86b4e DHW |
74 | { |
75 | bfd_byte buffer[2]; | |
14578105 | 76 | |
87f86b4e DHW |
77 | buffer[0] = bytes >> 8; |
78 | buffer[1] = bytes & 0xff; | |
4002f18a | 79 | if (bfd_write ((PTR) buffer, 1, 2, abfd) != 2) |
14578105 ILT |
80 | return false; |
81 | return true; | |
87f86b4e DHW |
82 | } |
83 | ||
14578105 | 84 | static boolean |
57a1867e DM |
85 | ieee_write_int (abfd, value) |
86 | bfd *abfd; | |
87 | bfd_vma value; | |
87f86b4e | 88 | { |
14578105 | 89 | if (value <= 127) |
9783e04a | 90 | { |
14578105 ILT |
91 | if (! ieee_write_byte (abfd, (bfd_byte) value)) |
92 | return false; | |
9783e04a DM |
93 | } |
94 | else | |
95 | { | |
96 | unsigned int length; | |
14578105 | 97 | |
9783e04a DM |
98 | /* How many significant bytes ? */ |
99 | /* FIXME FOR LONGER INTS */ | |
100 | if (value & 0xff000000) | |
14578105 | 101 | length = 4; |
9783e04a | 102 | else if (value & 0x00ff0000) |
14578105 | 103 | length = 3; |
9783e04a | 104 | else if (value & 0x0000ff00) |
14578105 | 105 | length = 2; |
9783e04a DM |
106 | else |
107 | length = 1; | |
108 | ||
14578105 ILT |
109 | if (! ieee_write_byte (abfd, |
110 | (bfd_byte) ((int) ieee_number_repeat_start_enum | |
111 | + length))) | |
112 | return false; | |
9783e04a DM |
113 | switch (length) |
114 | { | |
115 | case 4: | |
14578105 ILT |
116 | if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24))) |
117 | return false; | |
118 | /* Fall through. */ | |
9783e04a | 119 | case 3: |
14578105 ILT |
120 | if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16))) |
121 | return false; | |
122 | /* Fall through. */ | |
9783e04a | 123 | case 2: |
14578105 ILT |
124 | if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8))) |
125 | return false; | |
126 | /* Fall through. */ | |
9783e04a | 127 | case 1: |
14578105 ILT |
128 | if (! ieee_write_byte (abfd, (bfd_byte) (value))) |
129 | return false; | |
9783e04a | 130 | } |
87f86b4e | 131 | } |
14578105 ILT |
132 | |
133 | return true; | |
87f86b4e DHW |
134 | } |
135 | ||
14578105 | 136 | static boolean |
57a1867e DM |
137 | ieee_write_id (abfd, id) |
138 | bfd *abfd; | |
14578105 | 139 | const char *id; |
87f86b4e | 140 | { |
9783e04a | 141 | size_t length = strlen (id); |
14578105 | 142 | |
9783e04a DM |
143 | if (length <= 127) |
144 | { | |
14578105 ILT |
145 | if (! ieee_write_byte (abfd, (bfd_byte) length)) |
146 | return false; | |
9783e04a DM |
147 | } |
148 | else if (length < 255) | |
149 | { | |
14578105 ILT |
150 | if (! ieee_write_byte (abfd, ieee_extension_length_1_enum) |
151 | || ! ieee_write_byte (abfd, (bfd_byte) length)) | |
152 | return false; | |
9783e04a DM |
153 | } |
154 | else if (length < 65535) | |
155 | { | |
14578105 ILT |
156 | if (! ieee_write_byte (abfd, ieee_extension_length_2_enum) |
157 | || ! ieee_write_2bytes (abfd, (int) length)) | |
158 | return false; | |
9783e04a DM |
159 | } |
160 | else | |
161 | { | |
14578105 ILT |
162 | (*_bfd_error_handler) |
163 | ("%s: string too long (%d chars, max 65535)", | |
164 | bfd_get_filename (abfd), length); | |
165 | bfd_set_error (bfd_error_invalid_operation); | |
166 | return false; | |
9783e04a | 167 | } |
14578105 | 168 | |
4002f18a | 169 | if (bfd_write ((PTR) id, 1, length, abfd) != length) |
14578105 ILT |
170 | return false; |
171 | return true; | |
87f86b4e | 172 | } |
9783e04a | 173 | \f |
87f86b4e DHW |
174 | /*************************************************************************** |
175 | Functions for reading from ieee files in the strange way that the | |
176 | standard requires: | |
177 | */ | |
87f86b4e | 178 | |
6f715d66 SC |
179 | #define this_byte(ieee) *((ieee)->input_p) |
180 | #define next_byte(ieee) ((ieee)->input_p++) | |
181 | #define this_byte_and_next(ieee) (*((ieee)->input_p++)) | |
87f86b4e | 182 | |
9783e04a | 183 | static unsigned short |
57a1867e DM |
184 | read_2bytes (ieee) |
185 | common_header_type *ieee; | |
87f86b4e | 186 | { |
9783e04a DM |
187 | unsigned char c1 = this_byte_and_next (ieee); |
188 | unsigned char c2 = this_byte_and_next (ieee); | |
189 | return (c1 << 8) | c2; | |
87f86b4e DHW |
190 | } |
191 | ||
192 | static void | |
57a1867e DM |
193 | bfd_get_string (ieee, string, length) |
194 | common_header_type *ieee; | |
195 | char *string; | |
196 | size_t length; | |
87f86b4e DHW |
197 | { |
198 | size_t i; | |
9783e04a DM |
199 | for (i = 0; i < length; i++) |
200 | { | |
201 | string[i] = this_byte_and_next (ieee); | |
202 | } | |
87f86b4e DHW |
203 | } |
204 | ||
301dfc71 | 205 | static char * |
57a1867e DM |
206 | read_id (ieee) |
207 | common_header_type *ieee; | |
87f86b4e DHW |
208 | { |
209 | size_t length; | |
210 | char *string; | |
9783e04a DM |
211 | length = this_byte_and_next (ieee); |
212 | if (length <= 0x7f) | |
213 | { | |
214 | /* Simple string of length 0 to 127 */ | |
215 | } | |
216 | else if (length == 0xde) | |
217 | { | |
218 | /* Length is next byte, allowing 0..255 */ | |
219 | length = this_byte_and_next (ieee); | |
220 | } | |
221 | else if (length == 0xdf) | |
222 | { | |
223 | /* Length is next two bytes, allowing 0..65535 */ | |
224 | length = this_byte_and_next (ieee); | |
225 | length = (length * 256) + this_byte_and_next (ieee); | |
226 | } | |
87f86b4e | 227 | /* Buy memory and read string */ |
9783e04a DM |
228 | string = bfd_alloc (ieee->abfd, length + 1); |
229 | if (!string) | |
a9713b91 | 230 | return NULL; |
9783e04a | 231 | bfd_get_string (ieee, string, length); |
87f86b4e DHW |
232 | string[length] = 0; |
233 | return string; | |
234 | } | |
235 | ||
14578105 | 236 | static boolean |
57a1867e DM |
237 | ieee_write_expression (abfd, value, symbol, pcrel, index) |
238 | bfd *abfd; | |
239 | bfd_vma value; | |
240 | asymbol *symbol; | |
241 | boolean pcrel; | |
242 | unsigned int index; | |
87f86b4e | 243 | { |
69e0d34d | 244 | unsigned int term_count = 0; |
b2c91bd9 | 245 | |
9783e04a DM |
246 | if (value != 0) |
247 | { | |
14578105 ILT |
248 | if (! ieee_write_int (abfd, value)) |
249 | return false; | |
9783e04a DM |
250 | term_count++; |
251 | } | |
87f86b4e | 252 | |
8feff717 | 253 | if (bfd_is_com_section (symbol->section) |
c3246d9b | 254 | || bfd_is_und_section (symbol->section)) |
9783e04a DM |
255 | { |
256 | /* Def of a common symbol */ | |
14578105 ILT |
257 | if (! ieee_write_byte (abfd, ieee_variable_X_enum) |
258 | || ! ieee_write_int (abfd, symbol->value)) | |
259 | return false; | |
69e0d34d | 260 | term_count++; |
87f86b4e | 261 | } |
c3246d9b | 262 | else if (! bfd_is_abs_section (symbol->section)) |
69e0d34d | 263 | { |
9783e04a | 264 | /* Ref to defined symbol - */ |
301dfc71 | 265 | |
9783e04a DM |
266 | if (symbol->flags & BSF_GLOBAL) |
267 | { | |
14578105 ILT |
268 | if (! ieee_write_byte (abfd, ieee_variable_I_enum) |
269 | || ! ieee_write_int (abfd, symbol->value)) | |
270 | return false; | |
9783e04a DM |
271 | term_count++; |
272 | } | |
273 | else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM)) | |
274 | { | |
14578105 ILT |
275 | /* This is a reference to a defined local symbol. We can |
276 | easily do a local as a section+offset. */ | |
e4d27380 ILT |
277 | if (! ieee_write_byte (abfd, ieee_variable_R_enum) |
278 | || ! ieee_write_byte (abfd, | |
279 | (bfd_byte) (symbol->section->index | |
280 | + IEEE_SECTION_NUMBER_BASE))) | |
14578105 | 281 | return false; |
9783e04a | 282 | term_count++; |
e4d27380 ILT |
283 | if (symbol->value != 0) |
284 | { | |
285 | if (! ieee_write_int (abfd, symbol->value)) | |
286 | return false; | |
287 | term_count++; | |
288 | } | |
9783e04a DM |
289 | } |
290 | else | |
291 | { | |
14578105 ILT |
292 | (*_bfd_error_handler) |
293 | ("%s: unrecognized symbol `%s' flags 0x%x", | |
294 | bfd_get_filename (abfd), bfd_asymbol_name (symbol), | |
295 | symbol->flags); | |
296 | bfd_set_error (bfd_error_invalid_operation); | |
297 | return false; | |
9783e04a | 298 | } |
87f86b4e | 299 | } |
87f86b4e | 300 | |
9783e04a DM |
301 | if (pcrel) |
302 | { | |
69e0d34d | 303 | /* subtract the pc from here by asking for PC of this section*/ |
14578105 ILT |
304 | if (! ieee_write_byte (abfd, ieee_variable_P_enum) |
305 | || ! ieee_write_byte (abfd, | |
306 | (bfd_byte) (index + IEEE_SECTION_NUMBER_BASE)) | |
307 | || ! ieee_write_byte (abfd, ieee_function_minus_enum)) | |
308 | return false; | |
69e0d34d SC |
309 | } |
310 | ||
e4d27380 ILT |
311 | /* Handle the degenerate case of a 0 address. */ |
312 | if (term_count == 0) | |
313 | { | |
314 | if (! ieee_write_int (abfd, 0)) | |
315 | return false; | |
316 | } | |
317 | ||
14578105 | 318 | while (term_count > 1) |
9783e04a | 319 | { |
14578105 ILT |
320 | if (! ieee_write_byte (abfd, ieee_function_plus_enum)) |
321 | return false; | |
322 | term_count--; | |
b2c91bd9 | 323 | } |
14578105 ILT |
324 | |
325 | return true; | |
87f86b4e | 326 | } |
9783e04a | 327 | \f |
87f86b4e DHW |
328 | /*****************************************************************************/ |
329 | ||
330 | /* | |
331 | writes any integer into the buffer supplied and always takes 5 bytes | |
332 | */ | |
333 | static void | |
57a1867e DM |
334 | ieee_write_int5 (buffer, value) |
335 | bfd_byte *buffer; | |
336 | bfd_vma value; | |
87f86b4e | 337 | { |
9783e04a DM |
338 | buffer[0] = (bfd_byte) ieee_number_repeat_4_enum; |
339 | buffer[1] = (value >> 24) & 0xff; | |
340 | buffer[2] = (value >> 16) & 0xff; | |
341 | buffer[3] = (value >> 8) & 0xff; | |
342 | buffer[4] = (value >> 0) & 0xff; | |
301dfc71 | 343 | } |
9783e04a | 344 | |
14578105 | 345 | static boolean |
57a1867e DM |
346 | ieee_write_int5_out (abfd, value) |
347 | bfd *abfd; | |
348 | bfd_vma value; | |
301dfc71 | 349 | { |
d0ec7a8e | 350 | bfd_byte b[5]; |
14578105 | 351 | |
9783e04a | 352 | ieee_write_int5 (b, value); |
4002f18a | 353 | if (bfd_write ((PTR) b, 1, 5, abfd) != 5) |
14578105 ILT |
354 | return false; |
355 | return true; | |
87f86b4e | 356 | } |
87f86b4e | 357 | |
9783e04a | 358 | static boolean |
57a1867e DM |
359 | parse_int (ieee, value_ptr) |
360 | common_header_type *ieee; | |
361 | bfd_vma *value_ptr; | |
87f86b4e | 362 | { |
9783e04a | 363 | int value = this_byte (ieee); |
87f86b4e | 364 | int result; |
9783e04a DM |
365 | if (value >= 0 && value <= 127) |
366 | { | |
367 | *value_ptr = value; | |
368 | next_byte (ieee); | |
369 | return true; | |
370 | } | |
371 | else if (value >= 0x80 && value <= 0x88) | |
372 | { | |
373 | unsigned int count = value & 0xf; | |
374 | result = 0; | |
375 | next_byte (ieee); | |
376 | while (count) | |
377 | { | |
378 | result = (result << 8) | this_byte_and_next (ieee); | |
379 | count--; | |
380 | } | |
381 | *value_ptr = result; | |
382 | return true; | |
383 | } | |
87f86b4e DHW |
384 | return false; |
385 | } | |
9783e04a | 386 | |
301dfc71 | 387 | static int |
57a1867e DM |
388 | parse_i (ieee, ok) |
389 | common_header_type *ieee; | |
390 | boolean *ok; | |
87f86b4e DHW |
391 | { |
392 | bfd_vma x; | |
9783e04a | 393 | *ok = parse_int (ieee, &x); |
87f86b4e DHW |
394 | return x; |
395 | } | |
396 | ||
9783e04a | 397 | static bfd_vma |
57a1867e DM |
398 | must_parse_int (ieee) |
399 | common_header_type *ieee; | |
87f86b4e DHW |
400 | { |
401 | bfd_vma result; | |
9783e04a | 402 | BFD_ASSERT (parse_int (ieee, &result) == true); |
87f86b4e DHW |
403 | return result; |
404 | } | |
405 | ||
9783e04a | 406 | typedef struct |
87f86b4e DHW |
407 | { |
408 | bfd_vma value; | |
409 | asection *section; | |
410 | ieee_symbol_index_type symbol; | |
411 | } ieee_value_type; | |
412 | ||
413 | ||
e4d27380 ILT |
414 | #if KEEPMINUSPCININST |
415 | ||
416 | #define SRC_MASK(arg) arg | |
417 | #define PCREL_OFFSET false | |
418 | ||
419 | #else | |
420 | ||
421 | #define SRC_MASK(arg) 0 | |
422 | #define PCREL_OFFSET true | |
423 | ||
424 | #endif | |
425 | ||
14578105 ILT |
426 | static reloc_howto_type abs32_howto = |
427 | HOWTO (1, | |
428 | 0, | |
429 | 2, | |
430 | 32, | |
431 | false, | |
432 | 0, | |
433 | complain_overflow_bitfield, | |
434 | 0, | |
435 | "abs32", | |
436 | true, | |
437 | 0xffffffff, | |
438 | 0xffffffff, | |
439 | false); | |
440 | ||
441 | static reloc_howto_type abs16_howto = | |
442 | HOWTO (1, | |
443 | 0, | |
444 | 1, | |
445 | 16, | |
446 | false, | |
447 | 0, | |
448 | complain_overflow_bitfield, | |
449 | 0, | |
450 | "abs16", | |
451 | true, | |
452 | 0x0000ffff, | |
453 | 0x0000ffff, | |
454 | false); | |
455 | ||
456 | static reloc_howto_type abs8_howto = | |
457 | HOWTO (1, | |
458 | 0, | |
459 | 0, | |
460 | 8, | |
461 | false, | |
462 | 0, | |
463 | complain_overflow_bitfield, | |
464 | 0, | |
465 | "abs8", | |
466 | true, | |
467 | 0x000000ff, | |
468 | 0x000000ff, | |
469 | false); | |
470 | ||
471 | static reloc_howto_type rel32_howto = | |
472 | HOWTO (1, | |
473 | 0, | |
474 | 2, | |
475 | 32, | |
476 | true, | |
477 | 0, | |
478 | complain_overflow_signed, | |
479 | 0, | |
480 | "rel32", | |
481 | true, | |
e4d27380 | 482 | SRC_MASK (0xffffffff), |
14578105 | 483 | 0xffffffff, |
e4d27380 | 484 | PCREL_OFFSET); |
14578105 ILT |
485 | |
486 | static reloc_howto_type rel16_howto = | |
487 | HOWTO (1, | |
488 | 0, | |
489 | 1, | |
490 | 16, | |
491 | true, | |
492 | 0, | |
493 | complain_overflow_signed, | |
494 | 0, | |
495 | "rel16", | |
496 | true, | |
e4d27380 | 497 | SRC_MASK (0x0000ffff), |
14578105 | 498 | 0x0000ffff, |
e4d27380 | 499 | PCREL_OFFSET); |
14578105 ILT |
500 | |
501 | static reloc_howto_type rel8_howto = | |
502 | HOWTO (1, | |
503 | 0, | |
504 | 0, | |
505 | 8, | |
506 | true, | |
507 | 0, | |
508 | complain_overflow_signed, | |
509 | 0, | |
510 | "rel8", | |
511 | true, | |
e4d27380 | 512 | SRC_MASK (0x000000ff), |
14578105 | 513 | 0x000000ff, |
e4d27380 | 514 | PCREL_OFFSET); |
14578105 ILT |
515 | |
516 | static ieee_symbol_index_type NOSYMBOL = {0, 0}; | |
87f86b4e | 517 | |
301dfc71 | 518 | static void |
57a1867e DM |
519 | parse_expression (ieee, value, symbol, pcrel, extra, section) |
520 | ieee_data_type *ieee; | |
521 | bfd_vma *value; | |
522 | ieee_symbol_index_type *symbol; | |
523 | boolean *pcrel; | |
524 | unsigned int *extra; | |
525 | asection **section; | |
d0ec7a8e | 526 | |
87f86b4e DHW |
527 | { |
528 | #define POS sp[1] | |
529 | #define TOS sp[0] | |
530 | #define NOS sp[-1] | |
531 | #define INC sp++; | |
532 | #define DEC sp--; | |
69e0d34d | 533 | |
87f86b4e DHW |
534 | boolean loop = true; |
535 | ieee_value_type stack[10]; | |
536 | ||
537 | /* The stack pointer always points to the next unused location */ | |
538 | #define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC; | |
539 | #define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value; | |
540 | ieee_value_type *sp = stack; | |
541 | ||
9783e04a DM |
542 | while (loop) |
543 | { | |
544 | switch (this_byte (&(ieee->h))) | |
87f86b4e | 545 | { |
d0ec7a8e SC |
546 | case ieee_variable_P_enum: |
547 | /* P variable, current program counter for section n */ | |
9783e04a DM |
548 | { |
549 | int section_n; | |
550 | next_byte (&(ieee->h)); | |
551 | *pcrel = true; | |
552 | section_n = must_parse_int (&(ieee->h)); | |
e4d27380 | 553 | PUSH (NOSYMBOL, bfd_abs_section_ptr, 0); |
9783e04a DM |
554 | break; |
555 | } | |
d0ec7a8e SC |
556 | case ieee_variable_L_enum: |
557 | /* L variable address of section N */ | |
9783e04a DM |
558 | next_byte (&(ieee->h)); |
559 | PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); | |
d0ec7a8e SC |
560 | break; |
561 | case ieee_variable_R_enum: | |
562 | /* R variable, logical address of section module */ | |
563 | /* FIXME, this should be different to L */ | |
9783e04a DM |
564 | next_byte (&(ieee->h)); |
565 | PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0); | |
d0ec7a8e SC |
566 | break; |
567 | case ieee_variable_S_enum: | |
568 | /* S variable, size in MAUS of section module */ | |
9783e04a DM |
569 | next_byte (&(ieee->h)); |
570 | PUSH (NOSYMBOL, | |
571 | 0, | |
572 | ieee->section_table[must_parse_int (&(ieee->h))]->_raw_size); | |
87f86b4e | 573 | break; |
9783e04a | 574 | case ieee_variable_I_enum: |
e4d27380 ILT |
575 | /* Push the address of variable n */ |
576 | { | |
577 | ieee_symbol_index_type sy; | |
578 | next_byte (&(ieee->h)); | |
579 | sy.index = (int) must_parse_int (&(ieee->h)); | |
580 | sy.letter = 'I'; | |
581 | ||
582 | PUSH (sy, bfd_abs_section_ptr, 0); | |
583 | } | |
584 | break; | |
d0ec7a8e SC |
585 | case ieee_variable_X_enum: |
586 | /* Push the address of external variable n */ | |
9783e04a DM |
587 | { |
588 | ieee_symbol_index_type sy; | |
589 | next_byte (&(ieee->h)); | |
590 | sy.index = (int) (must_parse_int (&(ieee->h))); | |
591 | sy.letter = 'X'; | |
87f86b4e | 592 | |
c3246d9b | 593 | PUSH (sy, bfd_und_section_ptr, 0); |
9783e04a | 594 | } |
d0ec7a8e SC |
595 | break; |
596 | case ieee_function_minus_enum: | |
9783e04a DM |
597 | { |
598 | bfd_vma value1, value2; | |
599 | asection *section1, *section_dummy; | |
600 | ieee_symbol_index_type sy; | |
601 | next_byte (&(ieee->h)); | |
602 | ||
603 | POP (sy, section1, value1); | |
604 | POP (sy, section_dummy, value2); | |
e4d27380 | 605 | PUSH (sy, section1 ? section1 : section_dummy, value2 - value1); |
9783e04a | 606 | } |
d0ec7a8e SC |
607 | break; |
608 | case ieee_function_plus_enum: | |
9783e04a DM |
609 | { |
610 | bfd_vma value1, value2; | |
611 | asection *section1; | |
612 | asection *section2; | |
613 | ieee_symbol_index_type sy1; | |
614 | ieee_symbol_index_type sy2; | |
615 | next_byte (&(ieee->h)); | |
616 | ||
617 | POP (sy1, section1, value1); | |
618 | POP (sy2, section2, value2); | |
c3246d9b ILT |
619 | PUSH (sy1.letter ? sy1 : sy2, |
620 | bfd_is_abs_section (section1) ? section2 : section1, | |
621 | value1 + value2); | |
9783e04a | 622 | } |
d0ec7a8e | 623 | break; |
9783e04a DM |
624 | default: |
625 | { | |
626 | bfd_vma va; | |
627 | BFD_ASSERT (this_byte (&(ieee->h)) < (int) ieee_variable_A_enum | |
628 | || this_byte (&(ieee->h)) > (int) ieee_variable_Z_enum); | |
629 | if (parse_int (&(ieee->h), &va)) | |
630 | { | |
c3246d9b | 631 | PUSH (NOSYMBOL, bfd_abs_section_ptr, va); |
9783e04a DM |
632 | } |
633 | else | |
634 | { | |
635 | /* | |
d0ec7a8e SC |
636 | Thats all that we can understand. As far as I can see |
637 | there is a bug in the Microtec IEEE output which I'm | |
9783e04a | 638 | using to scan, whereby the comma operator is omitted |
d0ec7a8e SC |
639 | sometimes in an expression, giving expressions with too |
640 | many terms. We can tell if that's the case by ensuring | |
641 | that sp == stack here. If not, then we've pushed | |
9783e04a DM |
642 | something too far, so we keep adding. */ |
643 | ||
644 | while (sp != stack + 1) | |
645 | { | |
646 | asection *section1; | |
647 | ieee_symbol_index_type sy1; | |
648 | POP (sy1, section1, *extra); | |
649 | } | |
650 | { | |
651 | asection *dummy; | |
d0ec7a8e | 652 | |
9783e04a DM |
653 | POP (*symbol, dummy, *value); |
654 | if (section) | |
655 | *section = dummy; | |
d0ec7a8e | 656 | } |
9465d03e | 657 | |
d0ec7a8e SC |
658 | loop = false; |
659 | } | |
9783e04a | 660 | } |
d0ec7a8e | 661 | } |
9783e04a | 662 | } |
87f86b4e DHW |
663 | } |
664 | ||
301dfc71 | 665 | |
301dfc71 | 666 | #define ieee_seek(abfd, offset) \ |
e98e6ec1 | 667 | IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset |
6f715d66 | 668 | |
ae115e51 ILT |
669 | #define ieee_pos(abfd) \ |
670 | (IEEE_DATA(abfd)->h.input_p - IEEE_DATA(abfd)->h.first_byte) | |
87f86b4e | 671 | |
b2c91bd9 | 672 | static unsigned int last_index; |
9783e04a DM |
673 | static char last_type; /* is the index for an X or a D */ |
674 | ||
b2c91bd9 | 675 | static ieee_symbol_type * |
57a1867e DM |
676 | get_symbol (abfd, |
677 | ieee, | |
678 | last_symbol, | |
679 | symbol_count, | |
680 | pptr, | |
681 | max_index, | |
682 | this_type | |
9783e04a | 683 | ) |
57a1867e DM |
684 | bfd *abfd; |
685 | ieee_data_type *ieee; | |
686 | ieee_symbol_type *last_symbol; | |
687 | unsigned int *symbol_count; | |
688 | ieee_symbol_type ***pptr; | |
689 | unsigned int *max_index; | |
690 | char this_type | |
691 | ; | |
b2c91bd9 SC |
692 | { |
693 | /* Need a new symbol */ | |
9783e04a DM |
694 | unsigned int new_index = must_parse_int (&(ieee->h)); |
695 | if (new_index != last_index || this_type != last_type) | |
696 | { | |
697 | ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd, | |
698 | sizeof (ieee_symbol_type)); | |
699 | if (!new_symbol) | |
a9713b91 | 700 | return NULL; |
9783e04a DM |
701 | |
702 | new_symbol->index = new_index; | |
703 | last_index = new_index; | |
704 | (*symbol_count)++; | |
705 | **pptr = new_symbol; | |
706 | *pptr = &new_symbol->next; | |
707 | if (new_index > *max_index) | |
708 | { | |
709 | *max_index = new_index; | |
710 | } | |
711 | last_type = this_type; | |
e4d27380 | 712 | new_symbol->symbol.section = bfd_abs_section_ptr; |
9783e04a DM |
713 | return new_symbol; |
714 | } | |
b2c91bd9 SC |
715 | return last_symbol; |
716 | } | |
9783e04a | 717 | |
326e32d7 | 718 | static boolean |
57a1867e DM |
719 | ieee_slurp_external_symbols (abfd) |
720 | bfd *abfd; | |
87f86b4e | 721 | { |
9783e04a | 722 | ieee_data_type *ieee = IEEE_DATA (abfd); |
87f86b4e DHW |
723 | file_ptr offset = ieee->w.r.external_part; |
724 | ||
725 | ieee_symbol_type **prev_symbols_ptr = &ieee->external_symbols; | |
726 | ieee_symbol_type **prev_reference_ptr = &ieee->external_reference; | |
9783e04a | 727 | ieee_symbol_type *symbol = (ieee_symbol_type *) NULL; |
87f86b4e DHW |
728 | unsigned int symbol_count = 0; |
729 | boolean loop = true; | |
b2c91bd9 | 730 | last_index = 0xffffff; |
87f86b4e DHW |
731 | ieee->symbol_table_full = true; |
732 | ||
9783e04a | 733 | ieee_seek (abfd, offset); |
87f86b4e | 734 | |
9783e04a DM |
735 | while (loop) |
736 | { | |
737 | switch (this_byte (&(ieee->h))) | |
738 | { | |
739 | case ieee_nn_record: | |
740 | next_byte (&(ieee->h)); | |
aff6e0b4 | 741 | |
9783e04a DM |
742 | symbol = get_symbol (abfd, ieee, symbol, &symbol_count, |
743 | &prev_symbols_ptr, | |
e4d27380 | 744 | &ieee->external_symbol_max_index, 'I'); |
326e32d7 ILT |
745 | if (symbol == NULL) |
746 | return false; | |
b2c91bd9 | 747 | |
9783e04a DM |
748 | symbol->symbol.the_bfd = abfd; |
749 | symbol->symbol.name = read_id (&(ieee->h)); | |
c3246d9b | 750 | symbol->symbol.udata.p = (PTR) NULL; |
9783e04a DM |
751 | symbol->symbol.flags = BSF_NO_FLAGS; |
752 | break; | |
753 | case ieee_external_symbol_enum: | |
754 | next_byte (&(ieee->h)); | |
b2c91bd9 | 755 | |
9783e04a DM |
756 | symbol = get_symbol (abfd, ieee, symbol, &symbol_count, |
757 | &prev_symbols_ptr, | |
758 | &ieee->external_symbol_max_index, 'D'); | |
326e32d7 ILT |
759 | if (symbol == NULL) |
760 | return false; | |
87f86b4e | 761 | |
9783e04a | 762 | BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index); |
b2c91bd9 | 763 | |
9783e04a DM |
764 | symbol->symbol.the_bfd = abfd; |
765 | symbol->symbol.name = read_id (&(ieee->h)); | |
c3246d9b | 766 | symbol->symbol.udata.p = (PTR) NULL; |
9783e04a DM |
767 | symbol->symbol.flags = BSF_NO_FLAGS; |
768 | break; | |
769 | case ieee_attribute_record_enum >> 8: | |
770 | { | |
771 | unsigned int symbol_name_index; | |
772 | unsigned int symbol_type_index; | |
773 | unsigned int symbol_attribute_def; | |
774 | bfd_vma value; | |
e4d27380 | 775 | switch (read_2bytes (ieee)) |
9783e04a | 776 | { |
e4d27380 ILT |
777 | case ieee_attribute_record_enum: |
778 | symbol_name_index = must_parse_int (&(ieee->h)); | |
779 | symbol_type_index = must_parse_int (&(ieee->h)); | |
780 | symbol_attribute_def = must_parse_int (&(ieee->h)); | |
781 | switch (symbol_attribute_def) | |
782 | { | |
783 | case 8: | |
784 | case 19: | |
785 | parse_int (&ieee->h, &value); | |
786 | break; | |
787 | default: | |
788 | (*_bfd_error_handler) | |
789 | ("%s: unimplemented ATI record %u for symbol %u", | |
790 | bfd_get_filename (abfd), symbol_attribute_def, | |
791 | symbol_name_index); | |
792 | bfd_set_error (bfd_error_bad_value); | |
793 | return false; | |
794 | break; | |
795 | } | |
796 | break; | |
797 | case ieee_external_reference_info_record_enum: | |
798 | /* Skip over ATX record. */ | |
799 | parse_int (&(ieee->h), &value); | |
9783e04a DM |
800 | parse_int (&(ieee->h), &value); |
801 | parse_int (&(ieee->h), &value); | |
9783e04a DM |
802 | parse_int (&(ieee->h), &value); |
803 | break; | |
804 | } | |
b2c91bd9 | 805 | } |
9783e04a DM |
806 | break; |
807 | case ieee_value_record_enum >> 8: | |
808 | { | |
809 | unsigned int symbol_name_index; | |
810 | ieee_symbol_index_type symbol_ignore; | |
811 | boolean pcrel_ignore; | |
812 | unsigned int extra; | |
813 | next_byte (&(ieee->h)); | |
814 | next_byte (&(ieee->h)); | |
815 | ||
816 | symbol_name_index = must_parse_int (&(ieee->h)); | |
817 | parse_expression (ieee, | |
818 | &symbol->symbol.value, | |
819 | &symbol_ignore, | |
820 | &pcrel_ignore, | |
821 | &extra, | |
822 | &symbol->symbol.section); | |
823 | ||
824 | symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT; | |
e98e6ec1 | 825 | |
b2c91bd9 | 826 | } |
9783e04a DM |
827 | break; |
828 | case ieee_weak_external_reference_enum: | |
829 | { | |
830 | bfd_vma size; | |
831 | bfd_vma value; | |
832 | next_byte (&(ieee->h)); | |
833 | /* Throw away the external reference index */ | |
834 | (void) must_parse_int (&(ieee->h)); | |
835 | /* Fetch the default size if not resolved */ | |
836 | size = must_parse_int (&(ieee->h)); | |
837 | /* Fetch the defautlt value if available */ | |
838 | if (parse_int (&(ieee->h), &value) == false) | |
839 | { | |
840 | value = 0; | |
841 | } | |
842 | /* This turns into a common */ | |
c3246d9b | 843 | symbol->symbol.section = bfd_com_section_ptr; |
9783e04a DM |
844 | symbol->symbol.value = size; |
845 | } | |
846 | break; | |
87f86b4e | 847 | |
9783e04a DM |
848 | case ieee_external_reference_enum: |
849 | next_byte (&(ieee->h)); | |
b2c91bd9 | 850 | |
9783e04a DM |
851 | symbol = get_symbol (abfd, ieee, symbol, &symbol_count, |
852 | &prev_reference_ptr, | |
853 | &ieee->external_reference_max_index, 'X'); | |
326e32d7 ILT |
854 | if (symbol == NULL) |
855 | return false; | |
b2c91bd9 | 856 | |
9783e04a DM |
857 | symbol->symbol.the_bfd = abfd; |
858 | symbol->symbol.name = read_id (&(ieee->h)); | |
c3246d9b ILT |
859 | symbol->symbol.udata.p = (PTR) NULL; |
860 | symbol->symbol.section = bfd_und_section_ptr; | |
9783e04a DM |
861 | symbol->symbol.value = (bfd_vma) 0; |
862 | symbol->symbol.flags = 0; | |
b2c91bd9 | 863 | |
9783e04a DM |
864 | BFD_ASSERT (symbol->index >= ieee->external_reference_min_index); |
865 | break; | |
87f86b4e | 866 | |
9783e04a DM |
867 | default: |
868 | loop = false; | |
869 | } | |
87f86b4e | 870 | } |
87f86b4e | 871 | |
9783e04a DM |
872 | if (ieee->external_symbol_max_index != 0) |
873 | { | |
874 | ieee->external_symbol_count = | |
875 | ieee->external_symbol_max_index - | |
876 | ieee->external_symbol_min_index + 1; | |
877 | } | |
878 | else | |
879 | { | |
880 | ieee->external_symbol_count = 0; | |
881 | } | |
87f86b4e | 882 | |
9783e04a DM |
883 | if (ieee->external_reference_max_index != 0) |
884 | { | |
885 | ieee->external_reference_count = | |
886 | ieee->external_reference_max_index - | |
87f86b4e | 887 | ieee->external_reference_min_index + 1; |
9783e04a DM |
888 | } |
889 | else | |
890 | { | |
891 | ieee->external_reference_count = 0; | |
892 | } | |
87f86b4e DHW |
893 | |
894 | abfd->symcount = | |
9783e04a | 895 | ieee->external_reference_count + ieee->external_symbol_count; |
b2c91bd9 | 896 | |
9783e04a DM |
897 | if (symbol_count != abfd->symcount) |
898 | { | |
899 | /* There are gaps in the table -- */ | |
900 | ieee->symbol_table_full = false; | |
901 | } | |
b2c91bd9 | 902 | |
9783e04a DM |
903 | *prev_symbols_ptr = (ieee_symbol_type *) NULL; |
904 | *prev_reference_ptr = (ieee_symbol_type *) NULL; | |
326e32d7 ILT |
905 | |
906 | return true; | |
87f86b4e DHW |
907 | } |
908 | ||
326e32d7 | 909 | static boolean |
57a1867e DM |
910 | ieee_slurp_symbol_table (abfd) |
911 | bfd *abfd; | |
87f86b4e | 912 | { |
9783e04a DM |
913 | if (IEEE_DATA (abfd)->read_symbols == false) |
914 | { | |
326e32d7 ILT |
915 | if (! ieee_slurp_external_symbols (abfd)) |
916 | return false; | |
9783e04a DM |
917 | IEEE_DATA (abfd)->read_symbols = true; |
918 | } | |
326e32d7 | 919 | return true; |
87f86b4e DHW |
920 | } |
921 | ||
326e32d7 | 922 | long |
57a1867e DM |
923 | ieee_get_symtab_upper_bound (abfd) |
924 | bfd *abfd; | |
87f86b4e | 925 | { |
326e32d7 ILT |
926 | if (! ieee_slurp_symbol_table (abfd)) |
927 | return -1; | |
87f86b4e | 928 | |
9783e04a DM |
929 | return (abfd->symcount != 0) ? |
930 | (abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0; | |
87f86b4e DHW |
931 | } |
932 | ||
9783e04a | 933 | /* |
87f86b4e DHW |
934 | Move from our internal lists to the canon table, and insert in |
935 | symbol index order | |
936 | */ | |
937 | ||
2f3508ad | 938 | extern const bfd_target ieee_vec; |
9783e04a | 939 | |
326e32d7 | 940 | long |
57a1867e DM |
941 | ieee_get_symtab (abfd, location) |
942 | bfd *abfd; | |
943 | asymbol **location; | |
87f86b4e DHW |
944 | { |
945 | ieee_symbol_type *symp; | |
946 | static bfd dummy_bfd; | |
947 | static asymbol empty_symbol = | |
9783e04a | 948 | /* the_bfd, name, value, attr, section */ |
c3246d9b | 949 | {&dummy_bfd, " ieee empty", (symvalue) 0, BSF_DEBUGGING, bfd_abs_section_ptr}; |
b2c91bd9 | 950 | |
9783e04a DM |
951 | if (abfd->symcount) |
952 | { | |
953 | ieee_data_type *ieee = IEEE_DATA (abfd); | |
954 | dummy_bfd.xvec = &ieee_vec; | |
326e32d7 ILT |
955 | if (! ieee_slurp_symbol_table (abfd)) |
956 | return -1; | |
b2c91bd9 | 957 | |
9783e04a DM |
958 | if (ieee->symbol_table_full == false) |
959 | { | |
960 | /* Arrgh - there are gaps in the table, run through and fill them */ | |
961 | /* up with pointers to a null place */ | |
962 | unsigned int i; | |
963 | for (i = 0; i < abfd->symcount; i++) | |
964 | { | |
965 | location[i] = &empty_symbol; | |
966 | } | |
967 | } | |
87f86b4e | 968 | |
9783e04a DM |
969 | ieee->external_symbol_base_offset = -ieee->external_symbol_min_index; |
970 | for (symp = IEEE_DATA (abfd)->external_symbols; | |
971 | symp != (ieee_symbol_type *) NULL; | |
972 | symp = symp->next) | |
973 | { | |
974 | /* Place into table at correct index locations */ | |
975 | location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol; | |
976 | } | |
87f86b4e | 977 | |
9783e04a DM |
978 | /* The external refs are indexed in a bit */ |
979 | ieee->external_reference_base_offset = | |
980 | -ieee->external_reference_min_index + ieee->external_symbol_count; | |
87f86b4e | 981 | |
9783e04a DM |
982 | for (symp = IEEE_DATA (abfd)->external_reference; |
983 | symp != (ieee_symbol_type *) NULL; | |
984 | symp = symp->next) | |
985 | { | |
986 | location[symp->index + ieee->external_reference_base_offset] = | |
987 | &symp->symbol; | |
87f86b4e | 988 | |
9783e04a DM |
989 | } |
990 | } | |
991 | if (abfd->symcount) | |
992 | { | |
993 | location[abfd->symcount] = (asymbol *) NULL; | |
294eaca4 | 994 | } |
87f86b4e DHW |
995 | return abfd->symcount; |
996 | } | |
9783e04a | 997 | |
b2c91bd9 | 998 | static asection * |
57a1867e DM |
999 | get_section_entry (abfd, ieee, index) |
1000 | bfd *abfd; | |
1001 | ieee_data_type *ieee; | |
1002 | unsigned int index; | |
9783e04a | 1003 | { |
6c58561e ILT |
1004 | if (index >= ieee->section_table_size) |
1005 | { | |
1006 | unsigned int c, i; | |
1007 | asection **n; | |
1008 | ||
1009 | c = ieee->section_table_size; | |
1010 | if (c == 0) | |
1011 | c = 20; | |
1012 | while (c <= index) | |
1013 | c *= 2; | |
1014 | ||
1015 | n = ((asection **) | |
1016 | bfd_realloc (ieee->section_table, c * sizeof (asection *))); | |
1017 | if (n == NULL) | |
1018 | return NULL; | |
1019 | ||
1020 | for (i = ieee->section_table_size; i < c; i++) | |
1021 | n[i] = NULL; | |
1022 | ||
1023 | ieee->section_table = n; | |
1024 | ieee->section_table_size = c; | |
1025 | } | |
1026 | ||
9783e04a DM |
1027 | if (ieee->section_table[index] == (asection *) NULL) |
1028 | { | |
1029 | char *tmp = bfd_alloc (abfd, 11); | |
1030 | asection *section; | |
1031 | ||
1032 | if (!tmp) | |
a9713b91 | 1033 | return NULL; |
9783e04a DM |
1034 | sprintf (tmp, " fsec%4d", index); |
1035 | section = bfd_make_section (abfd, tmp); | |
1036 | ieee->section_table[index] = section; | |
1037 | section->flags = SEC_NO_FLAGS; | |
1038 | section->target_index = index; | |
1039 | ieee->section_table[index] = section; | |
1040 | } | |
b2c91bd9 SC |
1041 | return ieee->section_table[index]; |
1042 | } | |
87f86b4e DHW |
1043 | |
1044 | static void | |
57a1867e DM |
1045 | ieee_slurp_sections (abfd) |
1046 | bfd *abfd; | |
87f86b4e | 1047 | { |
9783e04a | 1048 | ieee_data_type *ieee = IEEE_DATA (abfd); |
87f86b4e | 1049 | file_ptr offset = ieee->w.r.section_part; |
9783e04a | 1050 | asection *section = (asection *) NULL; |
b07d03ba | 1051 | char *name; |
87f86b4e | 1052 | |
9783e04a DM |
1053 | if (offset != 0) |
1054 | { | |
1055 | bfd_byte section_type[3]; | |
1056 | ieee_seek (abfd, offset); | |
1057 | while (true) | |
1058 | { | |
1059 | switch (this_byte (&(ieee->h))) | |
71858486 | 1060 | { |
9783e04a DM |
1061 | case ieee_section_type_enum: |
1062 | { | |
1063 | unsigned int section_index; | |
1064 | next_byte (&(ieee->h)); | |
1065 | section_index = must_parse_int (&(ieee->h)); | |
b2c91bd9 | 1066 | |
9783e04a DM |
1067 | section = get_section_entry (abfd, ieee, section_index); |
1068 | ||
1069 | section_type[0] = this_byte_and_next (&(ieee->h)); | |
e4d27380 ILT |
1070 | |
1071 | /* Set minimal section attributes. Attributes are | |
1072 | extended later, based on section contents. */ | |
1073 | ||
9783e04a DM |
1074 | switch (section_type[0]) |
1075 | { | |
1076 | case 0xC1: | |
1077 | /* Normal attributes for absolute sections */ | |
1078 | section_type[1] = this_byte (&(ieee->h)); | |
e4d27380 | 1079 | section->flags = SEC_ALLOC; |
9783e04a DM |
1080 | switch (section_type[1]) |
1081 | { | |
1082 | case 0xD3: /* AS Absolute section attributes */ | |
1083 | next_byte (&(ieee->h)); | |
1084 | section_type[2] = this_byte (&(ieee->h)); | |
1085 | switch (section_type[2]) | |
1086 | { | |
1087 | case 0xD0: | |
1088 | /* Normal code */ | |
1089 | next_byte (&(ieee->h)); | |
e4d27380 | 1090 | section->flags |= SEC_CODE; |
9783e04a DM |
1091 | break; |
1092 | case 0xC4: | |
9783e04a | 1093 | /* Normal data */ |
e4d27380 ILT |
1094 | next_byte (&(ieee->h)); |
1095 | section->flags |= SEC_DATA; | |
9783e04a DM |
1096 | break; |
1097 | case 0xD2: | |
1098 | next_byte (&(ieee->h)); | |
1099 | /* Normal rom data */ | |
e4d27380 | 1100 | section->flags |= SEC_ROM | SEC_DATA; |
9783e04a DM |
1101 | break; |
1102 | default: | |
1103 | break; | |
1104 | } | |
1105 | } | |
1106 | break; | |
1107 | case 0xC3: /* Named relocatable sections (type C) */ | |
1108 | section_type[1] = this_byte (&(ieee->h)); | |
e4d27380 | 1109 | section->flags = SEC_ALLOC; |
9783e04a DM |
1110 | switch (section_type[1]) |
1111 | { | |
1112 | case 0xD0: /* Normal code (CP) */ | |
1113 | next_byte (&(ieee->h)); | |
e4d27380 | 1114 | section->flags |= SEC_CODE; |
9783e04a DM |
1115 | break; |
1116 | case 0xC4: /* Normal data (CD) */ | |
1117 | next_byte (&(ieee->h)); | |
e4d27380 | 1118 | section->flags |= SEC_DATA; |
9783e04a DM |
1119 | break; |
1120 | case 0xD2: /* Normal rom data (CR) */ | |
1121 | next_byte (&(ieee->h)); | |
e4d27380 | 1122 | section->flags |= SEC_ROM | SEC_DATA; |
9783e04a DM |
1123 | break; |
1124 | default: | |
1125 | break; | |
1126 | } | |
1127 | } | |
1128 | ||
1129 | /* Read section name, use it if non empty. */ | |
1130 | name = read_id (&ieee->h); | |
1131 | if (name[0]) | |
1132 | section->name = name; | |
1133 | ||
1134 | /* Skip these fields, which we don't care about */ | |
1135 | { | |
1136 | bfd_vma parent, brother, context; | |
1137 | parse_int (&(ieee->h), &parent); | |
1138 | parse_int (&(ieee->h), &brother); | |
1139 | parse_int (&(ieee->h), &context); | |
1140 | } | |
1141 | } | |
b2c91bd9 | 1142 | break; |
9783e04a DM |
1143 | case ieee_section_alignment_enum: |
1144 | { | |
1145 | unsigned int section_index; | |
1146 | bfd_vma value; | |
1147 | asection *section; | |
1148 | next_byte (&(ieee->h)); | |
1149 | section_index = must_parse_int (&ieee->h); | |
1150 | section = get_section_entry (abfd, ieee, section_index); | |
1151 | if (section_index > ieee->section_count) | |
1152 | { | |
1153 | ieee->section_count = section_index; | |
1154 | } | |
1155 | section->alignment_power = | |
1156 | bfd_log2 (must_parse_int (&ieee->h)); | |
1157 | (void) parse_int (&(ieee->h), &value); | |
1158 | } | |
b2c91bd9 | 1159 | break; |
9783e04a DM |
1160 | case ieee_e2_first_byte_enum: |
1161 | { | |
1162 | ieee_record_enum_type t = (ieee_record_enum_type) (read_2bytes (&(ieee->h))); | |
1163 | ||
1164 | switch (t) | |
1165 | { | |
1166 | case ieee_section_size_enum: | |
1167 | section = ieee->section_table[must_parse_int (&(ieee->h))]; | |
1168 | section->_raw_size = must_parse_int (&(ieee->h)); | |
1169 | break; | |
1170 | case ieee_physical_region_size_enum: | |
1171 | section = ieee->section_table[must_parse_int (&(ieee->h))]; | |
1172 | section->_raw_size = must_parse_int (&(ieee->h)); | |
1173 | break; | |
1174 | case ieee_region_base_address_enum: | |
1175 | section = ieee->section_table[must_parse_int (&(ieee->h))]; | |
1176 | section->vma = must_parse_int (&(ieee->h)); | |
14578105 | 1177 | section->lma = section->vma; |
9783e04a DM |
1178 | break; |
1179 | case ieee_mau_size_enum: | |
1180 | must_parse_int (&(ieee->h)); | |
1181 | must_parse_int (&(ieee->h)); | |
1182 | break; | |
1183 | case ieee_m_value_enum: | |
1184 | must_parse_int (&(ieee->h)); | |
1185 | must_parse_int (&(ieee->h)); | |
1186 | break; | |
1187 | case ieee_section_base_address_enum: | |
1188 | section = ieee->section_table[must_parse_int (&(ieee->h))]; | |
1189 | section->vma = must_parse_int (&(ieee->h)); | |
14578105 | 1190 | section->lma = section->vma; |
9783e04a DM |
1191 | break; |
1192 | case ieee_section_offset_enum: | |
1193 | (void) must_parse_int (&(ieee->h)); | |
1194 | (void) must_parse_int (&(ieee->h)); | |
1195 | break; | |
1196 | default: | |
1197 | return; | |
1198 | } | |
1199 | } | |
b2c91bd9 SC |
1200 | break; |
1201 | default: | |
1202 | return; | |
1203 | } | |
9783e04a | 1204 | } |
87f86b4e | 1205 | } |
87f86b4e DHW |
1206 | } |
1207 | ||
f8254a3c ILT |
1208 | /* Make a section for the debugging information, if any. We don't try |
1209 | to interpret the debugging information; we just point the section | |
1210 | at the area in the file so that program which understand can dig it | |
1211 | out. */ | |
1212 | ||
1213 | static boolean | |
1214 | ieee_slurp_debug (abfd) | |
1215 | bfd *abfd; | |
1216 | { | |
1217 | ieee_data_type *ieee = IEEE_DATA (abfd); | |
1218 | asection *sec; | |
1219 | ||
1220 | if (ieee->w.r.debug_information_part == 0) | |
1221 | return true; | |
1222 | ||
1223 | sec = bfd_make_section (abfd, ".debug"); | |
1224 | if (sec == NULL) | |
1225 | return false; | |
1226 | sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS; | |
1227 | sec->filepos = ieee->w.r.debug_information_part; | |
1228 | sec->_raw_size = ieee->w.r.data_part - ieee->w.r.debug_information_part; | |
1229 | ||
1230 | return true; | |
1231 | } | |
1232 | \f | |
87f86b4e | 1233 | /*********************************************************************** |
9783e04a | 1234 | * archive stuff |
87f86b4e | 1235 | */ |
9783e04a | 1236 | |
2f3508ad | 1237 | const bfd_target * |
57a1867e DM |
1238 | ieee_archive_p (abfd) |
1239 | bfd *abfd; | |
87f86b4e DHW |
1240 | { |
1241 | char *library; | |
1242 | boolean loop; | |
87f86b4e | 1243 | unsigned int i; |
70e00914 | 1244 | unsigned char buffer[512]; |
f8e01940 | 1245 | file_ptr buffer_offset = 0; |
69e0d34d | 1246 | ieee_ar_data_type *save = abfd->tdata.ieee_ar_data; |
9783e04a DM |
1247 | ieee_ar_data_type *ieee; |
1248 | abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type)); | |
1249 | if (!abfd->tdata.ieee_ar_data) | |
a9713b91 | 1250 | return NULL; |
9783e04a | 1251 | ieee = IEEE_AR_DATA (abfd); |
9465d03e | 1252 | |
4002f18a ILT |
1253 | /* FIXME: Check return value. I'm not sure whether it needs to read |
1254 | the entire buffer or not. */ | |
9783e04a | 1255 | bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); |
d0ec7a8e | 1256 | |
6f715d66 SC |
1257 | ieee->h.first_byte = buffer; |
1258 | ieee->h.input_p = buffer; | |
d0ec7a8e | 1259 | |
6f715d66 SC |
1260 | ieee->h.abfd = abfd; |
1261 | ||
9783e04a DM |
1262 | if (this_byte (&(ieee->h)) != Module_Beginning) |
1263 | { | |
1264 | abfd->tdata.ieee_ar_data = save; | |
2f3508ad | 1265 | return (const bfd_target *) NULL; |
69e0d34d | 1266 | } |
6f715d66 | 1267 | |
9783e04a DM |
1268 | next_byte (&(ieee->h)); |
1269 | library = read_id (&(ieee->h)); | |
1270 | if (strcmp (library, "LIBRARY") != 0) | |
1271 | { | |
1272 | bfd_release (abfd, ieee); | |
1273 | abfd->tdata.ieee_ar_data = save; | |
2f3508ad | 1274 | return (const bfd_target *) NULL; |
9783e04a | 1275 | } |
87f86b4e | 1276 | /* Throw away the filename */ |
9783e04a | 1277 | read_id (&(ieee->h)); |
9465d03e | 1278 | |
6f715d66 SC |
1279 | ieee->element_count = 0; |
1280 | ieee->element_index = 0; | |
87f86b4e | 1281 | |
9783e04a DM |
1282 | next_byte (&(ieee->h)); /* Drop the ad part */ |
1283 | must_parse_int (&(ieee->h)); /* And the two dummy numbers */ | |
1284 | must_parse_int (&(ieee->h)); | |
87f86b4e DHW |
1285 | |
1286 | loop = true; | |
1287 | /* Read the index of the BB table */ | |
9783e04a DM |
1288 | while (loop) |
1289 | { | |
1290 | ieee_ar_obstack_type t; | |
1291 | int rec = read_2bytes (&(ieee->h)); | |
1292 | if (rec == (int) ieee_assign_value_to_variable_enum) | |
1293 | { | |
1294 | must_parse_int (&(ieee->h)); | |
1295 | t.file_offset = must_parse_int (&(ieee->h)); | |
1296 | t.abfd = (bfd *) NULL; | |
1297 | ieee->element_count++; | |
1298 | ||
14578105 | 1299 | bfd_alloc_grow (abfd, (PTR) &t, sizeof t); |
9783e04a DM |
1300 | |
1301 | /* Make sure that we don't go over the end of the buffer */ | |
1302 | ||
ae115e51 | 1303 | if ((size_t) ieee_pos (abfd) > sizeof (buffer) / 2) |
9783e04a DM |
1304 | { |
1305 | /* Past half way, reseek and reprime */ | |
1306 | buffer_offset += ieee_pos (abfd); | |
4002f18a ILT |
1307 | if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0) |
1308 | return NULL; | |
1309 | /* FIXME: Check return value. I'm not sure whether it | |
1310 | needs to read the entire buffer or not. */ | |
9783e04a DM |
1311 | bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); |
1312 | ieee->h.first_byte = buffer; | |
1313 | ieee->h.input_p = buffer; | |
1314 | } | |
1315 | } | |
1316 | else | |
1317 | loop = false; | |
87f86b4e | 1318 | } |
6f715d66 | 1319 | |
14578105 | 1320 | ieee->elements = (ieee_ar_obstack_type *) bfd_alloc_finish (abfd); |
9783e04a | 1321 | if (!ieee->elements) |
14578105 | 1322 | return (const bfd_target *) NULL; |
87f86b4e DHW |
1323 | |
1324 | /* Now scan the area again, and replace BB offsets with file */ | |
1325 | /* offsets */ | |
1326 | ||
9783e04a DM |
1327 | for (i = 2; i < ieee->element_count; i++) |
1328 | { | |
4002f18a ILT |
1329 | if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0) |
1330 | return NULL; | |
1331 | /* FIXME: Check return value. I'm not sure whether it needs to | |
1332 | read the entire buffer or not. */ | |
9783e04a DM |
1333 | bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); |
1334 | ieee->h.first_byte = buffer; | |
1335 | ieee->h.input_p = buffer; | |
1336 | ||
1337 | next_byte (&(ieee->h)); /* Drop F8 */ | |
1338 | next_byte (&(ieee->h)); /* Drop 14 */ | |
1339 | must_parse_int (&(ieee->h)); /* Drop size of block */ | |
1340 | if (must_parse_int (&(ieee->h)) != 0) | |
1341 | { | |
1342 | /* This object has been deleted */ | |
1343 | ieee->elements[i].file_offset = 0; | |
1344 | } | |
1345 | else | |
1346 | { | |
1347 | ieee->elements[i].file_offset = must_parse_int (&(ieee->h)); | |
1348 | } | |
87f86b4e | 1349 | } |
87f86b4e | 1350 | |
aff6e0b4 | 1351 | /* abfd->has_armap = ;*/ |
87f86b4e DHW |
1352 | return abfd->xvec; |
1353 | } | |
1354 | ||
301dfc71 | 1355 | static boolean |
57a1867e DM |
1356 | ieee_mkobject (abfd) |
1357 | bfd *abfd; | |
9783e04a DM |
1358 | { |
1359 | abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, sizeof (ieee_data_type)); | |
1360 | return abfd->tdata.ieee_data ? true : false; | |
301dfc71 SC |
1361 | } |
1362 | ||
2f3508ad | 1363 | const bfd_target * |
57a1867e DM |
1364 | ieee_object_p (abfd) |
1365 | bfd *abfd; | |
87f86b4e DHW |
1366 | { |
1367 | char *processor; | |
1368 | unsigned int part; | |
301dfc71 | 1369 | ieee_data_type *ieee; |
70e00914 | 1370 | unsigned char buffer[300]; |
9783e04a | 1371 | ieee_data_type *save = IEEE_DATA (abfd); |
70e00914 | 1372 | |
e98e6ec1 | 1373 | abfd->tdata.ieee_data = 0; |
9783e04a DM |
1374 | ieee_mkobject (abfd); |
1375 | ||
1376 | ieee = IEEE_DATA (abfd); | |
4002f18a ILT |
1377 | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) |
1378 | goto fail; | |
301dfc71 | 1379 | /* Read the first few bytes in to see if it makes sense */ |
4002f18a ILT |
1380 | /* FIXME: Check return value. I'm not sure whether it needs to read |
1381 | the entire buffer or not. */ | |
9783e04a | 1382 | bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd); |
301dfc71 | 1383 | |
6f715d66 | 1384 | ieee->h.input_p = buffer; |
9783e04a | 1385 | if (this_byte_and_next (&(ieee->h)) != Module_Beginning) |
2f3508ad | 1386 | goto got_wrong_format; |
301dfc71 | 1387 | |
9783e04a DM |
1388 | ieee->read_symbols = false; |
1389 | ieee->read_data = false; | |
301dfc71 SC |
1390 | ieee->section_count = 0; |
1391 | ieee->external_symbol_max_index = 0; | |
1392 | ieee->external_symbol_min_index = IEEE_PUBLIC_BASE; | |
9783e04a | 1393 | ieee->external_reference_min_index = IEEE_REFERENCE_BASE; |
301dfc71 | 1394 | ieee->external_reference_max_index = 0; |
6f715d66 | 1395 | ieee->h.abfd = abfd; |
6c58561e ILT |
1396 | ieee->section_table = NULL; |
1397 | ieee->section_table_size = 0; | |
301dfc71 | 1398 | |
9783e04a DM |
1399 | processor = ieee->mb.processor = read_id (&(ieee->h)); |
1400 | if (strcmp (processor, "LIBRARY") == 0) | |
2f3508ad | 1401 | goto got_wrong_format; |
9783e04a DM |
1402 | ieee->mb.module_name = read_id (&(ieee->h)); |
1403 | if (abfd->filename == (CONST char *) NULL) | |
b2c91bd9 | 1404 | { |
9783e04a | 1405 | abfd->filename = ieee->mb.module_name; |
b2c91bd9 | 1406 | } |
9783e04a DM |
1407 | /* Determine the architecture and machine type of the object file. |
1408 | */ | |
1409 | { | |
a9713b91 | 1410 | const bfd_arch_info_type *arch = bfd_scan_arch (processor); |
9783e04a | 1411 | if (arch == 0) |
2f3508ad | 1412 | goto got_wrong_format; |
9783e04a | 1413 | abfd->arch_info = arch; |
87f86b4e DHW |
1414 | } |
1415 | ||
9783e04a DM |
1416 | if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum) |
1417 | { | |
301dfc71 | 1418 | goto fail; |
87f86b4e | 1419 | } |
9783e04a DM |
1420 | next_byte (&(ieee->h)); |
1421 | ||
1422 | if (parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau) == false) | |
1423 | { | |
301dfc71 | 1424 | goto fail; |
87f86b4e | 1425 | } |
9783e04a DM |
1426 | if (parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address) == false) |
1427 | { | |
301dfc71 | 1428 | goto fail; |
87f86b4e DHW |
1429 | } |
1430 | ||
9783e04a DM |
1431 | /* If there is a byte order info, take it */ |
1432 | if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum || | |
1433 | this_byte (&(ieee->h)) == (int) ieee_variable_M_enum) | |
1434 | next_byte (&(ieee->h)); | |
1435 | ||
1436 | for (part = 0; part < N_W_VARIABLES; part++) | |
1437 | { | |
1438 | boolean ok; | |
1439 | if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum) | |
1440 | { | |
1441 | goto fail; | |
1442 | } | |
1443 | if (this_byte_and_next (&(ieee->h)) != part) | |
1444 | { | |
1445 | goto fail; | |
1446 | } | |
1447 | ||
1448 | ieee->w.offset[part] = parse_i (&(ieee->h), &ok); | |
1449 | if (ok == false) | |
1450 | { | |
1451 | goto fail; | |
1452 | } | |
1453 | ||
1454 | } | |
301dfc71 | 1455 | |
e4d27380 ILT |
1456 | if (ieee->w.r.external_part != 0) |
1457 | abfd->flags = HAS_SYMS; | |
1458 | ||
1459 | /* By now we know that this is a real IEEE file, we're going to read | |
1460 | the whole thing into memory so that we can run up and down it | |
1461 | quickly. We can work out how big the file is from the trailer | |
1462 | record */ | |
1463 | ||
1464 | IEEE_DATA (abfd)->h.first_byte = | |
1465 | (unsigned char *) bfd_alloc (ieee->h.abfd, ieee->w.r.me_record + 1); | |
9783e04a | 1466 | if (!IEEE_DATA (abfd)->h.first_byte) |
a9713b91 | 1467 | goto fail; |
4002f18a ILT |
1468 | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) |
1469 | goto fail; | |
1470 | /* FIXME: Check return value. I'm not sure whether it needs to read | |
1471 | the entire buffer or not. */ | |
e4d27380 ILT |
1472 | bfd_read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1, |
1473 | ieee->w.r.me_record + 1, abfd); | |
301dfc71 | 1474 | |
9783e04a | 1475 | ieee_slurp_sections (abfd); |
f8254a3c ILT |
1476 | |
1477 | if (! ieee_slurp_debug (abfd)) | |
1478 | goto fail; | |
1479 | ||
e4d27380 ILT |
1480 | /* Parse section data to activate file and section flags implied by |
1481 | section contents. */ | |
1482 | ||
1483 | if (! ieee_slurp_section_data (abfd)) | |
1484 | goto fail; | |
1485 | ||
87f86b4e | 1486 | return abfd->xvec; |
2f3508ad ILT |
1487 | got_wrong_format: |
1488 | bfd_set_error (bfd_error_wrong_format); | |
9783e04a DM |
1489 | fail: |
1490 | (void) bfd_release (abfd, ieee); | |
1491 | abfd->tdata.ieee_data = save; | |
2f3508ad | 1492 | return (const bfd_target *) NULL; |
87f86b4e DHW |
1493 | } |
1494 | ||
9783e04a | 1495 | void |
57a1867e DM |
1496 | ieee_get_symbol_info (ignore_abfd, symbol, ret) |
1497 | bfd *ignore_abfd; | |
1498 | asymbol *symbol; | |
1499 | symbol_info *ret; | |
70e00914 KR |
1500 | { |
1501 | bfd_symbol_info (symbol, ret); | |
1502 | if (symbol->name[0] == ' ') | |
1503 | ret->name = "* empty table entry "; | |
1504 | if (!symbol->section) | |
1505 | ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A'; | |
1506 | } | |
87f86b4e | 1507 | |
9783e04a | 1508 | void |
57a1867e DM |
1509 | ieee_print_symbol (ignore_abfd, afile, symbol, how) |
1510 | bfd *ignore_abfd; | |
1511 | PTR afile; | |
1512 | asymbol *symbol; | |
1513 | bfd_print_symbol_type how; | |
87f86b4e | 1514 | { |
9783e04a | 1515 | FILE *file = (FILE *) afile; |
2b1d8a50 | 1516 | |
9783e04a DM |
1517 | switch (how) |
1518 | { | |
1519 | case bfd_print_symbol_name: | |
1520 | fprintf (file, "%s", symbol->name); | |
1521 | break; | |
1522 | case bfd_print_symbol_more: | |
87f86b4e | 1523 | #if 0 |
9783e04a DM |
1524 | fprintf (file, "%4x %2x", aout_symbol (symbol)->desc & 0xffff, |
1525 | aout_symbol (symbol)->other & 0xff); | |
87f86b4e | 1526 | #endif |
9783e04a DM |
1527 | BFD_FAIL (); |
1528 | break; | |
1529 | case bfd_print_symbol_all: | |
301dfc71 | 1530 | { |
14578105 ILT |
1531 | const char *section_name = |
1532 | (symbol->section == (asection *) NULL | |
1533 | ? "*abs" | |
1534 | : symbol->section->name); | |
9783e04a DM |
1535 | if (symbol->name[0] == ' ') |
1536 | { | |
1537 | fprintf (file, "* empty table entry "); | |
1538 | } | |
1539 | else | |
1540 | { | |
1541 | bfd_print_symbol_vandf ((PTR) file, symbol); | |
301dfc71 | 1542 | |
9783e04a DM |
1543 | fprintf (file, " %-5s %04x %02x %s", |
1544 | section_name, | |
1545 | (unsigned) ieee_symbol (symbol)->index, | |
14578105 | 1546 | (unsigned) 0, |
9783e04a DM |
1547 | symbol->name); |
1548 | } | |
301dfc71 | 1549 | } |
9783e04a DM |
1550 | break; |
1551 | } | |
87f86b4e DHW |
1552 | } |
1553 | ||
9783e04a | 1554 | static boolean |
e4d27380 | 1555 | do_one (ieee, current_map, location_ptr, s, iterations) |
57a1867e DM |
1556 | ieee_data_type *ieee; |
1557 | ieee_per_section_type *current_map; | |
1558 | unsigned char *location_ptr; | |
1559 | asection *s; | |
e4d27380 | 1560 | int iterations; |
7564d3d7 | 1561 | { |
9783e04a DM |
1562 | switch (this_byte (&(ieee->h))) |
1563 | { | |
1564 | case ieee_load_constant_bytes_enum: | |
7564d3d7 | 1565 | { |
9783e04a DM |
1566 | unsigned int number_of_maus; |
1567 | unsigned int i; | |
1568 | next_byte (&(ieee->h)); | |
1569 | number_of_maus = must_parse_int (&(ieee->h)); | |
1570 | ||
1571 | for (i = 0; i < number_of_maus; i++) | |
7564d3d7 | 1572 | { |
9783e04a DM |
1573 | location_ptr[current_map->pc++] = this_byte (&(ieee->h)); |
1574 | next_byte (&(ieee->h)); | |
7564d3d7 | 1575 | } |
9783e04a DM |
1576 | } |
1577 | break; | |
7564d3d7 | 1578 | |
9783e04a DM |
1579 | case ieee_load_with_relocation_enum: |
1580 | { | |
1581 | boolean loop = true; | |
1582 | next_byte (&(ieee->h)); | |
1583 | while (loop) | |
7564d3d7 | 1584 | { |
9783e04a DM |
1585 | switch (this_byte (&(ieee->h))) |
1586 | { | |
1587 | case ieee_variable_R_enum: | |
1588 | ||
1589 | case ieee_function_signed_open_b_enum: | |
1590 | case ieee_function_unsigned_open_b_enum: | |
1591 | case ieee_function_either_open_b_enum: | |
7564d3d7 | 1592 | { |
9783e04a DM |
1593 | unsigned int extra = 4; |
1594 | boolean pcrel = false; | |
1595 | asection *section; | |
1596 | ieee_reloc_type *r = | |
1597 | (ieee_reloc_type *) bfd_alloc (ieee->h.abfd, | |
1598 | sizeof (ieee_reloc_type)); | |
1599 | if (!r) | |
a9713b91 | 1600 | return false; |
7564d3d7 | 1601 | |
9783e04a DM |
1602 | *(current_map->reloc_tail_ptr) = r; |
1603 | current_map->reloc_tail_ptr = &r->next; | |
1604 | r->next = (ieee_reloc_type *) NULL; | |
1605 | next_byte (&(ieee->h)); | |
69e0d34d | 1606 | /* abort();*/ |
9783e04a DM |
1607 | r->relent.sym_ptr_ptr = 0; |
1608 | parse_expression (ieee, | |
1609 | &r->relent.addend, | |
1610 | &r->symbol, | |
1611 | &pcrel, &extra, §ion); | |
1612 | r->relent.address = current_map->pc; | |
e4d27380 ILT |
1613 | s->flags |= SEC_RELOC; |
1614 | s->owner->flags |= HAS_RELOC; | |
9783e04a DM |
1615 | s->reloc_count++; |
1616 | if (r->relent.sym_ptr_ptr == 0) | |
1617 | { | |
1618 | r->relent.sym_ptr_ptr = section->symbol_ptr_ptr; | |
1619 | } | |
1620 | ||
1621 | if (this_byte (&(ieee->h)) == (int) ieee_comma) | |
1622 | { | |
1623 | next_byte (&(ieee->h)); | |
1624 | /* Fetch number of bytes to pad */ | |
1625 | extra = must_parse_int (&(ieee->h)); | |
1626 | }; | |
1627 | ||
1628 | switch (this_byte (&(ieee->h))) | |
1629 | { | |
1630 | case ieee_function_signed_close_b_enum: | |
1631 | next_byte (&(ieee->h)); | |
1632 | break; | |
1633 | case ieee_function_unsigned_close_b_enum: | |
1634 | next_byte (&(ieee->h)); | |
1635 | break; | |
1636 | case ieee_function_either_close_b_enum: | |
1637 | next_byte (&(ieee->h)); | |
1638 | break; | |
1639 | default: | |
1640 | break; | |
1641 | } | |
1642 | /* Build a relocation entry for this type */ | |
1643 | /* If pc rel then stick -ve pc into instruction | |
14578105 | 1644 | and take out of reloc .. |
b2c91bd9 | 1645 | |
14578105 ILT |
1646 | I've changed this. It's all too complicated. I |
1647 | keep 0 in the instruction now. */ | |
9783e04a DM |
1648 | |
1649 | switch (extra) | |
1650 | { | |
1651 | case 0: | |
1652 | case 4: | |
1653 | ||
1654 | if (pcrel == true) | |
1655 | { | |
b2c91bd9 | 1656 | #if KEEPMINUSPCININST |
9783e04a DM |
1657 | bfd_put_32 (ieee->h.abfd, -current_map->pc, location_ptr + |
1658 | current_map->pc); | |
1659 | r->relent.howto = &rel32_howto; | |
1660 | r->relent.addend -= | |
1661 | current_map->pc; | |
b2c91bd9 | 1662 | #else |
9783e04a DM |
1663 | bfd_put_32 (ieee->h.abfd, 0, location_ptr + |
1664 | current_map->pc); | |
1665 | r->relent.howto = &rel32_howto; | |
b2c91bd9 | 1666 | #endif |
9783e04a DM |
1667 | } |
1668 | else | |
1669 | { | |
1670 | bfd_put_32 (ieee->h.abfd, 0, location_ptr + | |
1671 | current_map->pc); | |
1672 | r->relent.howto = &abs32_howto; | |
1673 | } | |
1674 | current_map->pc += 4; | |
1675 | break; | |
1676 | case 2: | |
1677 | if (pcrel == true) | |
1678 | { | |
b2c91bd9 | 1679 | #if KEEPMINUSPCININST |
9783e04a DM |
1680 | bfd_put_16 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc); |
1681 | r->relent.addend -= current_map->pc; | |
1682 | r->relent.howto = &rel16_howto; | |
b2c91bd9 SC |
1683 | #else |
1684 | ||
9783e04a DM |
1685 | bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc); |
1686 | r->relent.howto = &rel16_howto; | |
b2c91bd9 | 1687 | #endif |
9783e04a DM |
1688 | } |
1689 | ||
1690 | else | |
1691 | { | |
1692 | bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc); | |
1693 | r->relent.howto = &abs16_howto; | |
1694 | } | |
1695 | current_map->pc += 2; | |
1696 | break; | |
1697 | case 1: | |
1698 | if (pcrel == true) | |
1699 | { | |
b2c91bd9 | 1700 | #if KEEPMINUSPCININST |
9783e04a DM |
1701 | bfd_put_8 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc); |
1702 | r->relent.addend -= current_map->pc; | |
1703 | r->relent.howto = &rel8_howto; | |
b2c91bd9 | 1704 | #else |
9783e04a DM |
1705 | bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc); |
1706 | r->relent.howto = &rel8_howto; | |
b2c91bd9 | 1707 | #endif |
9783e04a DM |
1708 | } |
1709 | else | |
1710 | { | |
1711 | bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc); | |
1712 | r->relent.howto = &abs8_howto; | |
1713 | } | |
1714 | current_map->pc += 1; | |
1715 | break; | |
1716 | ||
1717 | default: | |
1718 | BFD_FAIL (); | |
e4d27380 | 1719 | return false; |
9783e04a DM |
1720 | } |
1721 | } | |
1722 | break; | |
1723 | default: | |
1724 | { | |
1725 | bfd_vma this_size; | |
1726 | if (parse_int (&(ieee->h), &this_size) == true) | |
1727 | { | |
1728 | unsigned int i; | |
1729 | for (i = 0; i < this_size; i++) | |
1730 | { | |
1731 | location_ptr[current_map->pc++] = this_byte (&(ieee->h)); | |
1732 | next_byte (&(ieee->h)); | |
1733 | } | |
1734 | } | |
1735 | else | |
1736 | { | |
1737 | loop = false; | |
1738 | } | |
7564d3d7 | 1739 | } |
9783e04a | 1740 | } |
e4d27380 ILT |
1741 | |
1742 | /* Prevent more than the first load-item of an LR record | |
1743 | from being repeated (MRI convention). */ | |
1744 | if (iterations != 1) | |
1745 | loop = false; | |
7564d3d7 SC |
1746 | } |
1747 | } | |
9783e04a DM |
1748 | } |
1749 | return true; | |
7564d3d7 | 1750 | } |
87f86b4e | 1751 | |
6f715d66 | 1752 | /* Read in all the section data and relocation stuff too */ |
9783e04a | 1753 | static boolean |
57a1867e DM |
1754 | ieee_slurp_section_data (abfd) |
1755 | bfd *abfd; | |
87f86b4e | 1756 | { |
9783e04a DM |
1757 | bfd_byte *location_ptr = (bfd_byte *) NULL; |
1758 | ieee_data_type *ieee = IEEE_DATA (abfd); | |
1759 | unsigned int section_number; | |
87f86b4e | 1760 | |
9783e04a | 1761 | ieee_per_section_type *current_map = (ieee_per_section_type *) NULL; |
87f86b4e DHW |
1762 | asection *s; |
1763 | /* Seek to the start of the data area */ | |
9783e04a DM |
1764 | if (ieee->read_data == true) |
1765 | return true; | |
87f86b4e | 1766 | ieee->read_data = true; |
9783e04a | 1767 | ieee_seek (abfd, ieee->w.r.data_part); |
87f86b4e DHW |
1768 | |
1769 | /* Allocate enough space for all the section contents */ | |
1770 | ||
9783e04a DM |
1771 | for (s = abfd->sections; s != (asection *) NULL; s = s->next) |
1772 | { | |
1773 | ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd; | |
f8254a3c ILT |
1774 | if ((s->flags & SEC_DEBUGGING) != 0) |
1775 | continue; | |
9783e04a DM |
1776 | per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size); |
1777 | if (!per->data) | |
a9713b91 | 1778 | return false; |
9783e04a DM |
1779 | /*SUPPRESS 68*/ |
1780 | per->reloc_tail_ptr = | |
1781 | (ieee_reloc_type **) & (s->relocation); | |
1782 | } | |
87f86b4e | 1783 | |
9783e04a DM |
1784 | while (true) |
1785 | { | |
1786 | switch (this_byte (&(ieee->h))) | |
87f86b4e | 1787 | { |
7564d3d7 SC |
1788 | /* IF we see anything strange then quit */ |
1789 | default: | |
1790 | return true; | |
87f86b4e | 1791 | |
7564d3d7 | 1792 | case ieee_set_current_section_enum: |
9783e04a DM |
1793 | next_byte (&(ieee->h)); |
1794 | section_number = must_parse_int (&(ieee->h)); | |
7564d3d7 | 1795 | s = ieee->section_table[section_number]; |
e4d27380 | 1796 | s->flags |= SEC_LOAD | SEC_HAS_CONTENTS; |
7564d3d7 SC |
1797 | current_map = (ieee_per_section_type *) s->used_by_bfd; |
1798 | location_ptr = current_map->data - s->vma; | |
1799 | /* The document I have says that Microtec's compilers reset */ | |
1800 | /* this after a sec section, even though the standard says not */ | |
1801 | /* to. SO .. */ | |
9783e04a | 1802 | current_map->pc = s->vma; |
7564d3d7 | 1803 | break; |
87f86b4e | 1804 | |
7564d3d7 | 1805 | case ieee_e2_first_byte_enum: |
9783e04a DM |
1806 | next_byte (&(ieee->h)); |
1807 | switch (this_byte (&(ieee->h))) | |
1808 | { | |
1809 | case ieee_set_current_pc_enum & 0xff: | |
7564d3d7 | 1810 | { |
9783e04a DM |
1811 | bfd_vma value; |
1812 | ieee_symbol_index_type symbol; | |
1813 | unsigned int extra; | |
1814 | boolean pcrel; | |
1815 | next_byte (&(ieee->h)); | |
1816 | must_parse_int (&(ieee->h)); /* Thow away section #*/ | |
1817 | parse_expression (ieee, &value, | |
1818 | &symbol, | |
1819 | &pcrel, &extra, | |
1820 | 0); | |
1821 | current_map->pc = value; | |
1822 | BFD_ASSERT ((unsigned) (value - s->vma) <= s->_raw_size); | |
7564d3d7 | 1823 | } |
9783e04a DM |
1824 | break; |
1825 | ||
1826 | case ieee_value_starting_address_enum & 0xff: | |
6c58561e ILT |
1827 | next_byte (&(ieee->h)); |
1828 | if (this_byte (&(ieee->h)) == ieee_function_either_open_b_enum) | |
1829 | next_byte (&(ieee->h)); | |
1830 | abfd->start_address = must_parse_int (&(ieee->h)); | |
9783e04a DM |
1831 | /* We've got to the end of the data now - */ |
1832 | return true; | |
1833 | default: | |
1834 | BFD_FAIL (); | |
e4d27380 | 1835 | return false; |
9783e04a | 1836 | } |
7564d3d7 SC |
1837 | break; |
1838 | case ieee_repeat_data_enum: | |
9783e04a DM |
1839 | { |
1840 | /* Repeat the following LD or LR n times - we do this by | |
7564d3d7 | 1841 | remembering the stream pointer before running it and |
6f715d66 SC |
1842 | resetting it and running it n times. We special case |
1843 | the repetition of a repeat_data/load_constant | |
7564d3d7 SC |
1844 | */ |
1845 | ||
9783e04a DM |
1846 | unsigned int iterations; |
1847 | unsigned char *start; | |
1848 | next_byte (&(ieee->h)); | |
1849 | iterations = must_parse_int (&(ieee->h)); | |
1850 | start = ieee->h.input_p; | |
1851 | if (start[0] == (int) ieee_load_constant_bytes_enum && | |
1852 | start[1] == 1) | |
1853 | { | |
1854 | while (iterations != 0) | |
1855 | { | |
1856 | location_ptr[current_map->pc++] = start[2]; | |
1857 | iterations--; | |
1858 | } | |
1859 | next_byte (&(ieee->h)); | |
1860 | next_byte (&(ieee->h)); | |
1861 | next_byte (&(ieee->h)); | |
6f715d66 | 1862 | } |
9783e04a DM |
1863 | else |
1864 | { | |
1865 | while (iterations != 0) | |
1866 | { | |
1867 | ieee->h.input_p = start; | |
e4d27380 ILT |
1868 | if (!do_one (ieee, current_map, location_ptr, s, |
1869 | iterations)) | |
9783e04a DM |
1870 | return false; |
1871 | iterations--; | |
1872 | } | |
7564d3d7 | 1873 | } |
9783e04a | 1874 | } |
7564d3d7 SC |
1875 | break; |
1876 | case ieee_load_constant_bytes_enum: | |
1877 | case ieee_load_with_relocation_enum: | |
9783e04a | 1878 | { |
e4d27380 | 1879 | if (!do_one (ieee, current_map, location_ptr, s, 1)) |
9783e04a DM |
1880 | return false; |
1881 | } | |
87f86b4e | 1882 | } |
9783e04a | 1883 | } |
87f86b4e DHW |
1884 | } |
1885 | ||
87f86b4e | 1886 | boolean |
57a1867e DM |
1887 | ieee_new_section_hook (abfd, newsect) |
1888 | bfd *abfd; | |
1889 | asection *newsect; | |
87f86b4e | 1890 | { |
a6dab071 | 1891 | newsect->used_by_bfd = (PTR) |
9783e04a DM |
1892 | bfd_alloc (abfd, sizeof (ieee_per_section_type)); |
1893 | if (!newsect->used_by_bfd) | |
a9713b91 | 1894 | return false; |
9783e04a DM |
1895 | ieee_per_section (newsect)->data = (bfd_byte *) NULL; |
1896 | ieee_per_section (newsect)->section = newsect; | |
87f86b4e DHW |
1897 | return true; |
1898 | } | |
1899 | ||
326e32d7 | 1900 | long |
57a1867e DM |
1901 | ieee_get_reloc_upper_bound (abfd, asect) |
1902 | bfd *abfd; | |
1903 | sec_ptr asect; | |
87f86b4e | 1904 | { |
f8254a3c ILT |
1905 | if ((asect->flags & SEC_DEBUGGING) != 0) |
1906 | return 0; | |
326e32d7 ILT |
1907 | if (! ieee_slurp_section_data (abfd)) |
1908 | return -1; | |
9783e04a | 1909 | return (asect->reloc_count + 1) * sizeof (arelent *); |
87f86b4e DHW |
1910 | } |
1911 | ||
1912 | static boolean | |
57a1867e DM |
1913 | ieee_get_section_contents (abfd, section, location, offset, count) |
1914 | bfd *abfd; | |
1915 | sec_ptr section; | |
1916 | PTR location; | |
1917 | file_ptr offset; | |
1918 | bfd_size_type count; | |
87f86b4e | 1919 | { |
a6dab071 | 1920 | ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd; |
f8254a3c ILT |
1921 | if ((section->flags & SEC_DEBUGGING) != 0) |
1922 | return _bfd_generic_get_section_contents (abfd, section, location, | |
1923 | offset, count); | |
9783e04a DM |
1924 | ieee_slurp_section_data (abfd); |
1925 | (void) memcpy ((PTR) location, (PTR) (p->data + offset), (unsigned) count); | |
87f86b4e DHW |
1926 | return true; |
1927 | } | |
1928 | ||
326e32d7 | 1929 | long |
57a1867e DM |
1930 | ieee_canonicalize_reloc (abfd, section, relptr, symbols) |
1931 | bfd *abfd; | |
1932 | sec_ptr section; | |
1933 | arelent **relptr; | |
1934 | asymbol **symbols; | |
87f86b4e | 1935 | { |
d0ec7a8e | 1936 | /* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/ |
9783e04a DM |
1937 | ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation); |
1938 | ieee_data_type *ieee = IEEE_DATA (abfd); | |
1939 | ||
f8254a3c ILT |
1940 | if ((section->flags & SEC_DEBUGGING) != 0) |
1941 | return 0; | |
1942 | ||
9783e04a DM |
1943 | while (src != (ieee_reloc_type *) NULL) |
1944 | { | |
1945 | /* Work out which symbol to attach it this reloc to */ | |
1946 | switch (src->symbol.letter) | |
1947 | { | |
e4d27380 ILT |
1948 | case 'I': |
1949 | src->relent.sym_ptr_ptr = | |
1950 | symbols + src->symbol.index + ieee->external_symbol_base_offset; | |
1951 | break; | |
9783e04a DM |
1952 | case 'X': |
1953 | src->relent.sym_ptr_ptr = | |
1954 | symbols + src->symbol.index + ieee->external_reference_base_offset; | |
1955 | break; | |
1956 | case 0: | |
1957 | src->relent.sym_ptr_ptr = | |
1958 | src->relent.sym_ptr_ptr[0]->section->symbol_ptr_ptr; | |
1959 | break; | |
1960 | default: | |
87f86b4e | 1961 | |
9783e04a DM |
1962 | BFD_FAIL (); |
1963 | } | |
1964 | *relptr++ = &src->relent; | |
1965 | src = src->next; | |
87f86b4e | 1966 | } |
9783e04a | 1967 | *relptr = (arelent *) NULL; |
87f86b4e DHW |
1968 | return section->reloc_count; |
1969 | } | |
1970 | ||
9783e04a | 1971 | static int |
57a1867e DM |
1972 | comp (ap, bp) |
1973 | CONST PTR ap; | |
1974 | CONST PTR bp; | |
87f86b4e | 1975 | { |
9783e04a DM |
1976 | arelent *a = *((arelent **) ap); |
1977 | arelent *b = *((arelent **) bp); | |
87f86b4e DHW |
1978 | return a->address - b->address; |
1979 | } | |
9872a49c | 1980 | |
14578105 | 1981 | /* Write the section headers. */ |
87f86b4e | 1982 | |
14578105 | 1983 | static boolean |
57a1867e DM |
1984 | ieee_write_section_part (abfd) |
1985 | bfd *abfd; | |
87f86b4e | 1986 | { |
9783e04a | 1987 | ieee_data_type *ieee = IEEE_DATA (abfd); |
87f86b4e | 1988 | asection *s; |
9783e04a DM |
1989 | ieee->w.r.section_part = bfd_tell (abfd); |
1990 | for (s = abfd->sections; s != (asection *) NULL; s = s->next) | |
1991 | { | |
f8254a3c ILT |
1992 | if (! bfd_is_abs_section (s) |
1993 | && (s->flags & SEC_DEBUGGING) == 0) | |
6f715d66 | 1994 | { |
14578105 ILT |
1995 | if (! ieee_write_byte (abfd, ieee_section_type_enum) |
1996 | || ! ieee_write_byte (abfd, | |
1997 | (bfd_byte) (s->index | |
1998 | + IEEE_SECTION_NUMBER_BASE))) | |
1999 | return false; | |
6f715d66 | 2000 | |
9783e04a DM |
2001 | if (abfd->flags & EXEC_P) |
2002 | { | |
2003 | /* This image is executable, so output absolute sections */ | |
14578105 ILT |
2004 | if (! ieee_write_byte (abfd, ieee_variable_A_enum) |
2005 | || ! ieee_write_byte (abfd, ieee_variable_S_enum)) | |
2006 | return false; | |
9783e04a DM |
2007 | } |
2008 | else | |
2009 | { | |
14578105 ILT |
2010 | if (! ieee_write_byte (abfd, ieee_variable_C_enum)) |
2011 | return false; | |
9783e04a | 2012 | } |
6f715d66 | 2013 | |
9783e04a DM |
2014 | switch (s->flags & (SEC_CODE | SEC_DATA | SEC_ROM)) |
2015 | { | |
2016 | case SEC_CODE | SEC_LOAD: | |
2017 | case SEC_CODE: | |
14578105 ILT |
2018 | if (! ieee_write_byte (abfd, ieee_variable_P_enum)) |
2019 | return false; | |
9783e04a DM |
2020 | break; |
2021 | case SEC_DATA: | |
2022 | default: | |
14578105 ILT |
2023 | if (! ieee_write_byte (abfd, ieee_variable_D_enum)) |
2024 | return false; | |
9783e04a DM |
2025 | break; |
2026 | case SEC_ROM: | |
2027 | case SEC_ROM | SEC_DATA: | |
2028 | case SEC_ROM | SEC_LOAD: | |
2029 | case SEC_ROM | SEC_DATA | SEC_LOAD: | |
14578105 ILT |
2030 | if (! ieee_write_byte (abfd, ieee_variable_R_enum)) |
2031 | return false; | |
9783e04a | 2032 | } |
87f86b4e | 2033 | |
9783e04a | 2034 | |
14578105 ILT |
2035 | if (! ieee_write_id (abfd, s->name)) |
2036 | return false; | |
6f715d66 | 2037 | #if 0 |
9783e04a DM |
2038 | ieee_write_int (abfd, 0); /* Parent */ |
2039 | ieee_write_int (abfd, 0); /* Brother */ | |
2040 | ieee_write_int (abfd, 0); /* Context */ | |
6f715d66 | 2041 | #endif |
9783e04a | 2042 | /* Alignment */ |
14578105 ILT |
2043 | if (! ieee_write_byte (abfd, ieee_section_alignment_enum) |
2044 | || ! ieee_write_byte (abfd, | |
2045 | (bfd_byte) (s->index | |
2046 | + IEEE_SECTION_NUMBER_BASE)) | |
2047 | || ! ieee_write_int (abfd, 1 << s->alignment_power)) | |
2048 | return false; | |
9783e04a DM |
2049 | |
2050 | /* Size */ | |
14578105 ILT |
2051 | if (! ieee_write_2bytes (abfd, ieee_section_size_enum) |
2052 | || ! ieee_write_byte (abfd, | |
2053 | (bfd_byte) (s->index | |
2054 | + IEEE_SECTION_NUMBER_BASE)) | |
2055 | || ! ieee_write_int (abfd, s->_raw_size)) | |
2056 | return false; | |
9783e04a DM |
2057 | if (abfd->flags & EXEC_P) |
2058 | { | |
2059 | /* Relocateable sections don't have asl records */ | |
2060 | /* Vma */ | |
14578105 ILT |
2061 | if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum) |
2062 | || ! ieee_write_byte (abfd, | |
2063 | ((bfd_byte) | |
2064 | (s->index | |
2065 | + IEEE_SECTION_NUMBER_BASE))) | |
6c58561e | 2066 | || ! ieee_write_int (abfd, s->lma)) |
14578105 | 2067 | return false; |
9783e04a DM |
2068 | } |
2069 | } | |
b2c91bd9 | 2070 | } |
14578105 ILT |
2071 | |
2072 | return true; | |
87f86b4e DHW |
2073 | } |
2074 | ||
2075 | ||
9783e04a | 2076 | static boolean |
57a1867e DM |
2077 | do_with_relocs (abfd, s) |
2078 | bfd *abfd; | |
2079 | asection *s; | |
87f86b4e | 2080 | { |
e4d27380 ILT |
2081 | unsigned int number_of_maus_in_address = |
2082 | bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd); | |
6f715d66 | 2083 | unsigned int relocs_to_go = s->reloc_count; |
9783e04a | 2084 | bfd_byte *stream = ieee_per_section (s)->data; |
6f715d66 | 2085 | arelent **p = s->orelocation; |
6f715d66 SC |
2086 | bfd_size_type current_byte_index = 0; |
2087 | ||
9783e04a DM |
2088 | qsort (s->orelocation, |
2089 | relocs_to_go, | |
2090 | sizeof (arelent **), | |
2091 | comp); | |
6f715d66 | 2092 | |
b2c91bd9 | 2093 | /* Output the section preheader */ |
14578105 ILT |
2094 | if (! ieee_write_byte (abfd, ieee_set_current_section_enum) |
2095 | || ! ieee_write_byte (abfd, | |
2096 | (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)) | |
2097 | || ! ieee_write_2bytes (abfd, ieee_set_current_pc_enum) | |
2098 | || ! ieee_write_byte (abfd, | |
e4d27380 | 2099 | (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))) |
14578105 | 2100 | return false; |
e4d27380 ILT |
2101 | if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0) |
2102 | { | |
6c58561e | 2103 | if (! ieee_write_int (abfd, s->lma)) |
e4d27380 ILT |
2104 | return false; |
2105 | } | |
2106 | else | |
2107 | { | |
2108 | if (! ieee_write_expression (abfd, 0, s->symbol, 0, 0)) | |
2109 | return false; | |
2110 | } | |
6f715d66 | 2111 | |
9783e04a DM |
2112 | if (relocs_to_go == 0) |
2113 | { | |
14578105 ILT |
2114 | /* If there aren't any relocations then output the load constant |
2115 | byte opcode rather than the load with relocation opcode */ | |
b2c91bd9 | 2116 | |
9783e04a DM |
2117 | while (current_byte_index < s->_raw_size) |
2118 | { | |
b2c91bd9 | 2119 | bfd_size_type run; |
e4d27380 | 2120 | unsigned int MAXRUN = 127; |
b2c91bd9 | 2121 | run = MAXRUN; |
9783e04a DM |
2122 | if (run > s->_raw_size - current_byte_index) |
2123 | { | |
2124 | run = s->_raw_size - current_byte_index; | |
2125 | } | |
6f715d66 | 2126 | |
9783e04a DM |
2127 | if (run != 0) |
2128 | { | |
14578105 ILT |
2129 | if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)) |
2130 | return false; | |
9783e04a | 2131 | /* Output a stream of bytes */ |
14578105 ILT |
2132 | if (! ieee_write_int (abfd, run)) |
2133 | return false; | |
4002f18a ILT |
2134 | if (bfd_write ((PTR) (stream + current_byte_index), |
2135 | 1, | |
2136 | run, | |
2137 | abfd) | |
2138 | != run) | |
2139 | return false; | |
9783e04a DM |
2140 | current_byte_index += run; |
2141 | } | |
6f715d66 | 2142 | } |
9783e04a DM |
2143 | } |
2144 | else | |
2145 | { | |
14578105 ILT |
2146 | if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum)) |
2147 | return false; | |
6f715d66 | 2148 | |
9783e04a | 2149 | /* Output the data stream as the longest sequence of bytes |
14578105 ILT |
2150 | possible, allowing for the a reasonable packet size and |
2151 | relocation stuffs. */ | |
6f715d66 | 2152 | |
9783e04a DM |
2153 | if ((PTR) stream == (PTR) NULL) |
2154 | { | |
b2c91bd9 | 2155 | /* Outputting a section without data, fill it up */ |
9783e04a DM |
2156 | stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size)); |
2157 | if (!stream) | |
a9713b91 | 2158 | return false; |
ae115e51 | 2159 | memset ((PTR) stream, 0, (size_t) s->_raw_size); |
6f715d66 | 2160 | } |
9783e04a DM |
2161 | while (current_byte_index < s->_raw_size) |
2162 | { | |
b2c91bd9 | 2163 | bfd_size_type run; |
e4d27380 | 2164 | unsigned int MAXRUN = 127; |
9783e04a DM |
2165 | if (relocs_to_go) |
2166 | { | |
2167 | run = (*p)->address - current_byte_index; | |
e4d27380 ILT |
2168 | if (run > MAXRUN) |
2169 | run = MAXRUN; | |
9783e04a DM |
2170 | } |
2171 | else | |
2172 | { | |
2173 | run = MAXRUN; | |
2174 | } | |
2175 | if (run > s->_raw_size - current_byte_index) | |
2176 | { | |
2177 | run = s->_raw_size - current_byte_index; | |
2178 | } | |
6f715d66 | 2179 | |
9783e04a DM |
2180 | if (run != 0) |
2181 | { | |
2182 | /* Output a stream of bytes */ | |
14578105 ILT |
2183 | if (! ieee_write_int (abfd, run)) |
2184 | return false; | |
4002f18a ILT |
2185 | if (bfd_write ((PTR) (stream + current_byte_index), |
2186 | 1, | |
2187 | run, | |
2188 | abfd) | |
2189 | != run) | |
2190 | return false; | |
9783e04a DM |
2191 | current_byte_index += run; |
2192 | } | |
b2c91bd9 | 2193 | /* Output any relocations here */ |
9783e04a DM |
2194 | if (relocs_to_go && (*p) && (*p)->address == current_byte_index) |
2195 | { | |
14578105 ILT |
2196 | while (relocs_to_go |
2197 | && (*p) && (*p)->address == current_byte_index) | |
9783e04a | 2198 | { |
9783e04a | 2199 | arelent *r = *p; |
e4d27380 | 2200 | bfd_signed_vma ov; |
b2c91bd9 SC |
2201 | |
2202 | #if 0 | |
9783e04a DM |
2203 | if (r->howto->pc_relative) |
2204 | { | |
2205 | r->addend += current_byte_index; | |
2206 | } | |
b2c91bd9 SC |
2207 | #endif |
2208 | ||
9783e04a DM |
2209 | switch (r->howto->size) |
2210 | { | |
2211 | case 2: | |
b2c91bd9 | 2212 | |
e4d27380 ILT |
2213 | ov = bfd_get_signed_32 (abfd, |
2214 | stream + current_byte_index); | |
9783e04a DM |
2215 | current_byte_index += 4; |
2216 | break; | |
2217 | case 1: | |
e4d27380 ILT |
2218 | ov = bfd_get_signed_16 (abfd, |
2219 | stream + current_byte_index); | |
9783e04a DM |
2220 | current_byte_index += 2; |
2221 | break; | |
2222 | case 0: | |
e4d27380 ILT |
2223 | ov = bfd_get_signed_8 (abfd, |
2224 | stream + current_byte_index); | |
9783e04a DM |
2225 | current_byte_index++; |
2226 | break; | |
2227 | default: | |
2228 | ov = 0; | |
2229 | BFD_FAIL (); | |
e4d27380 | 2230 | return false; |
9783e04a | 2231 | } |
e4d27380 ILT |
2232 | |
2233 | ov &= r->howto->src_mask; | |
2234 | ||
2235 | if (r->howto->pc_relative | |
2236 | && ! r->howto->pcrel_offset) | |
2237 | ov += r->address; | |
2238 | ||
14578105 ILT |
2239 | if (! ieee_write_byte (abfd, |
2240 | ieee_function_either_open_b_enum)) | |
2241 | return false; | |
2242 | ||
2243 | /* abort();*/ | |
b2c91bd9 | 2244 | |
9783e04a DM |
2245 | if (r->sym_ptr_ptr != (asymbol **) NULL) |
2246 | { | |
14578105 ILT |
2247 | if (! ieee_write_expression (abfd, r->addend + ov, |
2248 | *(r->sym_ptr_ptr), | |
2249 | r->howto->pc_relative, | |
2250 | s->index)) | |
2251 | return false; | |
9783e04a DM |
2252 | } |
2253 | else | |
2254 | { | |
14578105 ILT |
2255 | if (! ieee_write_expression (abfd, r->addend + ov, |
2256 | (asymbol *) NULL, | |
2257 | r->howto->pc_relative, | |
2258 | s->index)) | |
2259 | return false; | |
9783e04a | 2260 | } |
b2c91bd9 | 2261 | |
e4d27380 ILT |
2262 | if (number_of_maus_in_address |
2263 | != bfd_get_reloc_size (r->howto)) | |
9783e04a | 2264 | { |
e4d27380 ILT |
2265 | if (! ieee_write_int (abfd, |
2266 | bfd_get_reloc_size (r->howto))) | |
14578105 | 2267 | return false; |
9783e04a | 2268 | } |
14578105 ILT |
2269 | if (! ieee_write_byte (abfd, |
2270 | ieee_function_either_close_b_enum)) | |
2271 | return false; | |
b2c91bd9 | 2272 | |
9783e04a DM |
2273 | relocs_to_go--; |
2274 | p++; | |
2275 | } | |
2276 | ||
2277 | } | |
b2c91bd9 | 2278 | } |
9783e04a | 2279 | } |
14578105 | 2280 | |
9783e04a | 2281 | return true; |
6f715d66 SC |
2282 | } |
2283 | ||
14578105 ILT |
2284 | /* If there are no relocations in the output section then we can be |
2285 | clever about how we write. We block items up into a max of 127 | |
2286 | bytes. */ | |
6f715d66 | 2287 | |
14578105 | 2288 | static boolean |
57a1867e DM |
2289 | do_as_repeat (abfd, s) |
2290 | bfd *abfd; | |
2291 | asection *s; | |
9783e04a DM |
2292 | { |
2293 | if (s->_raw_size) | |
2294 | { | |
14578105 ILT |
2295 | if (! ieee_write_byte (abfd, ieee_set_current_section_enum) |
2296 | || ! ieee_write_byte (abfd, | |
2297 | (bfd_byte) (s->index | |
2298 | + IEEE_SECTION_NUMBER_BASE)) | |
2299 | || ! ieee_write_byte (abfd, ieee_set_current_pc_enum >> 8) | |
2300 | || ! ieee_write_byte (abfd, ieee_set_current_pc_enum & 0xff) | |
2301 | || ! ieee_write_byte (abfd, | |
2302 | (bfd_byte) (s->index | |
2303 | + IEEE_SECTION_NUMBER_BASE)) | |
6c58561e | 2304 | || ! ieee_write_int (abfd, s->lma) |
14578105 ILT |
2305 | || ! ieee_write_byte (abfd, ieee_repeat_data_enum) |
2306 | || ! ieee_write_int (abfd, s->_raw_size) | |
2307 | || ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum) | |
2308 | || ! ieee_write_byte (abfd, 1) | |
2309 | || ! ieee_write_byte (abfd, 0)) | |
2310 | return false; | |
9783e04a | 2311 | } |
14578105 ILT |
2312 | |
2313 | return true; | |
6f715d66 SC |
2314 | } |
2315 | ||
14578105 | 2316 | static boolean |
57a1867e DM |
2317 | do_without_relocs (abfd, s) |
2318 | bfd *abfd; | |
2319 | asection *s; | |
6f715d66 | 2320 | { |
9783e04a | 2321 | bfd_byte *stream = ieee_per_section (s)->data; |
6f715d66 | 2322 | |
9783e04a DM |
2323 | if (stream == 0 || ((s->flags & SEC_LOAD) == 0)) |
2324 | { | |
14578105 ILT |
2325 | if (! do_as_repeat (abfd, s)) |
2326 | return false; | |
9783e04a DM |
2327 | } |
2328 | else | |
2329 | { | |
2330 | unsigned int i; | |
2331 | for (i = 0; i < s->_raw_size; i++) | |
2332 | { | |
2333 | if (stream[i] != 0) | |
2334 | { | |
14578105 ILT |
2335 | if (! do_with_relocs (abfd, s)) |
2336 | return false; | |
2337 | return true; | |
9783e04a | 2338 | } |
6f715d66 | 2339 | } |
14578105 ILT |
2340 | if (! do_as_repeat (abfd, s)) |
2341 | return false; | |
9783e04a DM |
2342 | } |
2343 | ||
14578105 | 2344 | return true; |
6f715d66 | 2345 | } |
301dfc71 | 2346 | |
6f715d66 SC |
2347 | |
2348 | static unsigned char *output_ptr_start; | |
2349 | static unsigned char *output_ptr; | |
2350 | static unsigned char *output_ptr_end; | |
2351 | static unsigned char *input_ptr_start; | |
2352 | static unsigned char *input_ptr; | |
2353 | static unsigned char *input_ptr_end; | |
2354 | static bfd *input_bfd; | |
2355 | static bfd *output_bfd; | |
2356 | static int output_buffer; | |
2357 | ||
57a1867e | 2358 | static void |
9783e04a | 2359 | fill () |
6f715d66 | 2360 | { |
4002f18a ILT |
2361 | /* FIXME: Check return value. I'm not sure whether it needs to read |
2362 | the entire buffer or not. */ | |
9783e04a | 2363 | bfd_read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd); |
6f715d66 SC |
2364 | input_ptr = input_ptr_start; |
2365 | } | |
57a1867e | 2366 | static void |
9783e04a | 2367 | flush () |
6f715d66 | 2368 | { |
4002f18a ILT |
2369 | if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start, |
2370 | output_bfd) | |
ae115e51 | 2371 | != (bfd_size_type) (output_ptr - output_ptr_start)) |
4002f18a | 2372 | abort (); |
6f715d66 SC |
2373 | output_ptr = output_ptr_start; |
2374 | output_buffer++; | |
2375 | } | |
2376 | ||
2377 | #define THIS() ( *input_ptr ) | |
2378 | #define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); } | |
2379 | #define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end) flush(); } | |
2380 | ||
57a1867e | 2381 | static void |
9783e04a DM |
2382 | write_int (value) |
2383 | int value; | |
6f715d66 | 2384 | { |
9783e04a DM |
2385 | if (value >= 0 && value <= 127) |
2386 | { | |
2387 | OUT (value); | |
6f715d66 | 2388 | } |
9783e04a DM |
2389 | else |
2390 | { | |
2391 | unsigned int length; | |
2392 | /* How many significant bytes ? */ | |
2393 | /* FIXME FOR LONGER INTS */ | |
2394 | if (value & 0xff000000) | |
2395 | { | |
2396 | length = 4; | |
2397 | } | |
2398 | else if (value & 0x00ff0000) | |
2399 | { | |
2400 | length = 3; | |
2401 | } | |
2402 | else if (value & 0x0000ff00) | |
2403 | { | |
2404 | length = 2; | |
2405 | } | |
2406 | else | |
2407 | length = 1; | |
6f715d66 | 2408 | |
9783e04a DM |
2409 | OUT ((int) ieee_number_repeat_start_enum + length); |
2410 | switch (length) | |
2411 | { | |
2412 | case 4: | |
2413 | OUT (value >> 24); | |
2414 | case 3: | |
2415 | OUT (value >> 16); | |
2416 | case 2: | |
2417 | OUT (value >> 8); | |
2418 | case 1: | |
2419 | OUT (value); | |
2420 | } | |
6f715d66 | 2421 | |
9783e04a | 2422 | } |
6f715d66 | 2423 | } |
9783e04a | 2424 | |
57a1867e | 2425 | static void |
9783e04a | 2426 | copy_id () |
6f715d66 | 2427 | { |
9783e04a | 2428 | int length = THIS (); |
6f715d66 | 2429 | char ch; |
9783e04a DM |
2430 | OUT (length); |
2431 | NEXT (); | |
2432 | while (length--) | |
2433 | { | |
2434 | ch = THIS (); | |
2435 | OUT (ch); | |
2436 | NEXT (); | |
2437 | } | |
6f715d66 | 2438 | } |
9783e04a | 2439 | |
6f715d66 | 2440 | #define VAR(x) ((x | 0x80)) |
57a1867e | 2441 | static void |
9783e04a | 2442 | copy_expression () |
6f715d66 SC |
2443 | { |
2444 | int stack[10]; | |
2445 | int *tos = stack; | |
2446 | int value = 0; | |
9783e04a DM |
2447 | while (1) |
2448 | { | |
2449 | switch (THIS ()) | |
6f715d66 | 2450 | { |
9783e04a DM |
2451 | case 0x84: |
2452 | NEXT (); | |
2453 | value = THIS (); | |
2454 | NEXT (); | |
2455 | value = (value << 8) | THIS (); | |
2456 | NEXT (); | |
2457 | value = (value << 8) | THIS (); | |
2458 | NEXT (); | |
2459 | value = (value << 8) | THIS (); | |
2460 | NEXT (); | |
6f715d66 | 2461 | *tos++ = value; |
9783e04a DM |
2462 | break; |
2463 | case 0x83: | |
2464 | NEXT (); | |
2465 | value = THIS (); | |
2466 | NEXT (); | |
2467 | value = (value << 8) | THIS (); | |
2468 | NEXT (); | |
2469 | value = (value << 8) | THIS (); | |
2470 | NEXT (); | |
2471 | *tos++ = value; | |
2472 | break; | |
2473 | case 0x82: | |
2474 | NEXT (); | |
2475 | value = THIS (); | |
2476 | NEXT (); | |
2477 | value = (value << 8) | THIS (); | |
2478 | NEXT (); | |
2479 | *tos++ = value; | |
2480 | break; | |
2481 | case 0x81: | |
2482 | NEXT (); | |
2483 | value = THIS (); | |
2484 | NEXT (); | |
6f715d66 | 2485 | *tos++ = value; |
9783e04a DM |
2486 | break; |
2487 | case 0x80: | |
2488 | NEXT (); | |
2489 | *tos++ = 0; | |
2490 | break; | |
2491 | default: | |
2492 | if (THIS () > 0x84) | |
2493 | { | |
2494 | /* Not a number, just bug out with the answer */ | |
2495 | write_int (*(--tos)); | |
2496 | return; | |
2497 | } | |
2498 | *tos++ = THIS (); | |
2499 | NEXT (); | |
6f715d66 | 2500 | value = 0; |
9783e04a DM |
2501 | break; |
2502 | case 0xa5: | |
2503 | /* PLUS anything */ | |
2504 | { | |
2505 | int value = *(--tos); | |
2506 | value += *(--tos); | |
2507 | *tos++ = value; | |
2508 | NEXT (); | |
2509 | } | |
2510 | break; | |
2511 | case VAR ('R'): | |
2512 | { | |
2513 | int section_number; | |
2514 | ieee_data_type *ieee; | |
2515 | asection *s; | |
2516 | NEXT (); | |
2517 | section_number = THIS (); | |
2518 | ||
2519 | NEXT (); | |
2520 | ieee = IEEE_DATA (input_bfd); | |
2521 | s = ieee->section_table[section_number]; | |
2522 | if (s->output_section) | |
2523 | { | |
6c58561e | 2524 | value = s->output_section->lma; |
9783e04a DM |
2525 | } |
2526 | else | |
2527 | { | |
2528 | value = 0; | |
2529 | } | |
2530 | value += s->output_offset; | |
2531 | *tos++ = value; | |
2532 | value = 0; | |
2533 | } | |
2534 | break; | |
2535 | case 0x90: | |
2536 | { | |
2537 | NEXT (); | |
2538 | write_int (*(--tos)); | |
2539 | OUT (0x90); | |
2540 | return; | |
87f86b4e | 2541 | |
9783e04a | 2542 | } |
6f715d66 SC |
2543 | } |
2544 | } | |
6f715d66 SC |
2545 | |
2546 | } | |
87f86b4e | 2547 | |
6f715d66 SC |
2548 | /* Drop the int in the buffer, and copy a null into the gap, which we |
2549 | will overwrite later */ | |
87f86b4e | 2550 | |
9783e04a DM |
2551 | struct output_buffer_struct |
2552 | { | |
2553 | unsigned char *ptrp; | |
6f715d66 | 2554 | int buffer; |
9783e04a | 2555 | }; |
87f86b4e | 2556 | |
6f715d66 | 2557 | static void |
57a1867e DM |
2558 | fill_int (buf) |
2559 | struct output_buffer_struct *buf; | |
9783e04a DM |
2560 | { |
2561 | if (buf->buffer == output_buffer) | |
2562 | { | |
2563 | /* Still a chance to output the size */ | |
2564 | int value = output_ptr - buf->ptrp + 3; | |
2565 | buf->ptrp[0] = value >> 24; | |
2566 | buf->ptrp[1] = value >> 16; | |
2567 | buf->ptrp[2] = value >> 8; | |
2568 | buf->ptrp[3] = value >> 0; | |
2569 | } | |
6f715d66 | 2570 | } |
9783e04a | 2571 | |
6f715d66 | 2572 | static void |
57a1867e DM |
2573 | drop_int (buf) |
2574 | struct output_buffer_struct *buf; | |
6f715d66 | 2575 | { |
9783e04a | 2576 | int type = THIS (); |
6f715d66 | 2577 | int ch; |
9783e04a DM |
2578 | if (type <= 0x84) |
2579 | { | |
2580 | NEXT (); | |
2581 | switch (type) | |
2582 | { | |
2583 | case 0x84: | |
2584 | ch = THIS (); | |
2585 | NEXT (); | |
2586 | case 0x83: | |
2587 | ch = THIS (); | |
2588 | NEXT (); | |
2589 | case 0x82: | |
2590 | ch = THIS (); | |
2591 | NEXT (); | |
2592 | case 0x81: | |
2593 | ch = THIS (); | |
2594 | NEXT (); | |
2595 | case 0x80: | |
2596 | break; | |
2597 | } | |
6f715d66 | 2598 | } |
9783e04a | 2599 | OUT (0x84); |
6f715d66 | 2600 | buf->ptrp = output_ptr; |
9783e04a DM |
2601 | buf->buffer = output_buffer; |
2602 | OUT (0); | |
2603 | OUT (0); | |
2604 | OUT (0); | |
2605 | OUT (0); | |
6f715d66 SC |
2606 | } |
2607 | ||
57a1867e | 2608 | static void |
9783e04a | 2609 | copy_int () |
6f715d66 | 2610 | { |
9783e04a | 2611 | int type = THIS (); |
6f715d66 | 2612 | int ch; |
9783e04a DM |
2613 | if (type <= 0x84) |
2614 | { | |
2615 | OUT (type); | |
2616 | NEXT (); | |
2617 | switch (type) | |
2618 | { | |
2619 | case 0x84: | |
2620 | ch = THIS (); | |
2621 | NEXT (); | |
2622 | OUT (ch); | |
2623 | case 0x83: | |
2624 | ch = THIS (); | |
2625 | NEXT (); | |
2626 | OUT (ch); | |
2627 | case 0x82: | |
2628 | ch = THIS (); | |
2629 | NEXT (); | |
2630 | OUT (ch); | |
2631 | case 0x81: | |
2632 | ch = THIS (); | |
2633 | NEXT (); | |
2634 | OUT (ch); | |
2635 | case 0x80: | |
2636 | break; | |
2637 | } | |
6f715d66 | 2638 | } |
6f715d66 SC |
2639 | } |
2640 | ||
2641 | #define ID copy_id() | |
2642 | #define INT copy_int() | |
2643 | #define EXP copy_expression() | |
9783e04a | 2644 | static void copy_till_end (); |
6f715d66 SC |
2645 | #define INTn(q) copy_int() |
2646 | #define EXPn(q) copy_expression() | |
9783e04a | 2647 | |
57a1867e | 2648 | static void |
9783e04a | 2649 | f1_record () |
6f715d66 SC |
2650 | { |
2651 | int ch; | |
2652 | /* ATN record */ | |
9783e04a DM |
2653 | NEXT (); |
2654 | ch = THIS (); | |
2655 | switch (ch) | |
2656 | { | |
2657 | default: | |
2658 | OUT (0xf1); | |
2659 | OUT (ch); | |
2660 | break; | |
2661 | case 0xc9: | |
2662 | NEXT (); | |
2663 | OUT (0xf1); | |
2664 | OUT (0xc9); | |
2665 | INT; | |
2666 | INT; | |
2667 | ch = THIS (); | |
2668 | switch (ch) | |
2669 | { | |
2670 | case 0x16: | |
2671 | NEXT (); | |
2672 | break; | |
2673 | case 0x01: | |
2674 | NEXT (); | |
2675 | break; | |
2676 | case 0x00: | |
2677 | NEXT (); | |
2678 | INT; | |
2679 | break; | |
2680 | case 0x03: | |
2681 | NEXT (); | |
2682 | INT; | |
2683 | break; | |
2684 | case 0x13: | |
2685 | EXPn (instruction address); | |
2686 | break; | |
2687 | default: | |
2688 | break; | |
2689 | } | |
2690 | break; | |
2691 | case 0xd8: | |
2692 | /* EXternal ref */ | |
2693 | NEXT (); | |
2694 | OUT (0xf1); | |
2695 | OUT (0xd8); | |
2696 | EXP; | |
2697 | EXP; | |
2698 | EXP; | |
2699 | EXP; | |
2700 | break; | |
2701 | case 0xce: | |
2702 | NEXT (); | |
2703 | OUT (0xf1); | |
2704 | OUT (0xce); | |
2705 | INT; | |
2706 | INT; | |
2707 | ch = THIS (); | |
2708 | INT; | |
2709 | switch (ch) | |
2710 | { | |
6f715d66 | 2711 | case 0x01: |
9783e04a DM |
2712 | INT; |
2713 | INT; | |
2714 | break; | |
6f715d66 | 2715 | case 0x02: |
9783e04a DM |
2716 | INT; |
2717 | break; | |
6f715d66 | 2718 | case 0x04: |
9783e04a DM |
2719 | EXPn (external function); |
2720 | break; | |
6f715d66 SC |
2721 | case 0x05: |
2722 | break; | |
9783e04a DM |
2723 | case 0x07: |
2724 | INTn (line number); | |
2725 | INT; | |
2726 | case 0x08: | |
2727 | break; | |
2728 | case 0x0a: | |
2729 | INTn (locked register); | |
2730 | INT; | |
2731 | break; | |
2732 | case 0x3f: | |
2733 | copy_till_end (); | |
2734 | break; | |
2735 | case 0x3e: | |
2736 | copy_till_end (); | |
2737 | break; | |
2738 | case 0x40: | |
2739 | copy_till_end (); | |
2740 | break; | |
2741 | case 0x41: | |
2742 | ID; | |
2743 | break; | |
87f86b4e | 2744 | } |
9783e04a | 2745 | } |
6f715d66 SC |
2746 | |
2747 | } | |
9783e04a | 2748 | |
57a1867e | 2749 | static void |
9783e04a | 2750 | f0_record () |
6f715d66 SC |
2751 | { |
2752 | /* Attribute record */ | |
9783e04a DM |
2753 | NEXT (); |
2754 | OUT (0xf0); | |
2755 | INTn (Symbol name); | |
6f715d66 SC |
2756 | ID; |
2757 | } | |
9783e04a | 2758 | |
57a1867e | 2759 | static void |
9783e04a | 2760 | copy_till_end () |
6f715d66 | 2761 | { |
9783e04a DM |
2762 | int ch = THIS (); |
2763 | while (1) | |
2764 | { | |
2765 | while (ch <= 0x80) | |
6f715d66 | 2766 | { |
9783e04a DM |
2767 | OUT (ch); |
2768 | NEXT (); | |
2769 | ch = THIS (); | |
2770 | } | |
2771 | switch (ch) | |
2772 | { | |
2773 | case 0x84: | |
2774 | OUT (THIS ()); | |
2775 | NEXT (); | |
2776 | case 0x83: | |
2777 | OUT (THIS ()); | |
2778 | NEXT (); | |
2779 | case 0x82: | |
2780 | OUT (THIS ()); | |
2781 | NEXT (); | |
2782 | case 0x81: | |
2783 | OUT (THIS ()); | |
2784 | NEXT (); | |
2785 | OUT (THIS ()); | |
2786 | NEXT (); | |
2787 | ||
2788 | ch = THIS (); | |
2789 | break; | |
2790 | default: | |
2791 | return; | |
6f715d66 | 2792 | } |
6f715d66 | 2793 | } |
6f715d66 SC |
2794 | |
2795 | } | |
2796 | ||
57a1867e | 2797 | static void |
9783e04a | 2798 | f2_record () |
6f715d66 | 2799 | { |
9783e04a DM |
2800 | NEXT (); |
2801 | OUT (0xf2); | |
2802 | INT; | |
2803 | NEXT (); | |
2804 | OUT (0xce); | |
2805 | INT; | |
2806 | copy_till_end (); | |
6f715d66 SC |
2807 | } |
2808 | ||
2809 | ||
9783e04a | 2810 | static void block (); |
57a1867e | 2811 | static void |
9783e04a | 2812 | f8_record () |
6f715d66 SC |
2813 | { |
2814 | int ch; | |
9783e04a DM |
2815 | NEXT (); |
2816 | ch = THIS (); | |
2817 | switch (ch) | |
2818 | { | |
2819 | case 0x01: | |
2820 | case 0x02: | |
2821 | case 0x03: | |
2822 | /* Unique typedefs for module */ | |
2823 | /* GLobal typedefs */ | |
2824 | /* High level module scope beginning */ | |
6f715d66 | 2825 | { |
9783e04a DM |
2826 | struct output_buffer_struct ob; |
2827 | NEXT (); | |
2828 | OUT (0xf8); | |
2829 | OUT (ch); | |
2830 | drop_int (&ob); | |
2831 | ID; | |
2832 | ||
2833 | block (); | |
2834 | ||
2835 | NEXT (); | |
2836 | fill_int (&ob); | |
2837 | OUT (0xf9); | |
2838 | } | |
2839 | break; | |
2840 | case 0x04: | |
2841 | /* Global function */ | |
2842 | { | |
2843 | struct output_buffer_struct ob; | |
2844 | NEXT (); | |
2845 | OUT (0xf8); | |
2846 | OUT (0x04); | |
2847 | drop_int (&ob); | |
2848 | ID; | |
2849 | INTn (stack size); | |
2850 | INTn (ret val); | |
2851 | EXPn (offset); | |
2852 | ||
2853 | block (); | |
2854 | ||
2855 | NEXT (); | |
2856 | OUT (0xf9); | |
2857 | EXPn (size of block); | |
2858 | fill_int (&ob); | |
2859 | } | |
2860 | break; | |
301dfc71 | 2861 | |
9783e04a DM |
2862 | case 0x05: |
2863 | /* File name for source line numbers */ | |
2864 | { | |
2865 | struct output_buffer_struct ob; | |
2866 | NEXT (); | |
2867 | OUT (0xf8); | |
2868 | OUT (0x05); | |
2869 | drop_int (&ob); | |
2870 | ID; | |
2871 | INTn (year); | |
2872 | INTn (month); | |
2873 | INTn (day); | |
2874 | INTn (hour); | |
2875 | INTn (monute); | |
2876 | INTn (second); | |
2877 | block (); | |
2878 | NEXT (); | |
2879 | OUT (0xf9); | |
2880 | fill_int (&ob); | |
2881 | } | |
2882 | break; | |
d0ec7a8e | 2883 | |
9783e04a DM |
2884 | case 0x06: |
2885 | /* Local function */ | |
2886 | { | |
2887 | struct output_buffer_struct ob; | |
2888 | NEXT (); | |
2889 | OUT (0xf8); | |
2890 | OUT (0x06); | |
2891 | drop_int (&ob); | |
2892 | ID; | |
2893 | INTn (stack size); | |
2894 | INTn (type return); | |
2895 | EXPn (offset); | |
2896 | block (); | |
2897 | NEXT (); | |
2898 | OUT (0xf9); | |
2899 | EXPn (size); | |
2900 | fill_int (&ob); | |
2901 | } | |
2902 | break; | |
d0ec7a8e | 2903 | |
9783e04a DM |
2904 | case 0x0a: |
2905 | /* Assembler module scope beginning -*/ | |
2906 | { | |
2907 | struct output_buffer_struct ob; | |
2908 | ||
2909 | NEXT (); | |
2910 | OUT (0xf8); | |
2911 | OUT (0x0a); | |
2912 | drop_int (&ob); | |
2913 | ID; | |
2914 | ID; | |
2915 | INT; | |
2916 | ID; | |
2917 | INT; | |
2918 | INT; | |
2919 | INT; | |
2920 | INT; | |
2921 | INT; | |
2922 | INT; | |
2923 | ||
2924 | block (); | |
2925 | ||
2926 | NEXT (); | |
2927 | OUT (0xf9); | |
2928 | fill_int (&ob); | |
2929 | } | |
2930 | break; | |
2931 | case 0x0b: | |
2932 | { | |
2933 | struct output_buffer_struct ob; | |
2934 | NEXT (); | |
2935 | OUT (0xf8); | |
2936 | OUT (0x0b); | |
2937 | drop_int (&ob); | |
2938 | ID; | |
2939 | INT; | |
2940 | INTn (section index); | |
2941 | EXPn (offset); | |
2942 | INTn (stuff); | |
2943 | ||
2944 | block (); | |
2945 | ||
2946 | OUT (0xf9); | |
2947 | NEXT (); | |
2948 | EXPn (Size in Maus); | |
2949 | fill_int (&ob); | |
87f86b4e | 2950 | } |
9783e04a DM |
2951 | break; |
2952 | } | |
6f715d66 | 2953 | } |
87f86b4e | 2954 | |
57a1867e | 2955 | static void |
9783e04a | 2956 | e2_record () |
6f715d66 | 2957 | { |
9783e04a DM |
2958 | OUT (0xe2); |
2959 | NEXT (); | |
2960 | OUT (0xce); | |
2961 | NEXT (); | |
6f715d66 SC |
2962 | INT; |
2963 | EXP; | |
2964 | } | |
2965 | ||
57a1867e DM |
2966 | static void |
2967 | block () | |
6f715d66 | 2968 | { |
9783e04a DM |
2969 | int ch; |
2970 | while (1) | |
2971 | { | |
2972 | ch = THIS (); | |
2973 | switch (ch) | |
2974 | { | |
2975 | case 0xe1: | |
2976 | case 0xe5: | |
2977 | return; | |
2978 | case 0xf9: | |
2979 | return; | |
2980 | case 0xf0: | |
2981 | f0_record (); | |
2982 | break; | |
2983 | case 0xf1: | |
2984 | f1_record (); | |
2985 | break; | |
2986 | case 0xf2: | |
2987 | f2_record (); | |
2988 | break; | |
2989 | case 0xf8: | |
2990 | f8_record (); | |
2991 | break; | |
2992 | case 0xe2: | |
2993 | e2_record (); | |
2994 | break; | |
6f715d66 | 2995 | |
9783e04a DM |
2996 | } |
2997 | } | |
6f715d66 | 2998 | } |
6f715d66 SC |
2999 | |
3000 | ||
9783e04a DM |
3001 | |
3002 | /* relocate_debug, | |
6f715d66 SC |
3003 | moves all the debug information from the source bfd to the output |
3004 | bfd, and relocates any expressions it finds | |
3005 | */ | |
3006 | ||
3007 | static void | |
57a1867e DM |
3008 | relocate_debug (output, input) |
3009 | bfd *output; | |
3010 | bfd *input; | |
6f715d66 SC |
3011 | { |
3012 | #define IBS 400 | |
3013 | #define OBS 400 | |
3014 | unsigned char input_buffer[IBS]; | |
3015 | ||
3016 | input_ptr_start = input_ptr = input_buffer; | |
3017 | input_ptr_end = input_buffer + IBS; | |
3018 | input_bfd = input; | |
4002f18a ILT |
3019 | /* FIXME: Check return value. I'm not sure whether it needs to read |
3020 | the entire buffer or not. */ | |
9783e04a DM |
3021 | bfd_read ((PTR) input_ptr_start, 1, IBS, input); |
3022 | block (); | |
6f715d66 | 3023 | } |
9783e04a DM |
3024 | |
3025 | /* | |
6f715d66 SC |
3026 | During linking, we we told about the bfds which made up our |
3027 | contents, we have a list of them. They will still be open, so go to | |
3028 | the debug info in each, and copy it out, relocating it as we go. | |
3029 | */ | |
3030 | ||
efa77952 | 3031 | static boolean |
57a1867e DM |
3032 | ieee_write_debug_part (abfd) |
3033 | bfd *abfd; | |
6f715d66 | 3034 | { |
9783e04a | 3035 | ieee_data_type *ieee = IEEE_DATA (abfd); |
6f715d66 SC |
3036 | bfd_chain_type *chain = ieee->chain_root; |
3037 | unsigned char output_buffer[OBS]; | |
b2c91bd9 | 3038 | boolean some_debug = false; |
9783e04a | 3039 | file_ptr here = bfd_tell (abfd); |
b2c91bd9 | 3040 | |
9783e04a | 3041 | output_ptr_start = output_ptr = output_buffer; |
6f715d66 SC |
3042 | output_ptr_end = output_buffer + OBS; |
3043 | output_ptr = output_buffer; | |
3044 | output_bfd = abfd; | |
6f715d66 | 3045 | |
9783e04a DM |
3046 | if (chain == (bfd_chain_type *) NULL) |
3047 | { | |
efa77952 | 3048 | asection *s; |
e98e6ec1 | 3049 | |
efa77952 ILT |
3050 | for (s = abfd->sections; s != NULL; s = s->next) |
3051 | if ((s->flags & SEC_DEBUGGING) != 0) | |
3052 | break; | |
3053 | if (s == NULL) | |
3054 | { | |
3055 | ieee->w.r.debug_information_part = 0; | |
3056 | return true; | |
3057 | } | |
9783e04a | 3058 | |
efa77952 ILT |
3059 | ieee->w.r.debug_information_part = here; |
3060 | if (bfd_write (s->contents, 1, s->_raw_size, abfd) != s->_raw_size) | |
3061 | return false; | |
e98e6ec1 | 3062 | } |
9783e04a DM |
3063 | else |
3064 | { | |
3065 | while (chain != (bfd_chain_type *) NULL) | |
3066 | { | |
e98e6ec1 | 3067 | bfd *entry = chain->this; |
9783e04a DM |
3068 | ieee_data_type *entry_ieee = IEEE_DATA (entry); |
3069 | if (entry_ieee->w.r.debug_information_part) | |
3070 | { | |
4002f18a ILT |
3071 | if (bfd_seek (entry, entry_ieee->w.r.debug_information_part, |
3072 | SEEK_SET) | |
3073 | != 0) | |
efa77952 | 3074 | return false; |
9783e04a | 3075 | relocate_debug (abfd, entry); |
e98e6ec1 | 3076 | } |
6f715d66 | 3077 | |
e98e6ec1 SC |
3078 | chain = chain->next; |
3079 | } | |
9783e04a DM |
3080 | if (some_debug) |
3081 | { | |
e98e6ec1 SC |
3082 | ieee->w.r.debug_information_part = here; |
3083 | } | |
9783e04a DM |
3084 | else |
3085 | { | |
e98e6ec1 SC |
3086 | ieee->w.r.debug_information_part = 0; |
3087 | } | |
efa77952 ILT |
3088 | |
3089 | flush (); | |
b2c91bd9 | 3090 | } |
9783e04a | 3091 | |
efa77952 | 3092 | return true; |
9783e04a | 3093 | } |
6f715d66 | 3094 | |
14578105 ILT |
3095 | /* Write the data in an ieee way. */ |
3096 | ||
3097 | static boolean | |
57a1867e DM |
3098 | ieee_write_data_part (abfd) |
3099 | bfd *abfd; | |
6f715d66 SC |
3100 | { |
3101 | asection *s; | |
9783e04a DM |
3102 | ieee_data_type *ieee = IEEE_DATA (abfd); |
3103 | ieee->w.r.data_part = bfd_tell (abfd); | |
3104 | for (s = abfd->sections; s != (asection *) NULL; s = s->next) | |
3105 | { | |
e4d27380 ILT |
3106 | /* Skip sections that have no loadable contents (.bss, |
3107 | debugging, etc.) */ | |
3108 | if ((s->flags & SEC_LOAD) == 0) | |
f8254a3c | 3109 | continue; |
e4d27380 | 3110 | |
9783e04a | 3111 | /* Sort the reloc records so we can insert them in the correct |
e4d27380 | 3112 | places */ |
9783e04a DM |
3113 | if (s->reloc_count != 0) |
3114 | { | |
14578105 ILT |
3115 | if (! do_with_relocs (abfd, s)) |
3116 | return false; | |
9783e04a DM |
3117 | } |
3118 | else | |
3119 | { | |
14578105 ILT |
3120 | if (! do_without_relocs (abfd, s)) |
3121 | return false; | |
9783e04a DM |
3122 | } |
3123 | } | |
14578105 ILT |
3124 | |
3125 | return true; | |
301dfc71 | 3126 | } |
87f86b4e DHW |
3127 | |
3128 | ||
9783e04a | 3129 | static boolean |
57a1867e DM |
3130 | init_for_output (abfd) |
3131 | bfd *abfd; | |
87f86b4e | 3132 | { |
9783e04a DM |
3133 | asection *s; |
3134 | for (s = abfd->sections; s != (asection *) NULL; s = s->next) | |
3135 | { | |
f8254a3c ILT |
3136 | if ((s->flags & SEC_DEBUGGING) != 0) |
3137 | continue; | |
9783e04a DM |
3138 | if (s->_raw_size != 0) |
3139 | { | |
3140 | ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size)); | |
3141 | if (!ieee_per_section (s)->data) | |
a9713b91 | 3142 | return false; |
9783e04a | 3143 | } |
87f86b4e | 3144 | } |
9783e04a | 3145 | return true; |
87f86b4e | 3146 | } |
9783e04a | 3147 | \f |
87f86b4e DHW |
3148 | /** exec and core file sections */ |
3149 | ||
9783e04a | 3150 | /* set section contents is complicated with IEEE since the format is |
87f86b4e DHW |
3151 | * not a byte image, but a record stream. |
3152 | */ | |
3153 | boolean | |
57a1867e DM |
3154 | ieee_set_section_contents (abfd, section, location, offset, count) |
3155 | bfd *abfd; | |
3156 | sec_ptr section; | |
3157 | PTR location; | |
3158 | file_ptr offset; | |
3159 | bfd_size_type count; | |
9783e04a | 3160 | { |
efa77952 ILT |
3161 | if ((section->flags & SEC_DEBUGGING) != 0) |
3162 | { | |
3163 | if (section->contents == NULL) | |
3164 | { | |
6c58561e ILT |
3165 | section->contents = ((unsigned char *) |
3166 | bfd_alloc (abfd, section->_raw_size)); | |
efa77952 ILT |
3167 | if (section->contents == NULL) |
3168 | return false; | |
3169 | } | |
3170 | /* bfd_set_section_contents has already checked that everything | |
3171 | is within range. */ | |
3172 | memcpy (section->contents + offset, location, count); | |
3173 | return true; | |
3174 | } | |
3175 | ||
9783e04a DM |
3176 | if (ieee_per_section (section)->data == (bfd_byte *) NULL) |
3177 | { | |
3178 | if (!init_for_output (abfd)) | |
3179 | return false; | |
3180 | } | |
3181 | memcpy ((PTR) (ieee_per_section (section)->data + offset), | |
3182 | (PTR) location, | |
3183 | (unsigned int) count); | |
87f86b4e DHW |
3184 | return true; |
3185 | } | |
3186 | ||
14578105 ILT |
3187 | /* Write the external symbols of a file. IEEE considers two sorts of |
3188 | external symbols, public, and referenced. It uses to internal | |
3189 | forms to index them as well. When we write them out we turn their | |
3190 | symbol values into indexes from the right base. */ | |
3191 | ||
3192 | static boolean | |
57a1867e DM |
3193 | ieee_write_external_part (abfd) |
3194 | bfd *abfd; | |
87f86b4e DHW |
3195 | { |
3196 | asymbol **q; | |
9783e04a | 3197 | ieee_data_type *ieee = IEEE_DATA (abfd); |
87f86b4e DHW |
3198 | |
3199 | unsigned int reference_index = IEEE_REFERENCE_BASE; | |
9783e04a DM |
3200 | unsigned int public_index = IEEE_PUBLIC_BASE + 2; |
3201 | file_ptr here = bfd_tell (abfd); | |
b2c91bd9 | 3202 | boolean hadone = false; |
9783e04a DM |
3203 | if (abfd->outsymbols != (asymbol **) NULL) |
3204 | { | |
3205 | ||
3206 | for (q = abfd->outsymbols; *q != (asymbol *) NULL; q++) | |
3207 | { | |
3208 | asymbol *p = *q; | |
c3246d9b | 3209 | if (bfd_is_und_section (p->section)) |
9783e04a DM |
3210 | { |
3211 | /* This must be a symbol reference .. */ | |
14578105 ILT |
3212 | if (! ieee_write_byte (abfd, ieee_external_reference_enum) |
3213 | || ! ieee_write_int (abfd, reference_index) | |
3214 | || ! ieee_write_id (abfd, p->name)) | |
3215 | return false; | |
9783e04a DM |
3216 | p->value = reference_index; |
3217 | reference_index++; | |
6c58561e | 3218 | hadone = true; |
9783e04a DM |
3219 | } |
3220 | else if (bfd_is_com_section (p->section)) | |
3221 | { | |
3222 | /* This is a weak reference */ | |
14578105 ILT |
3223 | if (! ieee_write_byte (abfd, ieee_external_reference_enum) |
3224 | || ! ieee_write_int (abfd, reference_index) | |
3225 | || ! ieee_write_id (abfd, p->name) | |
3226 | || ! ieee_write_byte (abfd, | |
3227 | ieee_weak_external_reference_enum) | |
3228 | || ! ieee_write_int (abfd, reference_index) | |
e4d27380 | 3229 | || ! ieee_write_int (abfd, p->value)) |
14578105 | 3230 | return false; |
9783e04a DM |
3231 | p->value = reference_index; |
3232 | reference_index++; | |
6c58561e | 3233 | hadone = true; |
9783e04a DM |
3234 | } |
3235 | else if (p->flags & BSF_GLOBAL) | |
3236 | { | |
3237 | /* This must be a symbol definition */ | |
87f86b4e | 3238 | |
14578105 ILT |
3239 | if (! ieee_write_byte (abfd, ieee_external_symbol_enum) |
3240 | || ! ieee_write_int (abfd, public_index) | |
3241 | || ! ieee_write_id (abfd, p->name) | |
3242 | || ! ieee_write_2bytes (abfd, ieee_attribute_record_enum) | |
3243 | || ! ieee_write_int (abfd, public_index) | |
3244 | || ! ieee_write_byte (abfd, 15) /* instruction address */ | |
3245 | || ! ieee_write_byte (abfd, 19) /* static symbol */ | |
3246 | || ! ieee_write_byte (abfd, 1)) /* one of them */ | |
3247 | return false; | |
b2c91bd9 | 3248 | |
9783e04a | 3249 | /* Write out the value */ |
14578105 ILT |
3250 | if (! ieee_write_2bytes (abfd, ieee_value_record_enum) |
3251 | || ! ieee_write_int (abfd, public_index)) | |
3252 | return false; | |
c3246d9b | 3253 | if (! bfd_is_abs_section (p->section)) |
9783e04a DM |
3254 | { |
3255 | if (abfd->flags & EXEC_P) | |
3256 | { | |
3257 | /* If fully linked, then output all symbols | |
14578105 ILT |
3258 | relocated */ |
3259 | if (! (ieee_write_int | |
3260 | (abfd, | |
3261 | (p->value | |
3262 | + p->section->output_offset | |
3263 | + p->section->output_section->vma)))) | |
3264 | return false; | |
9783e04a DM |
3265 | } |
3266 | else | |
3267 | { | |
14578105 ILT |
3268 | if (! (ieee_write_expression |
3269 | (abfd, | |
3270 | p->value + p->section->output_offset, | |
3271 | p->section->output_section->symbol, | |
3272 | false, 0))) | |
3273 | return false; | |
9783e04a DM |
3274 | } |
3275 | } | |
3276 | else | |
3277 | { | |
14578105 ILT |
3278 | if (! ieee_write_expression (abfd, |
3279 | p->value, | |
3280 | bfd_abs_section_ptr->symbol, | |
3281 | false, 0)) | |
3282 | return false; | |
e98e6ec1 | 3283 | } |
9783e04a DM |
3284 | p->value = public_index; |
3285 | public_index++; | |
6c58561e | 3286 | hadone = true; |
b2c91bd9 | 3287 | } |
9783e04a | 3288 | else |
b2c91bd9 | 3289 | { |
9783e04a DM |
3290 | /* This can happen - when there are gaps in the symbols read */ |
3291 | /* from an input ieee file */ | |
6f715d66 | 3292 | } |
9783e04a | 3293 | } |
87f86b4e | 3294 | } |
b2c91bd9 SC |
3295 | if (hadone) |
3296 | ieee->w.r.external_part = here; | |
87f86b4e | 3297 | |
14578105 | 3298 | return true; |
87f86b4e DHW |
3299 | } |
3300 | ||
b2c91bd9 | 3301 | |
9783e04a DM |
3302 | static CONST unsigned char exten[] = |
3303 | { | |
3304 | 0xf0, 0x20, 0x00, | |
3305 | 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */ | |
3306 | 0xf1, 0xce, 0x20, 0x00, 39, 2,/* keep symbol in original case */ | |
3307 | 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */ | |
3308 | }; | |
b2c91bd9 | 3309 | |
71858486 | 3310 | static CONST unsigned char envi[] = |
9783e04a DM |
3311 | { |
3312 | 0xf0, 0x21, 0x00, | |
b2c91bd9 SC |
3313 | |
3314 | /* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11, | |
9783e04a | 3315 | 0x19, 0x2c, |
b2c91bd9 | 3316 | */ |
9783e04a | 3317 | 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok */ |
b2c91bd9 | 3318 | |
9783e04a | 3319 | 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix */ |
b2c91bd9 | 3320 | /* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */ |
9783e04a | 3321 | }; |
b2c91bd9 | 3322 | |
14578105 | 3323 | static boolean |
57a1867e DM |
3324 | ieee_write_me_part (abfd) |
3325 | bfd *abfd; | |
9783e04a DM |
3326 | { |
3327 | ieee_data_type *ieee = IEEE_DATA (abfd); | |
3328 | ieee->w.r.trailer_part = bfd_tell (abfd); | |
3329 | if (abfd->start_address) | |
3330 | { | |
14578105 ILT |
3331 | if (! ieee_write_2bytes (abfd, ieee_value_starting_address_enum) |
3332 | || ! ieee_write_byte (abfd, ieee_function_either_open_b_enum) | |
3333 | || ! ieee_write_int (abfd, abfd->start_address) | |
3334 | || ! ieee_write_byte (abfd, ieee_function_either_close_b_enum)) | |
3335 | return false; | |
9783e04a | 3336 | } |
e4d27380 | 3337 | ieee->w.r.me_record = bfd_tell (abfd); |
14578105 ILT |
3338 | if (! ieee_write_byte (abfd, ieee_module_end_enum)) |
3339 | return false; | |
3340 | return true; | |
87f86b4e | 3341 | } |
9783e04a | 3342 | |
e4d27380 ILT |
3343 | /* Write out the IEEE processor ID. */ |
3344 | ||
3345 | static boolean | |
3346 | ieee_write_processor (abfd) | |
3347 | bfd *abfd; | |
3348 | { | |
3349 | const bfd_arch_info_type *arch; | |
3350 | ||
3351 | arch = bfd_get_arch_info (abfd); | |
3352 | switch (arch->arch) | |
3353 | { | |
3354 | default: | |
3355 | if (! ieee_write_id (abfd, bfd_printable_name (abfd))) | |
3356 | return false; | |
3357 | break; | |
3358 | ||
3359 | case bfd_arch_a29k: | |
3360 | if (! ieee_write_id (abfd, "29000")) | |
3361 | return false; | |
3362 | break; | |
3363 | ||
3364 | case bfd_arch_h8300: | |
3365 | if (! ieee_write_id (abfd, "H8/300")) | |
3366 | return false; | |
3367 | break; | |
3368 | ||
3369 | case bfd_arch_h8500: | |
3370 | if (! ieee_write_id (abfd, "H8/500")) | |
3371 | return false; | |
3372 | break; | |
3373 | ||
3374 | case bfd_arch_i960: | |
3375 | switch (arch->mach) | |
3376 | { | |
3377 | default: | |
3378 | case bfd_mach_i960_core: | |
3379 | case bfd_mach_i960_ka_sa: | |
3380 | if (! ieee_write_id (abfd, "80960KA")) | |
3381 | return false; | |
3382 | break; | |
3383 | ||
3384 | case bfd_mach_i960_kb_sb: | |
3385 | if (! ieee_write_id (abfd, "80960KB")) | |
3386 | return false; | |
3387 | break; | |
3388 | ||
3389 | case bfd_mach_i960_ca: | |
3390 | if (! ieee_write_id (abfd, "80960CA")) | |
3391 | return false; | |
3392 | break; | |
3393 | ||
3394 | case bfd_mach_i960_mc: | |
3395 | case bfd_mach_i960_xa: | |
3396 | if (! ieee_write_id (abfd, "80960MC")) | |
3397 | return false; | |
3398 | break; | |
3399 | } | |
3400 | break; | |
3401 | ||
3402 | case bfd_arch_m68k: | |
3403 | { | |
3404 | char ab[20]; | |
3405 | ||
3406 | sprintf (ab, "%lu", arch->mach); | |
3407 | if (! ieee_write_id (abfd, ab)) | |
3408 | return false; | |
3409 | } | |
3410 | break; | |
3411 | } | |
3412 | ||
3413 | return true; | |
3414 | } | |
3415 | ||
87f86b4e | 3416 | boolean |
57a1867e DM |
3417 | ieee_write_object_contents (abfd) |
3418 | bfd *abfd; | |
87f86b4e | 3419 | { |
9783e04a | 3420 | ieee_data_type *ieee = IEEE_DATA (abfd); |
87f86b4e | 3421 | unsigned int i; |
9783e04a | 3422 | file_ptr old; |
14578105 | 3423 | |
301dfc71 | 3424 | /* Fast forward over the header area */ |
4002f18a ILT |
3425 | if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0) |
3426 | return false; | |
e4d27380 | 3427 | |
14578105 | 3428 | if (! ieee_write_byte (abfd, ieee_module_beginning_enum) |
e4d27380 | 3429 | || ! ieee_write_processor (abfd) |
14578105 ILT |
3430 | || ! ieee_write_id (abfd, abfd->filename)) |
3431 | return false; | |
6f715d66 | 3432 | |
9783e04a | 3433 | /* Fast forward over the variable bits */ |
14578105 ILT |
3434 | if (! ieee_write_byte (abfd, ieee_address_descriptor_enum)) |
3435 | return false; | |
b2c91bd9 SC |
3436 | |
3437 | /* Bits per MAU */ | |
14578105 ILT |
3438 | if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd)))) |
3439 | return false; | |
b2c91bd9 | 3440 | /* MAU's per address */ |
14578105 ILT |
3441 | if (! ieee_write_byte (abfd, |
3442 | (bfd_byte) (bfd_arch_bits_per_address (abfd) | |
3443 | / bfd_arch_bits_per_byte (abfd)))) | |
3444 | return false; | |
9783e04a DM |
3445 | |
3446 | old = bfd_tell (abfd); | |
4002f18a ILT |
3447 | if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0) |
3448 | return false; | |
9783e04a DM |
3449 | |
3450 | ieee->w.r.extension_record = bfd_tell (abfd); | |
4002f18a ILT |
3451 | if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten)) |
3452 | return false; | |
9783e04a | 3453 | if (abfd->flags & EXEC_P) |
14578105 ILT |
3454 | { |
3455 | if (! ieee_write_byte (abfd, 0x1)) /* Absolute */ | |
3456 | return false; | |
3457 | } | |
9783e04a | 3458 | else |
14578105 ILT |
3459 | { |
3460 | if (! ieee_write_byte (abfd, 0x2)) /* Relocateable */ | |
3461 | return false; | |
3462 | } | |
9783e04a DM |
3463 | |
3464 | ieee->w.r.environmental_record = bfd_tell (abfd); | |
4002f18a ILT |
3465 | if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi)) |
3466 | return false; | |
6c58561e ILT |
3467 | |
3468 | /* The HP emulator database requires a timestamp in the file. */ | |
3469 | { | |
3470 | time_t now; | |
3471 | const struct tm *t; | |
3472 | ||
3473 | time (&now); | |
3474 | t = (struct tm *) localtime (&now); | |
3475 | if (! ieee_write_2bytes (abfd, (int) ieee_atn_record_enum) | |
3476 | || ! ieee_write_byte (abfd, 0x21) | |
3477 | || ! ieee_write_byte (abfd, 0) | |
3478 | || ! ieee_write_byte (abfd, 50) | |
3479 | || ! ieee_write_int (abfd, t->tm_year + 1900) | |
3480 | || ! ieee_write_int (abfd, t->tm_mon + 1) | |
3481 | || ! ieee_write_int (abfd, t->tm_mday) | |
3482 | || ! ieee_write_int (abfd, t->tm_hour) | |
3483 | || ! ieee_write_int (abfd, t->tm_min) | |
3484 | || ! ieee_write_int (abfd, t->tm_sec)) | |
3485 | return false; | |
3486 | } | |
3487 | ||
b2c91bd9 | 3488 | output_bfd = abfd; |
14578105 | 3489 | |
9783e04a | 3490 | flush (); |
6f715d66 | 3491 | |
14578105 ILT |
3492 | if (! ieee_write_section_part (abfd)) |
3493 | return false; | |
3494 | /* First write the symbols. This changes their values into table | |
3495 | indeces so we cant use it after this point. */ | |
3496 | if (! ieee_write_external_part (abfd)) | |
3497 | return false; | |
87f86b4e | 3498 | |
14578105 | 3499 | /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/ |
b2c91bd9 SC |
3500 | |
3501 | /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/ | |
6f715d66 SC |
3502 | |
3503 | ||
14578105 | 3504 | /* Write any debugs we have been told about. */ |
efa77952 ILT |
3505 | if (! ieee_write_debug_part (abfd)) |
3506 | return false; | |
6f715d66 | 3507 | |
14578105 ILT |
3508 | /* Can only write the data once the symbols have been written, since |
3509 | the data contains relocation information which points to the | |
3510 | symbols. */ | |
3511 | if (! ieee_write_data_part (abfd)) | |
3512 | return false; | |
87f86b4e | 3513 | |
14578105 ILT |
3514 | /* At the end we put the end! */ |
3515 | if (! ieee_write_me_part (abfd)) | |
3516 | return false; | |
87f86b4e | 3517 | |
301dfc71 | 3518 | /* Generate the header */ |
4002f18a ILT |
3519 | if (bfd_seek (abfd, old, SEEK_SET) != 0) |
3520 | return false; | |
87f86b4e | 3521 | |
9783e04a DM |
3522 | for (i = 0; i < N_W_VARIABLES; i++) |
3523 | { | |
14578105 ILT |
3524 | if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum) |
3525 | || ! ieee_write_byte (abfd, (bfd_byte) i) | |
3526 | || ! ieee_write_int5_out (abfd, ieee->w.offset[i])) | |
3527 | return false; | |
9783e04a | 3528 | } |
14578105 | 3529 | |
87f86b4e DHW |
3530 | return true; |
3531 | } | |
9783e04a | 3532 | \f |
87f86b4e DHW |
3533 | /* Native-level interface to symbols. */ |
3534 | ||
3535 | /* We read the symbols into a buffer, which is discarded when this | |
14578105 ILT |
3536 | function exits. We read the strings into a buffer large enough to |
3537 | hold them all plus all the cached symbol entries. */ | |
87f86b4e DHW |
3538 | |
3539 | asymbol * | |
57a1867e DM |
3540 | ieee_make_empty_symbol (abfd) |
3541 | bfd *abfd; | |
87f86b4e | 3542 | { |
9783e04a | 3543 | ieee_symbol_type *new = |
14578105 | 3544 | (ieee_symbol_type *) bfd_zmalloc (sizeof (ieee_symbol_type)); |
9783e04a | 3545 | if (!new) |
58142f10 | 3546 | return NULL; |
87f86b4e DHW |
3547 | new->symbol.the_bfd = abfd; |
3548 | return &new->symbol; | |
87f86b4e DHW |
3549 | } |
3550 | ||
87f86b4e | 3551 | static bfd * |
57a1867e DM |
3552 | ieee_openr_next_archived_file (arch, prev) |
3553 | bfd *arch; | |
3554 | bfd *prev; | |
87f86b4e | 3555 | { |
9783e04a | 3556 | ieee_ar_data_type *ar = IEEE_AR_DATA (arch); |
87f86b4e | 3557 | /* take the next one from the arch state, or reset */ |
9783e04a DM |
3558 | if (prev == (bfd *) NULL) |
3559 | { | |
3560 | /* Reset the index - the first two entries are bogus*/ | |
3561 | ar->element_index = 2; | |
87f86b4e | 3562 | } |
9783e04a DM |
3563 | while (true) |
3564 | { | |
3565 | ieee_ar_obstack_type *p = ar->elements + ar->element_index; | |
3566 | ar->element_index++; | |
3567 | if (ar->element_index <= ar->element_count) | |
3568 | { | |
3569 | if (p->file_offset != (file_ptr) 0) | |
3570 | { | |
3571 | if (p->abfd == (bfd *) NULL) | |
3572 | { | |
3573 | p->abfd = _bfd_create_empty_archive_element_shell (arch); | |
3574 | p->abfd->origin = p->file_offset; | |
3575 | } | |
3576 | return p->abfd; | |
3577 | } | |
3578 | } | |
3579 | else | |
3580 | { | |
57a1867e | 3581 | bfd_set_error (bfd_error_no_more_archived_files); |
9783e04a DM |
3582 | return (bfd *) NULL; |
3583 | } | |
87f86b4e | 3584 | |
9783e04a | 3585 | } |
87f86b4e DHW |
3586 | } |
3587 | ||
3588 | static boolean | |
9783e04a DM |
3589 | ieee_find_nearest_line (abfd, |
3590 | section, | |
3591 | symbols, | |
3592 | offset, | |
3593 | filename_ptr, | |
3594 | functionname_ptr, | |
3595 | line_ptr) | |
3596 | bfd *abfd; | |
3597 | asection *section; | |
3598 | asymbol **symbols; | |
3599 | bfd_vma offset; | |
3600 | char **filename_ptr; | |
3601 | char **functionname_ptr; | |
3602 | int *line_ptr; | |
87f86b4e DHW |
3603 | { |
3604 | return false; | |
87f86b4e | 3605 | } |
301dfc71 | 3606 | |
301dfc71 | 3607 | static int |
9783e04a DM |
3608 | ieee_generic_stat_arch_elt (abfd, buf) |
3609 | bfd *abfd; | |
3610 | struct stat *buf; | |
301dfc71 | 3611 | { |
9465d03e | 3612 | ieee_ar_data_type *ar = abfd->my_archive->tdata.ieee_ar_data; |
e4d27380 ILT |
3613 | ieee_data_type *ieee; |
3614 | ||
9783e04a DM |
3615 | if (ar == (ieee_ar_data_type *) NULL) |
3616 | { | |
57a1867e | 3617 | bfd_set_error (bfd_error_invalid_operation); |
9783e04a DM |
3618 | return -1; |
3619 | } | |
e4d27380 ILT |
3620 | |
3621 | if (IEEE_DATA (abfd) == NULL) | |
9783e04a | 3622 | { |
e4d27380 ILT |
3623 | if (ieee_object_p (abfd) == NULL) |
3624 | { | |
3625 | bfd_set_error (bfd_error_wrong_format); | |
3626 | return -1; | |
3627 | } | |
9783e04a | 3628 | } |
e4d27380 ILT |
3629 | |
3630 | ieee = IEEE_DATA (abfd); | |
3631 | ||
3632 | buf->st_size = ieee->w.r.me_record + 1; | |
3633 | buf->st_mode = 0644; | |
3634 | return 0; | |
301dfc71 | 3635 | } |
9783e04a DM |
3636 | |
3637 | static int | |
57a1867e DM |
3638 | ieee_sizeof_headers (abfd, x) |
3639 | bfd *abfd; | |
3640 | boolean x; | |
39a2ce33 | 3641 | { |
d0ec7a8e | 3642 | return 0; |
39a2ce33 SC |
3643 | } |
3644 | ||
6f715d66 | 3645 | |
6812b607 ILT |
3646 | /* The debug info routines are never used. */ |
3647 | #if 0 | |
3648 | ||
9783e04a | 3649 | static void |
57a1867e DM |
3650 | ieee_bfd_debug_info_start (abfd) |
3651 | bfd *abfd; | |
9783e04a | 3652 | { |
6f715d66 | 3653 | |
9783e04a | 3654 | } |
6f715d66 | 3655 | |
9783e04a | 3656 | static void |
57a1867e DM |
3657 | ieee_bfd_debug_info_end (abfd) |
3658 | bfd *abfd; | |
9783e04a | 3659 | { |
6f715d66 | 3660 | |
9783e04a | 3661 | } |
6f715d66 SC |
3662 | |
3663 | ||
3664 | /* Add this section to the list of sections we have debug info for, to | |
9783e04a | 3665 | be ready to output it at close time |
6f715d66 | 3666 | */ |
9783e04a | 3667 | static void |
57a1867e DM |
3668 | ieee_bfd_debug_info_accumulate (abfd, section) |
3669 | bfd *abfd; | |
3670 | asection *section; | |
6f715d66 | 3671 | { |
9783e04a DM |
3672 | ieee_data_type *ieee = IEEE_DATA (section->owner); |
3673 | ieee_data_type *output_ieee = IEEE_DATA (abfd); | |
6f715d66 SC |
3674 | /* can only accumulate data from other ieee bfds */ |
3675 | if (section->owner->xvec != abfd->xvec) | |
3676 | return; | |
3677 | /* Only bother once per bfd */ | |
9783e04a | 3678 | if (ieee->done_debug == true) |
6f715d66 SC |
3679 | return; |
3680 | ieee->done_debug = true; | |
3681 | ||
3682 | /* Don't bother if there is no debug info */ | |
3683 | if (ieee->w.r.debug_information_part == 0) | |
3684 | return; | |
3685 | ||
3686 | ||
3687 | /* Add to chain */ | |
9783e04a DM |
3688 | { |
3689 | bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, sizeof (bfd_chain_type)); | |
3690 | if (!n) | |
a9713b91 | 3691 | abort (); /* FIXME */ |
9783e04a DM |
3692 | n->this = section->owner; |
3693 | n->next = (bfd_chain_type *) NULL; | |
3694 | ||
3695 | if (output_ieee->chain_head) | |
3696 | { | |
6f715d66 SC |
3697 | output_ieee->chain_head->next = n; |
3698 | } | |
9783e04a DM |
3699 | else |
3700 | { | |
6f715d66 SC |
3701 | output_ieee->chain_root = n; |
3702 | ||
3703 | } | |
9783e04a DM |
3704 | output_ieee->chain_head = n; |
3705 | } | |
6f715d66 SC |
3706 | } |
3707 | ||
6812b607 ILT |
3708 | #endif |
3709 | ||
3710 | #define ieee_close_and_cleanup _bfd_generic_close_and_cleanup | |
3711 | #define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info | |
6f715d66 | 3712 | |
9872a49c SC |
3713 | #define ieee_slurp_armap bfd_true |
3714 | #define ieee_slurp_extended_name_table bfd_true | |
c3246d9b ILT |
3715 | #define ieee_construct_extended_name_table \ |
3716 | ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \ | |
3717 | bfd_true) | |
6812b607 ILT |
3718 | #define ieee_truncate_arname bfd_dont_truncate_arname |
3719 | #define ieee_write_armap \ | |
3720 | ((boolean (*) \ | |
3721 | PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \ | |
3722 | bfd_true) | |
a9713b91 | 3723 | #define ieee_read_ar_hdr bfd_nullvoidptr |
c3246d9b | 3724 | #define ieee_update_armap_timestamp bfd_true |
e4d27380 | 3725 | #define ieee_get_elt_at_index _bfd_generic_get_elt_at_index |
6812b607 ILT |
3726 | |
3727 | #define ieee_bfd_is_local_label bfd_generic_is_local_label | |
3728 | #define ieee_get_lineno _bfd_nosymbols_get_lineno | |
3729 | #define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol | |
c3246d9b ILT |
3730 | #define ieee_read_minisymbols _bfd_generic_read_minisymbols |
3731 | #define ieee_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol | |
6812b607 ILT |
3732 | |
3733 | #define ieee_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup | |
3734 | ||
3735 | #define ieee_set_arch_mach _bfd_generic_set_arch_mach | |
3736 | ||
a9713b91 ILT |
3737 | #define ieee_get_section_contents_in_window \ |
3738 | _bfd_generic_get_section_contents_in_window | |
6812b607 ILT |
3739 | #define ieee_bfd_get_relocated_section_contents \ |
3740 | bfd_generic_get_relocated_section_contents | |
69e0d34d | 3741 | #define ieee_bfd_relax_section bfd_generic_relax_section |
f4bd7a8f DM |
3742 | #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create |
3743 | #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols | |
3744 | #define ieee_bfd_final_link _bfd_generic_final_link | |
c3246d9b | 3745 | #define ieee_bfd_link_split_section _bfd_generic_link_split_section |
8feff717 | 3746 | |
87f86b4e | 3747 | /*SUPPRESS 460 */ |
2f3508ad | 3748 | const bfd_target ieee_vec = |
87f86b4e DHW |
3749 | { |
3750 | "ieee", /* name */ | |
01dd1b2b | 3751 | bfd_target_ieee_flavour, |
f8254a3c ILT |
3752 | BFD_ENDIAN_UNKNOWN, /* target byte order */ |
3753 | BFD_ENDIAN_UNKNOWN, /* target headers byte order */ | |
87f86b4e DHW |
3754 | (HAS_RELOC | EXEC_P | /* object flags */ |
3755 | HAS_LINENO | HAS_DEBUG | | |
f4bd7a8f | 3756 | HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED), |
9783e04a DM |
3757 | (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS |
3758 | | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */ | |
6c58561e | 3759 | '_', /* leading underscore */ |
87f86b4e DHW |
3760 | ' ', /* ar_pad_char */ |
3761 | 16, /* ar_max_namelen */ | |
9783e04a DM |
3762 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, |
3763 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
3764 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */ | |
3765 | bfd_getb64, bfd_getb_signed_64, bfd_putb64, | |
3766 | bfd_getb32, bfd_getb_signed_32, bfd_putb32, | |
3767 | bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */ | |
3768 | ||
3769 | {_bfd_dummy_target, | |
3770 | ieee_object_p, /* bfd_check_format */ | |
3771 | ieee_archive_p, | |
3772 | _bfd_dummy_target, | |
3773 | }, | |
87f86b4e DHW |
3774 | { |
3775 | bfd_false, | |
9783e04a | 3776 | ieee_mkobject, |
87f86b4e DHW |
3777 | _bfd_generic_mkarchive, |
3778 | bfd_false | |
9783e04a | 3779 | }, |
2b1d8a50 JG |
3780 | { |
3781 | bfd_false, | |
3782 | ieee_write_object_contents, | |
3783 | _bfd_write_archive_contents, | |
3784 | bfd_false, | |
3785 | }, | |
6812b607 ILT |
3786 | |
3787 | BFD_JUMP_TABLE_GENERIC (ieee), | |
3788 | BFD_JUMP_TABLE_COPY (_bfd_generic), | |
3789 | BFD_JUMP_TABLE_CORE (_bfd_nocore), | |
3790 | BFD_JUMP_TABLE_ARCHIVE (ieee), | |
3791 | BFD_JUMP_TABLE_SYMBOLS (ieee), | |
3792 | BFD_JUMP_TABLE_RELOCS (ieee), | |
3793 | BFD_JUMP_TABLE_WRITE (ieee), | |
3794 | BFD_JUMP_TABLE_LINK (ieee), | |
dfc1c006 | 3795 | BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), |
6812b607 | 3796 | |
8feff717 | 3797 | (PTR) 0 |
87f86b4e | 3798 | }; |