1 /* BFD back-end for ieee-695 objects.
2 Copyright (C) 1990, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc.
3 Written by Steve Chamberlain of Cygnus Support.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #define KEEPMINUSPCININST 0
23 /* IEEE 695 format is a stream of records, which we parse using a simple one-
24 token (which is one byte in this lexicon) lookahead recursive decent
33 static boolean ieee_write_byte PARAMS ((bfd *, bfd_byte));
34 static boolean ieee_write_2bytes PARAMS ((bfd *, int));
35 static boolean ieee_write_int PARAMS ((bfd *, bfd_vma));
36 static boolean ieee_write_id PARAMS ((bfd *, const char *));
37 static boolean ieee_write_expression
38 PARAMS ((bfd *, bfd_vma, asymbol *, boolean, unsigned int));
39 static void ieee_write_int5 PARAMS ((bfd_byte *, bfd_vma));
40 static boolean ieee_write_int5_out PARAMS ((bfd *, bfd_vma));
41 static boolean ieee_write_section_part PARAMS ((bfd *));
42 static boolean do_with_relocs PARAMS ((bfd *, asection *));
43 static boolean do_as_repeat PARAMS ((bfd *, asection *));
44 static boolean do_without_relocs PARAMS ((bfd *, asection *));
45 static boolean ieee_write_external_part PARAMS ((bfd *));
46 static boolean ieee_write_data_part PARAMS ((bfd *));
47 static boolean ieee_write_debug_part PARAMS ((bfd *));
48 static boolean ieee_write_me_part PARAMS ((bfd *));
49 static boolean ieee_write_processor PARAMS ((bfd *));
51 static boolean ieee_slurp_debug PARAMS ((bfd *));
52 static boolean ieee_slurp_section_data PARAMS ((bfd *));
54 /* Functions for writing to ieee files in the strange way that the
58 ieee_write_byte (abfd, byte)
62 if (bfd_write ((PTR) &byte, 1, 1, abfd) != 1)
68 ieee_write_2bytes (abfd, bytes)
74 buffer[0] = bytes >> 8;
75 buffer[1] = bytes & 0xff;
76 if (bfd_write ((PTR) buffer, 1, 2, abfd) != 2)
82 ieee_write_int (abfd, value)
88 if (! ieee_write_byte (abfd, (bfd_byte) value))
95 /* How many significant bytes ? */
96 /* FIXME FOR LONGER INTS */
97 if (value & 0xff000000)
99 else if (value & 0x00ff0000)
101 else if (value & 0x0000ff00)
106 if (! ieee_write_byte (abfd,
107 (bfd_byte) ((int) ieee_number_repeat_start_enum
113 if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24)))
117 if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16)))
121 if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8)))
125 if (! ieee_write_byte (abfd, (bfd_byte) (value)))
134 ieee_write_id (abfd, id)
138 size_t length = strlen (id);
142 if (! ieee_write_byte (abfd, (bfd_byte) length))
145 else if (length < 255)
147 if (! ieee_write_byte (abfd, ieee_extension_length_1_enum)
148 || ! ieee_write_byte (abfd, (bfd_byte) length))
151 else if (length < 65535)
153 if (! ieee_write_byte (abfd, ieee_extension_length_2_enum)
154 || ! ieee_write_2bytes (abfd, (int) length))
159 (*_bfd_error_handler)
160 ("%s: string too long (%d chars, max 65535)",
161 bfd_get_filename (abfd), length);
162 bfd_set_error (bfd_error_invalid_operation);
166 if (bfd_write ((PTR) id, 1, length, abfd) != length)
171 /***************************************************************************
172 Functions for reading from ieee files in the strange way that the
176 #define this_byte(ieee) *((ieee)->input_p)
177 #define next_byte(ieee) ((ieee)->input_p++)
178 #define this_byte_and_next(ieee) (*((ieee)->input_p++))
180 static unsigned short
182 common_header_type *ieee;
184 unsigned char c1 = this_byte_and_next (ieee);
185 unsigned char c2 = this_byte_and_next (ieee);
186 return (c1 << 8) | c2;
190 bfd_get_string (ieee, string, length)
191 common_header_type *ieee;
196 for (i = 0; i < length; i++)
198 string[i] = this_byte_and_next (ieee);
204 common_header_type *ieee;
208 length = this_byte_and_next (ieee);
211 /* Simple string of length 0 to 127 */
213 else if (length == 0xde)
215 /* Length is next byte, allowing 0..255 */
216 length = this_byte_and_next (ieee);
218 else if (length == 0xdf)
220 /* Length is next two bytes, allowing 0..65535 */
221 length = this_byte_and_next (ieee);
222 length = (length * 256) + this_byte_and_next (ieee);
224 /* Buy memory and read string */
225 string = bfd_alloc (ieee->abfd, length + 1);
228 bfd_get_string (ieee, string, length);
234 ieee_write_expression (abfd, value, symbol, pcrel, index)
241 unsigned int term_count = 0;
245 if (! ieee_write_int (abfd, value))
250 if (bfd_is_com_section (symbol->section)
251 || bfd_is_und_section (symbol->section))
253 /* Def of a common symbol */
254 if (! ieee_write_byte (abfd, ieee_variable_X_enum)
255 || ! ieee_write_int (abfd, symbol->value))
259 else if (! bfd_is_abs_section (symbol->section))
261 /* Ref to defined symbol - */
263 if (symbol->flags & BSF_GLOBAL)
265 if (! ieee_write_byte (abfd, ieee_variable_I_enum)
266 || ! ieee_write_int (abfd, symbol->value))
270 else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM))
272 /* This is a reference to a defined local symbol. We can
273 easily do a local as a section+offset. */
274 if (! ieee_write_byte (abfd, ieee_variable_R_enum)
275 || ! ieee_write_byte (abfd,
276 (bfd_byte) (symbol->section->index
277 + IEEE_SECTION_NUMBER_BASE)))
280 if (symbol->value != 0)
282 if (! ieee_write_int (abfd, symbol->value))
289 (*_bfd_error_handler)
290 ("%s: unrecognized symbol `%s' flags 0x%x",
291 bfd_get_filename (abfd), bfd_asymbol_name (symbol),
293 bfd_set_error (bfd_error_invalid_operation);
300 /* subtract the pc from here by asking for PC of this section*/
301 if (! ieee_write_byte (abfd, ieee_variable_P_enum)
302 || ! ieee_write_byte (abfd,
303 (bfd_byte) (index + IEEE_SECTION_NUMBER_BASE))
304 || ! ieee_write_byte (abfd, ieee_function_minus_enum))
308 /* Handle the degenerate case of a 0 address. */
311 if (! ieee_write_int (abfd, 0))
315 while (term_count > 1)
317 if (! ieee_write_byte (abfd, ieee_function_plus_enum))
325 /*****************************************************************************/
328 writes any integer into the buffer supplied and always takes 5 bytes
331 ieee_write_int5 (buffer, value)
335 buffer[0] = (bfd_byte) ieee_number_repeat_4_enum;
336 buffer[1] = (value >> 24) & 0xff;
337 buffer[2] = (value >> 16) & 0xff;
338 buffer[3] = (value >> 8) & 0xff;
339 buffer[4] = (value >> 0) & 0xff;
343 ieee_write_int5_out (abfd, value)
349 ieee_write_int5 (b, value);
350 if (bfd_write ((PTR) b, 1, 5, abfd) != 5)
356 parse_int (ieee, value_ptr)
357 common_header_type *ieee;
360 int value = this_byte (ieee);
362 if (value >= 0 && value <= 127)
368 else if (value >= 0x80 && value <= 0x88)
370 unsigned int count = value & 0xf;
375 result = (result << 8) | this_byte_and_next (ieee);
386 common_header_type *ieee;
390 *ok = parse_int (ieee, &x);
395 must_parse_int (ieee)
396 common_header_type *ieee;
399 BFD_ASSERT (parse_int (ieee, &result) == true);
407 ieee_symbol_index_type symbol;
411 #if KEEPMINUSPCININST
413 #define SRC_MASK(arg) arg
414 #define PCREL_OFFSET false
418 #define SRC_MASK(arg) 0
419 #define PCREL_OFFSET true
423 static reloc_howto_type abs32_howto =
430 complain_overflow_bitfield,
438 static reloc_howto_type abs16_howto =
445 complain_overflow_bitfield,
453 static reloc_howto_type abs8_howto =
460 complain_overflow_bitfield,
468 static reloc_howto_type rel32_howto =
475 complain_overflow_signed,
479 SRC_MASK (0xffffffff),
483 static reloc_howto_type rel16_howto =
490 complain_overflow_signed,
494 SRC_MASK (0x0000ffff),
498 static reloc_howto_type rel8_howto =
505 complain_overflow_signed,
509 SRC_MASK (0x000000ff),
513 static ieee_symbol_index_type NOSYMBOL = {0, 0};
516 parse_expression (ieee, value, symbol, pcrel, extra, section)
517 ieee_data_type *ieee;
519 ieee_symbol_index_type *symbol;
532 ieee_value_type stack[10];
534 /* The stack pointer always points to the next unused location */
535 #define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC;
536 #define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value;
537 ieee_value_type *sp = stack;
541 switch (this_byte (&(ieee->h)))
543 case ieee_variable_P_enum:
544 /* P variable, current program counter for section n */
547 next_byte (&(ieee->h));
549 section_n = must_parse_int (&(ieee->h));
550 PUSH (NOSYMBOL, bfd_abs_section_ptr, 0);
553 case ieee_variable_L_enum:
554 /* L variable address of section N */
555 next_byte (&(ieee->h));
556 PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
558 case ieee_variable_R_enum:
559 /* R variable, logical address of section module */
560 /* FIXME, this should be different to L */
561 next_byte (&(ieee->h));
562 PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
564 case ieee_variable_S_enum:
565 /* S variable, size in MAUS of section module */
566 next_byte (&(ieee->h));
569 ieee->section_table[must_parse_int (&(ieee->h))]->_raw_size);
571 case ieee_variable_I_enum:
572 /* Push the address of variable n */
574 ieee_symbol_index_type sy;
575 next_byte (&(ieee->h));
576 sy.index = (int) must_parse_int (&(ieee->h));
579 PUSH (sy, bfd_abs_section_ptr, 0);
582 case ieee_variable_X_enum:
583 /* Push the address of external variable n */
585 ieee_symbol_index_type sy;
586 next_byte (&(ieee->h));
587 sy.index = (int) (must_parse_int (&(ieee->h)));
590 PUSH (sy, bfd_und_section_ptr, 0);
593 case ieee_function_minus_enum:
595 bfd_vma value1, value2;
596 asection *section1, *section_dummy;
597 ieee_symbol_index_type sy;
598 next_byte (&(ieee->h));
600 POP (sy, section1, value1);
601 POP (sy, section_dummy, value2);
602 PUSH (sy, section1 ? section1 : section_dummy, value2 - value1);
605 case ieee_function_plus_enum:
607 bfd_vma value1, value2;
610 ieee_symbol_index_type sy1;
611 ieee_symbol_index_type sy2;
612 next_byte (&(ieee->h));
614 POP (sy1, section1, value1);
615 POP (sy2, section2, value2);
616 PUSH (sy1.letter ? sy1 : sy2,
617 bfd_is_abs_section (section1) ? section2 : section1,
624 BFD_ASSERT (this_byte (&(ieee->h)) < (int) ieee_variable_A_enum
625 || this_byte (&(ieee->h)) > (int) ieee_variable_Z_enum);
626 if (parse_int (&(ieee->h), &va))
628 PUSH (NOSYMBOL, bfd_abs_section_ptr, va);
633 Thats all that we can understand. As far as I can see
634 there is a bug in the Microtec IEEE output which I'm
635 using to scan, whereby the comma operator is omitted
636 sometimes in an expression, giving expressions with too
637 many terms. We can tell if that's the case by ensuring
638 that sp == stack here. If not, then we've pushed
639 something too far, so we keep adding. */
641 while (sp != stack + 1)
644 ieee_symbol_index_type sy1;
645 POP (sy1, section1, *extra);
650 POP (*symbol, dummy, *value);
663 #define ieee_seek(abfd, offset) \
664 IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset
666 #define ieee_pos(abfd) \
667 (IEEE_DATA(abfd)->h.input_p - IEEE_DATA(abfd)->h.first_byte)
669 static unsigned int last_index;
670 static char last_type; /* is the index for an X or a D */
672 static ieee_symbol_type *
682 ieee_data_type *ieee;
683 ieee_symbol_type *last_symbol;
684 unsigned int *symbol_count;
685 ieee_symbol_type ***pptr;
686 unsigned int *max_index;
690 /* Need a new symbol */
691 unsigned int new_index = must_parse_int (&(ieee->h));
692 if (new_index != last_index || this_type != last_type)
694 ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd,
695 sizeof (ieee_symbol_type));
699 new_symbol->index = new_index;
700 last_index = new_index;
703 *pptr = &new_symbol->next;
704 if (new_index > *max_index)
706 *max_index = new_index;
708 last_type = this_type;
709 new_symbol->symbol.section = bfd_abs_section_ptr;
716 ieee_slurp_external_symbols (abfd)
719 ieee_data_type *ieee = IEEE_DATA (abfd);
720 file_ptr offset = ieee->w.r.external_part;
722 ieee_symbol_type **prev_symbols_ptr = &ieee->external_symbols;
723 ieee_symbol_type **prev_reference_ptr = &ieee->external_reference;
724 ieee_symbol_type *symbol = (ieee_symbol_type *) NULL;
725 unsigned int symbol_count = 0;
727 last_index = 0xffffff;
728 ieee->symbol_table_full = true;
730 ieee_seek (abfd, offset);
734 switch (this_byte (&(ieee->h)))
737 next_byte (&(ieee->h));
739 symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
741 &ieee->external_symbol_max_index, 'I');
745 symbol->symbol.the_bfd = abfd;
746 symbol->symbol.name = read_id (&(ieee->h));
747 symbol->symbol.udata.p = (PTR) NULL;
748 symbol->symbol.flags = BSF_NO_FLAGS;
750 case ieee_external_symbol_enum:
751 next_byte (&(ieee->h));
753 symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
755 &ieee->external_symbol_max_index, 'D');
759 BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index);
761 symbol->symbol.the_bfd = abfd;
762 symbol->symbol.name = read_id (&(ieee->h));
763 symbol->symbol.udata.p = (PTR) NULL;
764 symbol->symbol.flags = BSF_NO_FLAGS;
766 case ieee_attribute_record_enum >> 8:
768 unsigned int symbol_name_index;
769 unsigned int symbol_type_index;
770 unsigned int symbol_attribute_def;
772 switch (read_2bytes (ieee))
774 case ieee_attribute_record_enum:
775 symbol_name_index = must_parse_int (&(ieee->h));
776 symbol_type_index = must_parse_int (&(ieee->h));
777 symbol_attribute_def = must_parse_int (&(ieee->h));
778 switch (symbol_attribute_def)
782 parse_int (&ieee->h, &value);
785 (*_bfd_error_handler)
786 ("%s: unimplemented ATI record %u for symbol %u",
787 bfd_get_filename (abfd), symbol_attribute_def,
789 bfd_set_error (bfd_error_bad_value);
794 case ieee_external_reference_info_record_enum:
795 /* Skip over ATX record. */
796 parse_int (&(ieee->h), &value);
797 parse_int (&(ieee->h), &value);
798 parse_int (&(ieee->h), &value);
799 parse_int (&(ieee->h), &value);
804 case ieee_value_record_enum >> 8:
806 unsigned int symbol_name_index;
807 ieee_symbol_index_type symbol_ignore;
808 boolean pcrel_ignore;
810 next_byte (&(ieee->h));
811 next_byte (&(ieee->h));
813 symbol_name_index = must_parse_int (&(ieee->h));
814 parse_expression (ieee,
815 &symbol->symbol.value,
819 &symbol->symbol.section);
821 symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
825 case ieee_weak_external_reference_enum:
829 next_byte (&(ieee->h));
830 /* Throw away the external reference index */
831 (void) must_parse_int (&(ieee->h));
832 /* Fetch the default size if not resolved */
833 size = must_parse_int (&(ieee->h));
834 /* Fetch the defautlt value if available */
835 if (parse_int (&(ieee->h), &value) == false)
839 /* This turns into a common */
840 symbol->symbol.section = bfd_com_section_ptr;
841 symbol->symbol.value = size;
845 case ieee_external_reference_enum:
846 next_byte (&(ieee->h));
848 symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
850 &ieee->external_reference_max_index, 'X');
854 symbol->symbol.the_bfd = abfd;
855 symbol->symbol.name = read_id (&(ieee->h));
856 symbol->symbol.udata.p = (PTR) NULL;
857 symbol->symbol.section = bfd_und_section_ptr;
858 symbol->symbol.value = (bfd_vma) 0;
859 symbol->symbol.flags = 0;
861 BFD_ASSERT (symbol->index >= ieee->external_reference_min_index);
869 if (ieee->external_symbol_max_index != 0)
871 ieee->external_symbol_count =
872 ieee->external_symbol_max_index -
873 ieee->external_symbol_min_index + 1;
877 ieee->external_symbol_count = 0;
880 if (ieee->external_reference_max_index != 0)
882 ieee->external_reference_count =
883 ieee->external_reference_max_index -
884 ieee->external_reference_min_index + 1;
888 ieee->external_reference_count = 0;
892 ieee->external_reference_count + ieee->external_symbol_count;
894 if (symbol_count != abfd->symcount)
896 /* There are gaps in the table -- */
897 ieee->symbol_table_full = false;
900 *prev_symbols_ptr = (ieee_symbol_type *) NULL;
901 *prev_reference_ptr = (ieee_symbol_type *) NULL;
907 ieee_slurp_symbol_table (abfd)
910 if (IEEE_DATA (abfd)->read_symbols == false)
912 if (! ieee_slurp_external_symbols (abfd))
914 IEEE_DATA (abfd)->read_symbols = true;
920 ieee_get_symtab_upper_bound (abfd)
923 if (! ieee_slurp_symbol_table (abfd))
926 return (abfd->symcount != 0) ?
927 (abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0;
931 Move from our internal lists to the canon table, and insert in
935 extern const bfd_target ieee_vec;
938 ieee_get_symtab (abfd, location)
942 ieee_symbol_type *symp;
943 static bfd dummy_bfd;
944 static asymbol empty_symbol =
945 /* the_bfd, name, value, attr, section */
946 {&dummy_bfd, " ieee empty", (symvalue) 0, BSF_DEBUGGING, bfd_abs_section_ptr};
950 ieee_data_type *ieee = IEEE_DATA (abfd);
951 dummy_bfd.xvec = &ieee_vec;
952 if (! ieee_slurp_symbol_table (abfd))
955 if (ieee->symbol_table_full == false)
957 /* Arrgh - there are gaps in the table, run through and fill them */
958 /* up with pointers to a null place */
960 for (i = 0; i < abfd->symcount; i++)
962 location[i] = &empty_symbol;
966 ieee->external_symbol_base_offset = -ieee->external_symbol_min_index;
967 for (symp = IEEE_DATA (abfd)->external_symbols;
968 symp != (ieee_symbol_type *) NULL;
971 /* Place into table at correct index locations */
972 location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;
975 /* The external refs are indexed in a bit */
976 ieee->external_reference_base_offset =
977 -ieee->external_reference_min_index + ieee->external_symbol_count;
979 for (symp = IEEE_DATA (abfd)->external_reference;
980 symp != (ieee_symbol_type *) NULL;
983 location[symp->index + ieee->external_reference_base_offset] =
990 location[abfd->symcount] = (asymbol *) NULL;
992 return abfd->symcount;
996 get_section_entry (abfd, ieee, index)
998 ieee_data_type *ieee;
1001 if (ieee->section_table[index] == (asection *) NULL)
1003 char *tmp = bfd_alloc (abfd, 11);
1008 sprintf (tmp, " fsec%4d", index);
1009 section = bfd_make_section (abfd, tmp);
1010 ieee->section_table[index] = section;
1011 section->flags = SEC_NO_FLAGS;
1012 section->target_index = index;
1013 ieee->section_table[index] = section;
1015 return ieee->section_table[index];
1019 ieee_slurp_sections (abfd)
1022 ieee_data_type *ieee = IEEE_DATA (abfd);
1023 file_ptr offset = ieee->w.r.section_part;
1024 asection *section = (asection *) NULL;
1029 bfd_byte section_type[3];
1030 ieee_seek (abfd, offset);
1033 switch (this_byte (&(ieee->h)))
1035 case ieee_section_type_enum:
1037 unsigned int section_index;
1038 next_byte (&(ieee->h));
1039 section_index = must_parse_int (&(ieee->h));
1040 /* Fixme to be nice about a silly number of sections */
1041 BFD_ASSERT (section_index < NSECTIONS);
1043 section = get_section_entry (abfd, ieee, section_index);
1045 section_type[0] = this_byte_and_next (&(ieee->h));
1047 /* Set minimal section attributes. Attributes are
1048 extended later, based on section contents. */
1050 switch (section_type[0])
1053 /* Normal attributes for absolute sections */
1054 section_type[1] = this_byte (&(ieee->h));
1055 section->flags = SEC_ALLOC;
1056 switch (section_type[1])
1058 case 0xD3: /* AS Absolute section attributes */
1059 next_byte (&(ieee->h));
1060 section_type[2] = this_byte (&(ieee->h));
1061 switch (section_type[2])
1065 next_byte (&(ieee->h));
1066 section->flags |= SEC_CODE;
1070 next_byte (&(ieee->h));
1071 section->flags |= SEC_DATA;
1074 next_byte (&(ieee->h));
1075 /* Normal rom data */
1076 section->flags |= SEC_ROM | SEC_DATA;
1083 case 0xC3: /* Named relocatable sections (type C) */
1084 section_type[1] = this_byte (&(ieee->h));
1085 section->flags = SEC_ALLOC;
1086 switch (section_type[1])
1088 case 0xD0: /* Normal code (CP) */
1089 next_byte (&(ieee->h));
1090 section->flags |= SEC_CODE;
1092 case 0xC4: /* Normal data (CD) */
1093 next_byte (&(ieee->h));
1094 section->flags |= SEC_DATA;
1096 case 0xD2: /* Normal rom data (CR) */
1097 next_byte (&(ieee->h));
1098 section->flags |= SEC_ROM | SEC_DATA;
1105 /* Read section name, use it if non empty. */
1106 name = read_id (&ieee->h);
1108 section->name = name;
1110 /* Skip these fields, which we don't care about */
1112 bfd_vma parent, brother, context;
1113 parse_int (&(ieee->h), &parent);
1114 parse_int (&(ieee->h), &brother);
1115 parse_int (&(ieee->h), &context);
1119 case ieee_section_alignment_enum:
1121 unsigned int section_index;
1124 next_byte (&(ieee->h));
1125 section_index = must_parse_int (&ieee->h);
1126 section = get_section_entry (abfd, ieee, section_index);
1127 if (section_index > ieee->section_count)
1129 ieee->section_count = section_index;
1131 section->alignment_power =
1132 bfd_log2 (must_parse_int (&ieee->h));
1133 (void) parse_int (&(ieee->h), &value);
1136 case ieee_e2_first_byte_enum:
1138 ieee_record_enum_type t = (ieee_record_enum_type) (read_2bytes (&(ieee->h)));
1142 case ieee_section_size_enum:
1143 section = ieee->section_table[must_parse_int (&(ieee->h))];
1144 section->_raw_size = must_parse_int (&(ieee->h));
1146 case ieee_physical_region_size_enum:
1147 section = ieee->section_table[must_parse_int (&(ieee->h))];
1148 section->_raw_size = must_parse_int (&(ieee->h));
1150 case ieee_region_base_address_enum:
1151 section = ieee->section_table[must_parse_int (&(ieee->h))];
1152 section->vma = must_parse_int (&(ieee->h));
1153 section->lma = section->vma;
1155 case ieee_mau_size_enum:
1156 must_parse_int (&(ieee->h));
1157 must_parse_int (&(ieee->h));
1159 case ieee_m_value_enum:
1160 must_parse_int (&(ieee->h));
1161 must_parse_int (&(ieee->h));
1163 case ieee_section_base_address_enum:
1164 section = ieee->section_table[must_parse_int (&(ieee->h))];
1165 section->vma = must_parse_int (&(ieee->h));
1166 section->lma = section->vma;
1168 case ieee_section_offset_enum:
1169 (void) must_parse_int (&(ieee->h));
1170 (void) must_parse_int (&(ieee->h));
1184 /* Make a section for the debugging information, if any. We don't try
1185 to interpret the debugging information; we just point the section
1186 at the area in the file so that program which understand can dig it
1190 ieee_slurp_debug (abfd)
1193 ieee_data_type *ieee = IEEE_DATA (abfd);
1196 if (ieee->w.r.debug_information_part == 0)
1199 sec = bfd_make_section (abfd, ".debug");
1202 sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS;
1203 sec->filepos = ieee->w.r.debug_information_part;
1204 sec->_raw_size = ieee->w.r.data_part - ieee->w.r.debug_information_part;
1209 /***********************************************************************
1214 ieee_archive_p (abfd)
1220 unsigned char buffer[512];
1221 file_ptr buffer_offset = 0;
1222 ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
1223 ieee_ar_data_type *ieee;
1224 abfd->tdata.ieee_ar_data = (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type));
1225 if (!abfd->tdata.ieee_ar_data)
1227 ieee = IEEE_AR_DATA (abfd);
1229 /* FIXME: Check return value. I'm not sure whether it needs to read
1230 the entire buffer or not. */
1231 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
1233 ieee->h.first_byte = buffer;
1234 ieee->h.input_p = buffer;
1236 ieee->h.abfd = abfd;
1238 if (this_byte (&(ieee->h)) != Module_Beginning)
1240 abfd->tdata.ieee_ar_data = save;
1241 return (const bfd_target *) NULL;
1244 next_byte (&(ieee->h));
1245 library = read_id (&(ieee->h));
1246 if (strcmp (library, "LIBRARY") != 0)
1248 bfd_release (abfd, ieee);
1249 abfd->tdata.ieee_ar_data = save;
1250 return (const bfd_target *) NULL;
1252 /* Throw away the filename */
1253 read_id (&(ieee->h));
1255 ieee->element_count = 0;
1256 ieee->element_index = 0;
1258 next_byte (&(ieee->h)); /* Drop the ad part */
1259 must_parse_int (&(ieee->h)); /* And the two dummy numbers */
1260 must_parse_int (&(ieee->h));
1263 /* Read the index of the BB table */
1266 ieee_ar_obstack_type t;
1267 int rec = read_2bytes (&(ieee->h));
1268 if (rec == (int) ieee_assign_value_to_variable_enum)
1270 must_parse_int (&(ieee->h));
1271 t.file_offset = must_parse_int (&(ieee->h));
1272 t.abfd = (bfd *) NULL;
1273 ieee->element_count++;
1275 bfd_alloc_grow (abfd, (PTR) &t, sizeof t);
1277 /* Make sure that we don't go over the end of the buffer */
1279 if ((size_t) ieee_pos (abfd) > sizeof (buffer) / 2)
1281 /* Past half way, reseek and reprime */
1282 buffer_offset += ieee_pos (abfd);
1283 if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0)
1285 /* FIXME: Check return value. I'm not sure whether it
1286 needs to read the entire buffer or not. */
1287 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
1288 ieee->h.first_byte = buffer;
1289 ieee->h.input_p = buffer;
1296 ieee->elements = (ieee_ar_obstack_type *) bfd_alloc_finish (abfd);
1297 if (!ieee->elements)
1298 return (const bfd_target *) NULL;
1300 /* Now scan the area again, and replace BB offsets with file */
1303 for (i = 2; i < ieee->element_count; i++)
1305 if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0)
1307 /* FIXME: Check return value. I'm not sure whether it needs to
1308 read the entire buffer or not. */
1309 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
1310 ieee->h.first_byte = buffer;
1311 ieee->h.input_p = buffer;
1313 next_byte (&(ieee->h)); /* Drop F8 */
1314 next_byte (&(ieee->h)); /* Drop 14 */
1315 must_parse_int (&(ieee->h)); /* Drop size of block */
1316 if (must_parse_int (&(ieee->h)) != 0)
1318 /* This object has been deleted */
1319 ieee->elements[i].file_offset = 0;
1323 ieee->elements[i].file_offset = must_parse_int (&(ieee->h));
1327 /* abfd->has_armap = ;*/
1332 ieee_mkobject (abfd)
1335 abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, sizeof (ieee_data_type));
1336 return abfd->tdata.ieee_data ? true : false;
1340 ieee_object_p (abfd)
1345 ieee_data_type *ieee;
1346 unsigned char buffer[300];
1347 ieee_data_type *save = IEEE_DATA (abfd);
1349 abfd->tdata.ieee_data = 0;
1350 ieee_mkobject (abfd);
1352 ieee = IEEE_DATA (abfd);
1353 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
1355 /* Read the first few bytes in to see if it makes sense */
1356 /* FIXME: Check return value. I'm not sure whether it needs to read
1357 the entire buffer or not. */
1358 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
1360 ieee->h.input_p = buffer;
1361 if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
1362 goto got_wrong_format;
1364 ieee->read_symbols = false;
1365 ieee->read_data = false;
1366 ieee->section_count = 0;
1367 ieee->external_symbol_max_index = 0;
1368 ieee->external_symbol_min_index = IEEE_PUBLIC_BASE;
1369 ieee->external_reference_min_index = IEEE_REFERENCE_BASE;
1370 ieee->external_reference_max_index = 0;
1371 ieee->h.abfd = abfd;
1372 memset ((PTR) ieee->section_table, 0, sizeof (ieee->section_table));
1374 processor = ieee->mb.processor = read_id (&(ieee->h));
1375 if (strcmp (processor, "LIBRARY") == 0)
1376 goto got_wrong_format;
1377 ieee->mb.module_name = read_id (&(ieee->h));
1378 if (abfd->filename == (CONST char *) NULL)
1380 abfd->filename = ieee->mb.module_name;
1382 /* Determine the architecture and machine type of the object file.
1385 const bfd_arch_info_type *arch = bfd_scan_arch (processor);
1387 goto got_wrong_format;
1388 abfd->arch_info = arch;
1391 if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum)
1395 next_byte (&(ieee->h));
1397 if (parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau) == false)
1401 if (parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address) == false)
1406 /* If there is a byte order info, take it */
1407 if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum ||
1408 this_byte (&(ieee->h)) == (int) ieee_variable_M_enum)
1409 next_byte (&(ieee->h));
1411 for (part = 0; part < N_W_VARIABLES; part++)
1414 if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum)
1418 if (this_byte_and_next (&(ieee->h)) != part)
1423 ieee->w.offset[part] = parse_i (&(ieee->h), &ok);
1431 if (ieee->w.r.external_part != 0)
1432 abfd->flags = HAS_SYMS;
1434 /* By now we know that this is a real IEEE file, we're going to read
1435 the whole thing into memory so that we can run up and down it
1436 quickly. We can work out how big the file is from the trailer
1439 IEEE_DATA (abfd)->h.first_byte =
1440 (unsigned char *) bfd_alloc (ieee->h.abfd, ieee->w.r.me_record + 1);
1441 if (!IEEE_DATA (abfd)->h.first_byte)
1443 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
1445 /* FIXME: Check return value. I'm not sure whether it needs to read
1446 the entire buffer or not. */
1447 bfd_read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1,
1448 ieee->w.r.me_record + 1, abfd);
1450 ieee_slurp_sections (abfd);
1452 if (! ieee_slurp_debug (abfd))
1455 /* Parse section data to activate file and section flags implied by
1456 section contents. */
1458 if (! ieee_slurp_section_data (abfd))
1463 bfd_set_error (bfd_error_wrong_format);
1465 (void) bfd_release (abfd, ieee);
1466 abfd->tdata.ieee_data = save;
1467 return (const bfd_target *) NULL;
1471 ieee_get_symbol_info (ignore_abfd, symbol, ret)
1476 bfd_symbol_info (symbol, ret);
1477 if (symbol->name[0] == ' ')
1478 ret->name = "* empty table entry ";
1479 if (!symbol->section)
1480 ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
1484 ieee_print_symbol (ignore_abfd, afile, symbol, how)
1488 bfd_print_symbol_type how;
1490 FILE *file = (FILE *) afile;
1494 case bfd_print_symbol_name:
1495 fprintf (file, "%s", symbol->name);
1497 case bfd_print_symbol_more:
1499 fprintf (file, "%4x %2x", aout_symbol (symbol)->desc & 0xffff,
1500 aout_symbol (symbol)->other & 0xff);
1504 case bfd_print_symbol_all:
1506 const char *section_name =
1507 (symbol->section == (asection *) NULL
1509 : symbol->section->name);
1510 if (symbol->name[0] == ' ')
1512 fprintf (file, "* empty table entry ");
1516 bfd_print_symbol_vandf ((PTR) file, symbol);
1518 fprintf (file, " %-5s %04x %02x %s",
1520 (unsigned) ieee_symbol (symbol)->index,
1530 do_one (ieee, current_map, location_ptr, s, iterations)
1531 ieee_data_type *ieee;
1532 ieee_per_section_type *current_map;
1533 unsigned char *location_ptr;
1537 switch (this_byte (&(ieee->h)))
1539 case ieee_load_constant_bytes_enum:
1541 unsigned int number_of_maus;
1543 next_byte (&(ieee->h));
1544 number_of_maus = must_parse_int (&(ieee->h));
1546 for (i = 0; i < number_of_maus; i++)
1548 location_ptr[current_map->pc++] = this_byte (&(ieee->h));
1549 next_byte (&(ieee->h));
1554 case ieee_load_with_relocation_enum:
1556 boolean loop = true;
1557 next_byte (&(ieee->h));
1560 switch (this_byte (&(ieee->h)))
1562 case ieee_variable_R_enum:
1564 case ieee_function_signed_open_b_enum:
1565 case ieee_function_unsigned_open_b_enum:
1566 case ieee_function_either_open_b_enum:
1568 unsigned int extra = 4;
1569 boolean pcrel = false;
1571 ieee_reloc_type *r =
1572 (ieee_reloc_type *) bfd_alloc (ieee->h.abfd,
1573 sizeof (ieee_reloc_type));
1577 *(current_map->reloc_tail_ptr) = r;
1578 current_map->reloc_tail_ptr = &r->next;
1579 r->next = (ieee_reloc_type *) NULL;
1580 next_byte (&(ieee->h));
1582 r->relent.sym_ptr_ptr = 0;
1583 parse_expression (ieee,
1586 &pcrel, &extra, §ion);
1587 r->relent.address = current_map->pc;
1588 s->flags |= SEC_RELOC;
1589 s->owner->flags |= HAS_RELOC;
1591 if (r->relent.sym_ptr_ptr == 0)
1593 r->relent.sym_ptr_ptr = section->symbol_ptr_ptr;
1596 if (this_byte (&(ieee->h)) == (int) ieee_comma)
1598 next_byte (&(ieee->h));
1599 /* Fetch number of bytes to pad */
1600 extra = must_parse_int (&(ieee->h));
1603 switch (this_byte (&(ieee->h)))
1605 case ieee_function_signed_close_b_enum:
1606 next_byte (&(ieee->h));
1608 case ieee_function_unsigned_close_b_enum:
1609 next_byte (&(ieee->h));
1611 case ieee_function_either_close_b_enum:
1612 next_byte (&(ieee->h));
1617 /* Build a relocation entry for this type */
1618 /* If pc rel then stick -ve pc into instruction
1619 and take out of reloc ..
1621 I've changed this. It's all too complicated. I
1622 keep 0 in the instruction now. */
1631 #if KEEPMINUSPCININST
1632 bfd_put_32 (ieee->h.abfd, -current_map->pc, location_ptr +
1634 r->relent.howto = &rel32_howto;
1638 bfd_put_32 (ieee->h.abfd, 0, location_ptr +
1640 r->relent.howto = &rel32_howto;
1645 bfd_put_32 (ieee->h.abfd, 0, location_ptr +
1647 r->relent.howto = &abs32_howto;
1649 current_map->pc += 4;
1654 #if KEEPMINUSPCININST
1655 bfd_put_16 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc);
1656 r->relent.addend -= current_map->pc;
1657 r->relent.howto = &rel16_howto;
1660 bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1661 r->relent.howto = &rel16_howto;
1667 bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1668 r->relent.howto = &abs16_howto;
1670 current_map->pc += 2;
1675 #if KEEPMINUSPCININST
1676 bfd_put_8 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc);
1677 r->relent.addend -= current_map->pc;
1678 r->relent.howto = &rel8_howto;
1680 bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1681 r->relent.howto = &rel8_howto;
1686 bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1687 r->relent.howto = &abs8_howto;
1689 current_map->pc += 1;
1701 if (parse_int (&(ieee->h), &this_size) == true)
1704 for (i = 0; i < this_size; i++)
1706 location_ptr[current_map->pc++] = this_byte (&(ieee->h));
1707 next_byte (&(ieee->h));
1717 /* Prevent more than the first load-item of an LR record
1718 from being repeated (MRI convention). */
1719 if (iterations != 1)
1727 /* Read in all the section data and relocation stuff too */
1729 ieee_slurp_section_data (abfd)
1732 bfd_byte *location_ptr = (bfd_byte *) NULL;
1733 ieee_data_type *ieee = IEEE_DATA (abfd);
1734 unsigned int section_number;
1736 ieee_per_section_type *current_map = (ieee_per_section_type *) NULL;
1738 /* Seek to the start of the data area */
1739 if (ieee->read_data == true)
1741 ieee->read_data = true;
1742 ieee_seek (abfd, ieee->w.r.data_part);
1744 /* Allocate enough space for all the section contents */
1746 for (s = abfd->sections; s != (asection *) NULL; s = s->next)
1748 ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;
1749 if ((s->flags & SEC_DEBUGGING) != 0)
1751 per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size);
1755 per->reloc_tail_ptr =
1756 (ieee_reloc_type **) & (s->relocation);
1761 switch (this_byte (&(ieee->h)))
1763 /* IF we see anything strange then quit */
1767 case ieee_set_current_section_enum:
1768 next_byte (&(ieee->h));
1769 section_number = must_parse_int (&(ieee->h));
1770 s = ieee->section_table[section_number];
1771 s->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
1772 current_map = (ieee_per_section_type *) s->used_by_bfd;
1773 location_ptr = current_map->data - s->vma;
1774 /* The document I have says that Microtec's compilers reset */
1775 /* this after a sec section, even though the standard says not */
1777 current_map->pc = s->vma;
1780 case ieee_e2_first_byte_enum:
1781 next_byte (&(ieee->h));
1782 switch (this_byte (&(ieee->h)))
1784 case ieee_set_current_pc_enum & 0xff:
1787 ieee_symbol_index_type symbol;
1790 next_byte (&(ieee->h));
1791 must_parse_int (&(ieee->h)); /* Thow away section #*/
1792 parse_expression (ieee, &value,
1796 current_map->pc = value;
1797 BFD_ASSERT ((unsigned) (value - s->vma) <= s->_raw_size);
1801 case ieee_value_starting_address_enum & 0xff:
1802 /* We've got to the end of the data now - */
1809 case ieee_repeat_data_enum:
1811 /* Repeat the following LD or LR n times - we do this by
1812 remembering the stream pointer before running it and
1813 resetting it and running it n times. We special case
1814 the repetition of a repeat_data/load_constant
1817 unsigned int iterations;
1818 unsigned char *start;
1819 next_byte (&(ieee->h));
1820 iterations = must_parse_int (&(ieee->h));
1821 start = ieee->h.input_p;
1822 if (start[0] == (int) ieee_load_constant_bytes_enum &&
1825 while (iterations != 0)
1827 location_ptr[current_map->pc++] = start[2];
1830 next_byte (&(ieee->h));
1831 next_byte (&(ieee->h));
1832 next_byte (&(ieee->h));
1836 while (iterations != 0)
1838 ieee->h.input_p = start;
1839 if (!do_one (ieee, current_map, location_ptr, s,
1847 case ieee_load_constant_bytes_enum:
1848 case ieee_load_with_relocation_enum:
1850 if (!do_one (ieee, current_map, location_ptr, s, 1))
1858 ieee_new_section_hook (abfd, newsect)
1862 newsect->used_by_bfd = (PTR)
1863 bfd_alloc (abfd, sizeof (ieee_per_section_type));
1864 if (!newsect->used_by_bfd)
1866 ieee_per_section (newsect)->data = (bfd_byte *) NULL;
1867 ieee_per_section (newsect)->section = newsect;
1872 ieee_get_reloc_upper_bound (abfd, asect)
1876 if ((asect->flags & SEC_DEBUGGING) != 0)
1878 if (! ieee_slurp_section_data (abfd))
1880 return (asect->reloc_count + 1) * sizeof (arelent *);
1884 ieee_get_section_contents (abfd, section, location, offset, count)
1889 bfd_size_type count;
1891 ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;
1892 if ((section->flags & SEC_DEBUGGING) != 0)
1893 return _bfd_generic_get_section_contents (abfd, section, location,
1895 ieee_slurp_section_data (abfd);
1896 (void) memcpy ((PTR) location, (PTR) (p->data + offset), (unsigned) count);
1901 ieee_canonicalize_reloc (abfd, section, relptr, symbols)
1907 /* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
1908 ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation);
1909 ieee_data_type *ieee = IEEE_DATA (abfd);
1911 if ((section->flags & SEC_DEBUGGING) != 0)
1914 while (src != (ieee_reloc_type *) NULL)
1916 /* Work out which symbol to attach it this reloc to */
1917 switch (src->symbol.letter)
1920 src->relent.sym_ptr_ptr =
1921 symbols + src->symbol.index + ieee->external_symbol_base_offset;
1924 src->relent.sym_ptr_ptr =
1925 symbols + src->symbol.index + ieee->external_reference_base_offset;
1928 src->relent.sym_ptr_ptr =
1929 src->relent.sym_ptr_ptr[0]->section->symbol_ptr_ptr;
1935 *relptr++ = &src->relent;
1938 *relptr = (arelent *) NULL;
1939 return section->reloc_count;
1947 arelent *a = *((arelent **) ap);
1948 arelent *b = *((arelent **) bp);
1949 return a->address - b->address;
1952 /* Write the section headers. */
1955 ieee_write_section_part (abfd)
1958 ieee_data_type *ieee = IEEE_DATA (abfd);
1960 ieee->w.r.section_part = bfd_tell (abfd);
1961 for (s = abfd->sections; s != (asection *) NULL; s = s->next)
1963 if (! bfd_is_abs_section (s)
1964 && (s->flags & SEC_DEBUGGING) == 0)
1966 if (! ieee_write_byte (abfd, ieee_section_type_enum)
1967 || ! ieee_write_byte (abfd,
1968 (bfd_byte) (s->index
1969 + IEEE_SECTION_NUMBER_BASE)))
1972 if (abfd->flags & EXEC_P)
1974 /* This image is executable, so output absolute sections */
1975 if (! ieee_write_byte (abfd, ieee_variable_A_enum)
1976 || ! ieee_write_byte (abfd, ieee_variable_S_enum))
1981 if (! ieee_write_byte (abfd, ieee_variable_C_enum))
1985 switch (s->flags & (SEC_CODE | SEC_DATA | SEC_ROM))
1987 case SEC_CODE | SEC_LOAD:
1989 if (! ieee_write_byte (abfd, ieee_variable_P_enum))
1994 if (! ieee_write_byte (abfd, ieee_variable_D_enum))
1998 case SEC_ROM | SEC_DATA:
1999 case SEC_ROM | SEC_LOAD:
2000 case SEC_ROM | SEC_DATA | SEC_LOAD:
2001 if (! ieee_write_byte (abfd, ieee_variable_R_enum))
2006 if (! ieee_write_id (abfd, s->name))
2009 ieee_write_int (abfd, 0); /* Parent */
2010 ieee_write_int (abfd, 0); /* Brother */
2011 ieee_write_int (abfd, 0); /* Context */
2014 if (! ieee_write_byte (abfd, ieee_section_alignment_enum)
2015 || ! ieee_write_byte (abfd,
2016 (bfd_byte) (s->index
2017 + IEEE_SECTION_NUMBER_BASE))
2018 || ! ieee_write_int (abfd, 1 << s->alignment_power))
2022 if (! ieee_write_2bytes (abfd, ieee_section_size_enum)
2023 || ! ieee_write_byte (abfd,
2024 (bfd_byte) (s->index
2025 + IEEE_SECTION_NUMBER_BASE))
2026 || ! ieee_write_int (abfd, s->_raw_size))
2028 if (abfd->flags & EXEC_P)
2030 /* Relocateable sections don't have asl records */
2032 if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum)
2033 || ! ieee_write_byte (abfd,
2036 + IEEE_SECTION_NUMBER_BASE)))
2037 || ! ieee_write_int (abfd, s->vma))
2048 do_with_relocs (abfd, s)
2052 unsigned int number_of_maus_in_address =
2053 bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd);
2054 unsigned int relocs_to_go = s->reloc_count;
2055 bfd_byte *stream = ieee_per_section (s)->data;
2056 arelent **p = s->orelocation;
2057 bfd_size_type current_byte_index = 0;
2059 qsort (s->orelocation,
2061 sizeof (arelent **),
2064 /* Output the section preheader */
2065 if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
2066 || ! ieee_write_byte (abfd,
2067 (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))
2068 || ! ieee_write_2bytes (abfd, ieee_set_current_pc_enum)
2069 || ! ieee_write_byte (abfd,
2070 (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)))
2072 if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0)
2074 if (! ieee_write_int (abfd, s->vma))
2079 if (! ieee_write_expression (abfd, 0, s->symbol, 0, 0))
2083 if (relocs_to_go == 0)
2085 /* If there aren't any relocations then output the load constant
2086 byte opcode rather than the load with relocation opcode */
2088 while (current_byte_index < s->_raw_size)
2091 unsigned int MAXRUN = 127;
2093 if (run > s->_raw_size - current_byte_index)
2095 run = s->_raw_size - current_byte_index;
2100 if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum))
2102 /* Output a stream of bytes */
2103 if (! ieee_write_int (abfd, run))
2105 if (bfd_write ((PTR) (stream + current_byte_index),
2111 current_byte_index += run;
2117 if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum))
2120 /* Output the data stream as the longest sequence of bytes
2121 possible, allowing for the a reasonable packet size and
2122 relocation stuffs. */
2124 if ((PTR) stream == (PTR) NULL)
2126 /* Outputting a section without data, fill it up */
2127 stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));
2130 memset ((PTR) stream, 0, (size_t) s->_raw_size);
2132 while (current_byte_index < s->_raw_size)
2135 unsigned int MAXRUN = 127;
2138 run = (*p)->address - current_byte_index;
2146 if (run > s->_raw_size - current_byte_index)
2148 run = s->_raw_size - current_byte_index;
2153 /* Output a stream of bytes */
2154 if (! ieee_write_int (abfd, run))
2156 if (bfd_write ((PTR) (stream + current_byte_index),
2162 current_byte_index += run;
2164 /* Output any relocations here */
2165 if (relocs_to_go && (*p) && (*p)->address == current_byte_index)
2168 && (*p) && (*p)->address == current_byte_index)
2174 if (r->howto->pc_relative)
2176 r->addend += current_byte_index;
2180 switch (r->howto->size)
2184 ov = bfd_get_signed_32 (abfd,
2185 stream + current_byte_index);
2186 current_byte_index += 4;
2189 ov = bfd_get_signed_16 (abfd,
2190 stream + current_byte_index);
2191 current_byte_index += 2;
2194 ov = bfd_get_signed_8 (abfd,
2195 stream + current_byte_index);
2196 current_byte_index++;
2204 ov &= r->howto->src_mask;
2206 if (r->howto->pc_relative
2207 && ! r->howto->pcrel_offset)
2210 if (! ieee_write_byte (abfd,
2211 ieee_function_either_open_b_enum))
2216 if (r->sym_ptr_ptr != (asymbol **) NULL)
2218 if (! ieee_write_expression (abfd, r->addend + ov,
2220 r->howto->pc_relative,
2226 if (! ieee_write_expression (abfd, r->addend + ov,
2228 r->howto->pc_relative,
2233 if (number_of_maus_in_address
2234 != bfd_get_reloc_size (r->howto))
2236 if (! ieee_write_int (abfd,
2237 bfd_get_reloc_size (r->howto)))
2240 if (! ieee_write_byte (abfd,
2241 ieee_function_either_close_b_enum))
2255 /* If there are no relocations in the output section then we can be
2256 clever about how we write. We block items up into a max of 127
2260 do_as_repeat (abfd, s)
2266 if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
2267 || ! ieee_write_byte (abfd,
2268 (bfd_byte) (s->index
2269 + IEEE_SECTION_NUMBER_BASE))
2270 || ! ieee_write_byte (abfd, ieee_set_current_pc_enum >> 8)
2271 || ! ieee_write_byte (abfd, ieee_set_current_pc_enum & 0xff)
2272 || ! ieee_write_byte (abfd,
2273 (bfd_byte) (s->index
2274 + IEEE_SECTION_NUMBER_BASE))
2275 || ! ieee_write_int (abfd, s->vma)
2276 || ! ieee_write_byte (abfd, ieee_repeat_data_enum)
2277 || ! ieee_write_int (abfd, s->_raw_size)
2278 || ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)
2279 || ! ieee_write_byte (abfd, 1)
2280 || ! ieee_write_byte (abfd, 0))
2288 do_without_relocs (abfd, s)
2292 bfd_byte *stream = ieee_per_section (s)->data;
2294 if (stream == 0 || ((s->flags & SEC_LOAD) == 0))
2296 if (! do_as_repeat (abfd, s))
2302 for (i = 0; i < s->_raw_size; i++)
2306 if (! do_with_relocs (abfd, s))
2311 if (! do_as_repeat (abfd, s))
2319 static unsigned char *output_ptr_start;
2320 static unsigned char *output_ptr;
2321 static unsigned char *output_ptr_end;
2322 static unsigned char *input_ptr_start;
2323 static unsigned char *input_ptr;
2324 static unsigned char *input_ptr_end;
2325 static bfd *input_bfd;
2326 static bfd *output_bfd;
2327 static int output_buffer;
2332 /* FIXME: Check return value. I'm not sure whether it needs to read
2333 the entire buffer or not. */
2334 bfd_read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd);
2335 input_ptr = input_ptr_start;
2340 if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start,
2342 != (bfd_size_type) (output_ptr - output_ptr_start))
2344 output_ptr = output_ptr_start;
2348 #define THIS() ( *input_ptr )
2349 #define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); }
2350 #define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end) flush(); }
2356 if (value >= 0 && value <= 127)
2362 unsigned int length;
2363 /* How many significant bytes ? */
2364 /* FIXME FOR LONGER INTS */
2365 if (value & 0xff000000)
2369 else if (value & 0x00ff0000)
2373 else if (value & 0x0000ff00)
2380 OUT ((int) ieee_number_repeat_start_enum + length);
2399 int length = THIS ();
2411 #define VAR(x) ((x | 0x80))
2426 value = (value << 8) | THIS ();
2428 value = (value << 8) | THIS ();
2430 value = (value << 8) | THIS ();
2438 value = (value << 8) | THIS ();
2440 value = (value << 8) | THIS ();
2448 value = (value << 8) | THIS ();
2465 /* Not a number, just bug out with the answer */
2466 write_int (*(--tos));
2476 int value = *(--tos);
2485 ieee_data_type *ieee;
2488 section_number = THIS ();
2491 ieee = IEEE_DATA (input_bfd);
2492 s = ieee->section_table[section_number];
2493 if (s->output_section)
2495 value = s->output_section->vma;
2501 value += s->output_offset;
2509 write_int (*(--tos));
2519 /* Drop the int in the buffer, and copy a null into the gap, which we
2520 will overwrite later */
2522 struct output_buffer_struct
2524 unsigned char *ptrp;
2530 struct output_buffer_struct *buf;
2532 if (buf->buffer == output_buffer)
2534 /* Still a chance to output the size */
2535 int value = output_ptr - buf->ptrp + 3;
2536 buf->ptrp[0] = value >> 24;
2537 buf->ptrp[1] = value >> 16;
2538 buf->ptrp[2] = value >> 8;
2539 buf->ptrp[3] = value >> 0;
2545 struct output_buffer_struct *buf;
2571 buf->ptrp = output_ptr;
2572 buf->buffer = output_buffer;
2612 #define ID copy_id()
2613 #define INT copy_int()
2614 #define EXP copy_expression()
2615 static void copy_till_end ();
2616 #define INTn(q) copy_int()
2617 #define EXPn(q) copy_expression()
2656 EXPn (instruction address);
2690 EXPn (external function);
2700 INTn (locked register);
2723 /* Attribute record */
2781 static void block ();
2793 /* Unique typedefs for module */
2794 /* GLobal typedefs */
2795 /* High level module scope beginning */
2797 struct output_buffer_struct ob;
2812 /* Global function */
2814 struct output_buffer_struct ob;
2828 EXPn (size of block);
2834 /* File name for source line numbers */
2836 struct output_buffer_struct ob;
2856 /* Local function */
2858 struct output_buffer_struct ob;
2876 /* Assembler module scope beginning -*/
2878 struct output_buffer_struct ob;
2904 struct output_buffer_struct ob;
2911 INTn (section index);
2919 EXPn (Size in Maus);
2974 moves all the debug information from the source bfd to the output
2975 bfd, and relocates any expressions it finds
2979 relocate_debug (output, input)
2985 unsigned char input_buffer[IBS];
2987 input_ptr_start = input_ptr = input_buffer;
2988 input_ptr_end = input_buffer + IBS;
2990 /* FIXME: Check return value. I'm not sure whether it needs to read
2991 the entire buffer or not. */
2992 bfd_read ((PTR) input_ptr_start, 1, IBS, input);
2997 During linking, we we told about the bfds which made up our
2998 contents, we have a list of them. They will still be open, so go to
2999 the debug info in each, and copy it out, relocating it as we go.
3003 ieee_write_debug_part (abfd)
3006 ieee_data_type *ieee = IEEE_DATA (abfd);
3007 bfd_chain_type *chain = ieee->chain_root;
3008 unsigned char output_buffer[OBS];
3009 boolean some_debug = false;
3010 file_ptr here = bfd_tell (abfd);
3012 output_ptr_start = output_ptr = output_buffer;
3013 output_ptr_end = output_buffer + OBS;
3014 output_ptr = output_buffer;
3017 if (chain == (bfd_chain_type *) NULL)
3021 for (s = abfd->sections; s != NULL; s = s->next)
3022 if ((s->flags & SEC_DEBUGGING) != 0)
3026 ieee->w.r.debug_information_part = 0;
3030 ieee->w.r.debug_information_part = here;
3031 if (bfd_write (s->contents, 1, s->_raw_size, abfd) != s->_raw_size)
3036 while (chain != (bfd_chain_type *) NULL)
3038 bfd *entry = chain->this;
3039 ieee_data_type *entry_ieee = IEEE_DATA (entry);
3040 if (entry_ieee->w.r.debug_information_part)
3042 if (bfd_seek (entry, entry_ieee->w.r.debug_information_part,
3046 relocate_debug (abfd, entry);
3049 chain = chain->next;
3053 ieee->w.r.debug_information_part = here;
3057 ieee->w.r.debug_information_part = 0;
3066 /* Write the data in an ieee way. */
3069 ieee_write_data_part (abfd)
3073 ieee_data_type *ieee = IEEE_DATA (abfd);
3074 ieee->w.r.data_part = bfd_tell (abfd);
3075 for (s = abfd->sections; s != (asection *) NULL; s = s->next)
3077 /* Skip sections that have no loadable contents (.bss,
3079 if ((s->flags & SEC_LOAD) == 0)
3082 /* Sort the reloc records so we can insert them in the correct
3084 if (s->reloc_count != 0)
3086 if (! do_with_relocs (abfd, s))
3091 if (! do_without_relocs (abfd, s))
3101 init_for_output (abfd)
3105 for (s = abfd->sections; s != (asection *) NULL; s = s->next)
3107 if ((s->flags & SEC_DEBUGGING) != 0)
3109 if (s->_raw_size != 0)
3111 ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size));
3112 if (!ieee_per_section (s)->data)
3119 /** exec and core file sections */
3121 /* set section contents is complicated with IEEE since the format is
3122 * not a byte image, but a record stream.
3125 ieee_set_section_contents (abfd, section, location, offset, count)
3130 bfd_size_type count;
3132 if ((section->flags & SEC_DEBUGGING) != 0)
3134 if (section->contents == NULL)
3136 section->contents = bfd_alloc (abfd, section->_raw_size);
3137 if (section->contents == NULL)
3140 /* bfd_set_section_contents has already checked that everything
3142 memcpy (section->contents + offset, location, count);
3146 if (ieee_per_section (section)->data == (bfd_byte *) NULL)
3148 if (!init_for_output (abfd))
3151 memcpy ((PTR) (ieee_per_section (section)->data + offset),
3153 (unsigned int) count);
3157 /* Write the external symbols of a file. IEEE considers two sorts of
3158 external symbols, public, and referenced. It uses to internal
3159 forms to index them as well. When we write them out we turn their
3160 symbol values into indexes from the right base. */
3163 ieee_write_external_part (abfd)
3167 ieee_data_type *ieee = IEEE_DATA (abfd);
3169 unsigned int reference_index = IEEE_REFERENCE_BASE;
3170 unsigned int public_index = IEEE_PUBLIC_BASE + 2;
3171 file_ptr here = bfd_tell (abfd);
3172 boolean hadone = false;
3173 if (abfd->outsymbols != (asymbol **) NULL)
3176 for (q = abfd->outsymbols; *q != (asymbol *) NULL; q++)
3180 if (bfd_is_und_section (p->section))
3182 /* This must be a symbol reference .. */
3183 if (! ieee_write_byte (abfd, ieee_external_reference_enum)
3184 || ! ieee_write_int (abfd, reference_index)
3185 || ! ieee_write_id (abfd, p->name))
3187 p->value = reference_index;
3190 else if (bfd_is_com_section (p->section))
3192 /* This is a weak reference */
3193 if (! ieee_write_byte (abfd, ieee_external_reference_enum)
3194 || ! ieee_write_int (abfd, reference_index)
3195 || ! ieee_write_id (abfd, p->name)
3196 || ! ieee_write_byte (abfd,
3197 ieee_weak_external_reference_enum)
3198 || ! ieee_write_int (abfd, reference_index)
3199 || ! ieee_write_int (abfd, p->value))
3201 p->value = reference_index;
3204 else if (p->flags & BSF_GLOBAL)
3206 /* This must be a symbol definition */
3208 if (! ieee_write_byte (abfd, ieee_external_symbol_enum)
3209 || ! ieee_write_int (abfd, public_index)
3210 || ! ieee_write_id (abfd, p->name)
3211 || ! ieee_write_2bytes (abfd, ieee_attribute_record_enum)
3212 || ! ieee_write_int (abfd, public_index)
3213 || ! ieee_write_byte (abfd, 15) /* instruction address */
3214 || ! ieee_write_byte (abfd, 19) /* static symbol */
3215 || ! ieee_write_byte (abfd, 1)) /* one of them */
3218 /* Write out the value */
3219 if (! ieee_write_2bytes (abfd, ieee_value_record_enum)
3220 || ! ieee_write_int (abfd, public_index))
3222 if (! bfd_is_abs_section (p->section))
3224 if (abfd->flags & EXEC_P)
3226 /* If fully linked, then output all symbols
3228 if (! (ieee_write_int
3231 + p->section->output_offset
3232 + p->section->output_section->vma))))
3237 if (! (ieee_write_expression
3239 p->value + p->section->output_offset,
3240 p->section->output_section->symbol,
3247 if (! ieee_write_expression (abfd,
3249 bfd_abs_section_ptr->symbol,
3253 p->value = public_index;
3258 /* This can happen - when there are gaps in the symbols read */
3259 /* from an input ieee file */
3264 ieee->w.r.external_part = here;
3270 static CONST unsigned char exten[] =
3273 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */
3274 0xf1, 0xce, 0x20, 0x00, 39, 2,/* keep symbol in original case */
3275 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */
3278 static CONST unsigned char envi[] =
3282 /* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11,
3285 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok */
3287 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix */
3288 /* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */
3292 ieee_write_me_part (abfd)
3295 ieee_data_type *ieee = IEEE_DATA (abfd);
3296 ieee->w.r.trailer_part = bfd_tell (abfd);
3297 if (abfd->start_address)
3299 if (! ieee_write_2bytes (abfd, ieee_value_starting_address_enum)
3300 || ! ieee_write_byte (abfd, ieee_function_either_open_b_enum)
3301 || ! ieee_write_int (abfd, abfd->start_address)
3302 || ! ieee_write_byte (abfd, ieee_function_either_close_b_enum))
3305 ieee->w.r.me_record = bfd_tell (abfd);
3306 if (! ieee_write_byte (abfd, ieee_module_end_enum))
3311 /* Write out the IEEE processor ID. */
3314 ieee_write_processor (abfd)
3317 const bfd_arch_info_type *arch;
3319 arch = bfd_get_arch_info (abfd);
3323 if (! ieee_write_id (abfd, bfd_printable_name (abfd)))
3328 if (! ieee_write_id (abfd, "29000"))
3332 case bfd_arch_h8300:
3333 if (! ieee_write_id (abfd, "H8/300"))
3337 case bfd_arch_h8500:
3338 if (! ieee_write_id (abfd, "H8/500"))
3346 case bfd_mach_i960_core:
3347 case bfd_mach_i960_ka_sa:
3348 if (! ieee_write_id (abfd, "80960KA"))
3352 case bfd_mach_i960_kb_sb:
3353 if (! ieee_write_id (abfd, "80960KB"))
3357 case bfd_mach_i960_ca:
3358 if (! ieee_write_id (abfd, "80960CA"))
3362 case bfd_mach_i960_mc:
3363 case bfd_mach_i960_xa:
3364 if (! ieee_write_id (abfd, "80960MC"))
3374 sprintf (ab, "%lu", arch->mach);
3375 if (! ieee_write_id (abfd, ab))
3385 ieee_write_object_contents (abfd)
3388 ieee_data_type *ieee = IEEE_DATA (abfd);
3392 /* Fast forward over the header area */
3393 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
3396 if (! ieee_write_byte (abfd, ieee_module_beginning_enum)
3397 || ! ieee_write_processor (abfd)
3398 || ! ieee_write_id (abfd, abfd->filename))
3401 /* Fast forward over the variable bits */
3402 if (! ieee_write_byte (abfd, ieee_address_descriptor_enum))
3406 if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd))))
3408 /* MAU's per address */
3409 if (! ieee_write_byte (abfd,
3410 (bfd_byte) (bfd_arch_bits_per_address (abfd)
3411 / bfd_arch_bits_per_byte (abfd))))
3414 old = bfd_tell (abfd);
3415 if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0)
3418 ieee->w.r.extension_record = bfd_tell (abfd);
3419 if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten))
3421 if (abfd->flags & EXEC_P)
3423 if (! ieee_write_byte (abfd, 0x1)) /* Absolute */
3428 if (! ieee_write_byte (abfd, 0x2)) /* Relocateable */
3432 ieee->w.r.environmental_record = bfd_tell (abfd);
3433 if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi))
3439 if (! ieee_write_section_part (abfd))
3441 /* First write the symbols. This changes their values into table
3442 indeces so we cant use it after this point. */
3443 if (! ieee_write_external_part (abfd))
3446 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
3448 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
3451 /* Write any debugs we have been told about. */
3452 if (! ieee_write_debug_part (abfd))
3455 /* Can only write the data once the symbols have been written, since
3456 the data contains relocation information which points to the
3458 if (! ieee_write_data_part (abfd))
3461 /* At the end we put the end! */
3462 if (! ieee_write_me_part (abfd))
3465 /* Generate the header */
3466 if (bfd_seek (abfd, old, SEEK_SET) != 0)
3469 for (i = 0; i < N_W_VARIABLES; i++)
3471 if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum)
3472 || ! ieee_write_byte (abfd, (bfd_byte) i)
3473 || ! ieee_write_int5_out (abfd, ieee->w.offset[i]))
3480 /* Native-level interface to symbols. */
3482 /* We read the symbols into a buffer, which is discarded when this
3483 function exits. We read the strings into a buffer large enough to
3484 hold them all plus all the cached symbol entries. */
3487 ieee_make_empty_symbol (abfd)
3490 ieee_symbol_type *new =
3491 (ieee_symbol_type *) bfd_zmalloc (sizeof (ieee_symbol_type));
3494 new->symbol.the_bfd = abfd;
3495 return &new->symbol;
3499 ieee_openr_next_archived_file (arch, prev)
3503 ieee_ar_data_type *ar = IEEE_AR_DATA (arch);
3504 /* take the next one from the arch state, or reset */
3505 if (prev == (bfd *) NULL)
3507 /* Reset the index - the first two entries are bogus*/
3508 ar->element_index = 2;
3512 ieee_ar_obstack_type *p = ar->elements + ar->element_index;
3513 ar->element_index++;
3514 if (ar->element_index <= ar->element_count)
3516 if (p->file_offset != (file_ptr) 0)
3518 if (p->abfd == (bfd *) NULL)
3520 p->abfd = _bfd_create_empty_archive_element_shell (arch);
3521 p->abfd->origin = p->file_offset;
3528 bfd_set_error (bfd_error_no_more_archived_files);
3529 return (bfd *) NULL;
3536 ieee_find_nearest_line (abfd,
3547 char **filename_ptr;
3548 char **functionname_ptr;
3555 ieee_generic_stat_arch_elt (abfd, buf)
3559 ieee_ar_data_type *ar = abfd->my_archive->tdata.ieee_ar_data;
3560 ieee_data_type *ieee;
3562 if (ar == (ieee_ar_data_type *) NULL)
3564 bfd_set_error (bfd_error_invalid_operation);
3568 if (IEEE_DATA (abfd) == NULL)
3570 if (ieee_object_p (abfd) == NULL)
3572 bfd_set_error (bfd_error_wrong_format);
3577 ieee = IEEE_DATA (abfd);
3579 buf->st_size = ieee->w.r.me_record + 1;
3580 buf->st_mode = 0644;
3585 ieee_sizeof_headers (abfd, x)
3593 /* The debug info routines are never used. */
3597 ieee_bfd_debug_info_start (abfd)
3604 ieee_bfd_debug_info_end (abfd)
3611 /* Add this section to the list of sections we have debug info for, to
3612 be ready to output it at close time
3615 ieee_bfd_debug_info_accumulate (abfd, section)
3619 ieee_data_type *ieee = IEEE_DATA (section->owner);
3620 ieee_data_type *output_ieee = IEEE_DATA (abfd);
3621 /* can only accumulate data from other ieee bfds */
3622 if (section->owner->xvec != abfd->xvec)
3624 /* Only bother once per bfd */
3625 if (ieee->done_debug == true)
3627 ieee->done_debug = true;
3629 /* Don't bother if there is no debug info */
3630 if (ieee->w.r.debug_information_part == 0)
3636 bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, sizeof (bfd_chain_type));
3638 abort (); /* FIXME */
3639 n->this = section->owner;
3640 n->next = (bfd_chain_type *) NULL;
3642 if (output_ieee->chain_head)
3644 output_ieee->chain_head->next = n;
3648 output_ieee->chain_root = n;
3651 output_ieee->chain_head = n;
3657 #define ieee_close_and_cleanup _bfd_generic_close_and_cleanup
3658 #define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
3660 #define ieee_slurp_armap bfd_true
3661 #define ieee_slurp_extended_name_table bfd_true
3662 #define ieee_construct_extended_name_table \
3663 ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
3665 #define ieee_truncate_arname bfd_dont_truncate_arname
3666 #define ieee_write_armap \
3668 PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
3670 #define ieee_read_ar_hdr bfd_nullvoidptr
3671 #define ieee_update_armap_timestamp bfd_true
3672 #define ieee_get_elt_at_index _bfd_generic_get_elt_at_index
3674 #define ieee_bfd_is_local_label bfd_generic_is_local_label
3675 #define ieee_get_lineno _bfd_nosymbols_get_lineno
3676 #define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
3677 #define ieee_read_minisymbols _bfd_generic_read_minisymbols
3678 #define ieee_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
3680 #define ieee_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
3682 #define ieee_set_arch_mach _bfd_generic_set_arch_mach
3684 #define ieee_get_section_contents_in_window \
3685 _bfd_generic_get_section_contents_in_window
3686 #define ieee_bfd_get_relocated_section_contents \
3687 bfd_generic_get_relocated_section_contents
3688 #define ieee_bfd_relax_section bfd_generic_relax_section
3689 #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
3690 #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
3691 #define ieee_bfd_final_link _bfd_generic_final_link
3692 #define ieee_bfd_link_split_section _bfd_generic_link_split_section
3695 const bfd_target ieee_vec =
3698 bfd_target_ieee_flavour,
3699 BFD_ENDIAN_UNKNOWN, /* target byte order */
3700 BFD_ENDIAN_UNKNOWN, /* target headers byte order */
3701 (HAS_RELOC | EXEC_P | /* object flags */
3702 HAS_LINENO | HAS_DEBUG |
3703 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
3704 (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
3705 | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
3706 0, /* leading underscore */
3707 ' ', /* ar_pad_char */
3708 16, /* ar_max_namelen */
3709 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
3710 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
3711 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
3712 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
3713 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
3714 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
3717 ieee_object_p, /* bfd_check_format */
3724 _bfd_generic_mkarchive,
3729 ieee_write_object_contents,
3730 _bfd_write_archive_contents,
3734 BFD_JUMP_TABLE_GENERIC (ieee),
3735 BFD_JUMP_TABLE_COPY (_bfd_generic),
3736 BFD_JUMP_TABLE_CORE (_bfd_nocore),
3737 BFD_JUMP_TABLE_ARCHIVE (ieee),
3738 BFD_JUMP_TABLE_SYMBOLS (ieee),
3739 BFD_JUMP_TABLE_RELOCS (ieee),
3740 BFD_JUMP_TABLE_WRITE (ieee),
3741 BFD_JUMP_TABLE_LINK (ieee),
3742 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),