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