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