1 /* BFD back-end for ieee-695 objects.
2 Copyright (C) 1990, 91, 92, 93, 94, 95, 96, 97, 1998
3 Free Software Foundation, Inc.
5 Written by Steve Chamberlain of Cygnus Support.
7 This file is part of BFD, the Binary File Descriptor library.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
23 #define KEEPMINUSPCININST 0
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
35 static boolean ieee_write_byte PARAMS ((bfd *, int));
36 static boolean ieee_write_2bytes PARAMS ((bfd *, int));
37 static boolean ieee_write_int PARAMS ((bfd *, bfd_vma));
38 static boolean ieee_write_id PARAMS ((bfd *, const char *));
39 static boolean ieee_write_expression
40 PARAMS ((bfd *, bfd_vma, asymbol *, boolean, unsigned int));
41 static void ieee_write_int5 PARAMS ((bfd_byte *, bfd_vma));
42 static boolean ieee_write_int5_out PARAMS ((bfd *, bfd_vma));
43 static boolean ieee_write_section_part PARAMS ((bfd *));
44 static boolean do_with_relocs PARAMS ((bfd *, asection *));
45 static boolean do_as_repeat PARAMS ((bfd *, asection *));
46 static boolean do_without_relocs PARAMS ((bfd *, asection *));
47 static boolean ieee_write_external_part PARAMS ((bfd *));
48 static boolean ieee_write_data_part PARAMS ((bfd *));
49 static boolean ieee_write_debug_part PARAMS ((bfd *));
50 static boolean ieee_write_me_part PARAMS ((bfd *));
51 static boolean ieee_write_processor PARAMS ((bfd *));
53 static boolean ieee_slurp_debug PARAMS ((bfd *));
54 static boolean ieee_slurp_section_data PARAMS ((bfd *));
56 /* Functions for writing to ieee files in the strange way that the
60 ieee_write_byte (abfd, barg)
67 if (bfd_write ((PTR) &byte, 1, 1, abfd) != 1)
73 ieee_write_2bytes (abfd, bytes)
79 buffer[0] = bytes >> 8;
80 buffer[1] = bytes & 0xff;
81 if (bfd_write ((PTR) buffer, 1, 2, abfd) != 2)
87 ieee_write_int (abfd, value)
93 if (! ieee_write_byte (abfd, (bfd_byte) value))
100 /* How many significant bytes ? */
101 /* FIXME FOR LONGER INTS */
102 if (value & 0xff000000)
104 else if (value & 0x00ff0000)
106 else if (value & 0x0000ff00)
111 if (! ieee_write_byte (abfd,
112 (bfd_byte) ((int) ieee_number_repeat_start_enum
118 if (! ieee_write_byte (abfd, (bfd_byte) (value >> 24)))
122 if (! ieee_write_byte (abfd, (bfd_byte) (value >> 16)))
126 if (! ieee_write_byte (abfd, (bfd_byte) (value >> 8)))
130 if (! ieee_write_byte (abfd, (bfd_byte) (value)))
139 ieee_write_id (abfd, id)
143 size_t length = strlen (id);
147 if (! ieee_write_byte (abfd, (bfd_byte) length))
150 else if (length < 255)
152 if (! ieee_write_byte (abfd, ieee_extension_length_1_enum)
153 || ! ieee_write_byte (abfd, (bfd_byte) length))
156 else if (length < 65535)
158 if (! ieee_write_byte (abfd, ieee_extension_length_2_enum)
159 || ! ieee_write_2bytes (abfd, (int) length))
164 (*_bfd_error_handler)
165 ("%s: string too long (%d chars, max 65535)",
166 bfd_get_filename (abfd), length);
167 bfd_set_error (bfd_error_invalid_operation);
171 if (bfd_write ((PTR) id, 1, length, abfd) != length)
176 /***************************************************************************
177 Functions for reading from ieee files in the strange way that the
181 #define this_byte(ieee) *((ieee)->input_p)
182 #define next_byte(ieee) ((ieee)->input_p++)
183 #define this_byte_and_next(ieee) (*((ieee)->input_p++))
185 static unsigned short
187 common_header_type *ieee;
189 unsigned char c1 = this_byte_and_next (ieee);
190 unsigned char c2 = this_byte_and_next (ieee);
191 return (c1 << 8) | c2;
195 bfd_get_string (ieee, string, length)
196 common_header_type *ieee;
201 for (i = 0; i < length; i++)
203 string[i] = this_byte_and_next (ieee);
209 common_header_type *ieee;
213 length = this_byte_and_next (ieee);
216 /* Simple string of length 0 to 127 */
218 else if (length == 0xde)
220 /* Length is next byte, allowing 0..255 */
221 length = this_byte_and_next (ieee);
223 else if (length == 0xdf)
225 /* Length is next two bytes, allowing 0..65535 */
226 length = this_byte_and_next (ieee);
227 length = (length * 256) + this_byte_and_next (ieee);
229 /* Buy memory and read string */
230 string = bfd_alloc (ieee->abfd, length + 1);
233 bfd_get_string (ieee, string, length);
239 ieee_write_expression (abfd, value, symbol, pcrel, index)
246 unsigned int term_count = 0;
250 if (! ieee_write_int (abfd, value))
255 if (bfd_is_com_section (symbol->section)
256 || bfd_is_und_section (symbol->section))
258 /* Def of a common symbol */
259 if (! ieee_write_byte (abfd, ieee_variable_X_enum)
260 || ! ieee_write_int (abfd, symbol->value))
264 else if (! bfd_is_abs_section (symbol->section))
266 /* Ref to defined symbol - */
268 if (symbol->flags & BSF_GLOBAL)
270 if (! ieee_write_byte (abfd, ieee_variable_I_enum)
271 || ! ieee_write_int (abfd, symbol->value))
275 else if (symbol->flags & (BSF_LOCAL | BSF_SECTION_SYM))
277 /* This is a reference to a defined local symbol. We can
278 easily do a local as a section+offset. */
279 if (! ieee_write_byte (abfd, ieee_variable_R_enum)
280 || ! ieee_write_byte (abfd,
281 (bfd_byte) (symbol->section->index
282 + IEEE_SECTION_NUMBER_BASE)))
285 if (symbol->value != 0)
287 if (! ieee_write_int (abfd, symbol->value))
294 (*_bfd_error_handler)
295 ("%s: unrecognized symbol `%s' flags 0x%x",
296 bfd_get_filename (abfd), bfd_asymbol_name (symbol),
298 bfd_set_error (bfd_error_invalid_operation);
305 /* subtract the pc from here by asking for PC of this section*/
306 if (! ieee_write_byte (abfd, ieee_variable_P_enum)
307 || ! ieee_write_byte (abfd,
308 (bfd_byte) (index + IEEE_SECTION_NUMBER_BASE))
309 || ! ieee_write_byte (abfd, ieee_function_minus_enum))
313 /* Handle the degenerate case of a 0 address. */
316 if (! ieee_write_int (abfd, 0))
320 while (term_count > 1)
322 if (! ieee_write_byte (abfd, ieee_function_plus_enum))
330 /*****************************************************************************/
333 writes any integer into the buffer supplied and always takes 5 bytes
336 ieee_write_int5 (buffer, value)
340 buffer[0] = (bfd_byte) ieee_number_repeat_4_enum;
341 buffer[1] = (value >> 24) & 0xff;
342 buffer[2] = (value >> 16) & 0xff;
343 buffer[3] = (value >> 8) & 0xff;
344 buffer[4] = (value >> 0) & 0xff;
348 ieee_write_int5_out (abfd, value)
354 ieee_write_int5 (b, value);
355 if (bfd_write ((PTR) b, 1, 5, abfd) != 5)
361 parse_int (ieee, value_ptr)
362 common_header_type *ieee;
365 int value = this_byte (ieee);
367 if (value >= 0 && value <= 127)
373 else if (value >= 0x80 && value <= 0x88)
375 unsigned int count = value & 0xf;
380 result = (result << 8) | this_byte_and_next (ieee);
391 common_header_type *ieee;
395 *ok = parse_int (ieee, &x);
400 must_parse_int (ieee)
401 common_header_type *ieee;
404 BFD_ASSERT (parse_int (ieee, &result) == true);
412 ieee_symbol_index_type symbol;
416 #if KEEPMINUSPCININST
418 #define SRC_MASK(arg) arg
419 #define PCREL_OFFSET false
423 #define SRC_MASK(arg) 0
424 #define PCREL_OFFSET true
428 static reloc_howto_type abs32_howto =
435 complain_overflow_bitfield,
443 static reloc_howto_type abs16_howto =
450 complain_overflow_bitfield,
458 static reloc_howto_type abs8_howto =
465 complain_overflow_bitfield,
473 static reloc_howto_type rel32_howto =
480 complain_overflow_signed,
484 SRC_MASK (0xffffffff),
488 static reloc_howto_type rel16_howto =
495 complain_overflow_signed,
499 SRC_MASK (0x0000ffff),
503 static reloc_howto_type rel8_howto =
510 complain_overflow_signed,
514 SRC_MASK (0x000000ff),
518 static ieee_symbol_index_type NOSYMBOL = {0, 0};
521 parse_expression (ieee, value, symbol, pcrel, extra, section)
522 ieee_data_type *ieee;
524 ieee_symbol_index_type *symbol;
537 ieee_value_type stack[10];
539 /* The stack pointer always points to the next unused location */
540 #define PUSH(x,y,z) TOS.symbol=x;TOS.section=y;TOS.value=z;INC;
541 #define POP(x,y,z) DEC;x=TOS.symbol;y=TOS.section;z=TOS.value;
542 ieee_value_type *sp = stack;
546 switch (this_byte (&(ieee->h)))
548 case ieee_variable_P_enum:
549 /* P variable, current program counter for section n */
552 next_byte (&(ieee->h));
554 section_n = must_parse_int (&(ieee->h));
555 PUSH (NOSYMBOL, bfd_abs_section_ptr, 0);
558 case ieee_variable_L_enum:
559 /* L variable address of section N */
560 next_byte (&(ieee->h));
561 PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
563 case ieee_variable_R_enum:
564 /* R variable, logical address of section module */
565 /* FIXME, this should be different to L */
566 next_byte (&(ieee->h));
567 PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
569 case ieee_variable_S_enum:
570 /* S variable, size in MAUS of section module */
571 next_byte (&(ieee->h));
574 ieee->section_table[must_parse_int (&(ieee->h))]->_raw_size);
576 case ieee_variable_I_enum:
577 /* Push the address of variable n */
579 ieee_symbol_index_type sy;
580 next_byte (&(ieee->h));
581 sy.index = (int) must_parse_int (&(ieee->h));
584 PUSH (sy, bfd_abs_section_ptr, 0);
587 case ieee_variable_X_enum:
588 /* Push the address of external variable n */
590 ieee_symbol_index_type sy;
591 next_byte (&(ieee->h));
592 sy.index = (int) (must_parse_int (&(ieee->h)));
595 PUSH (sy, bfd_und_section_ptr, 0);
598 case ieee_function_minus_enum:
600 bfd_vma value1, value2;
601 asection *section1, *section_dummy;
602 ieee_symbol_index_type sy;
603 next_byte (&(ieee->h));
605 POP (sy, section1, value1);
606 POP (sy, section_dummy, value2);
607 PUSH (sy, section1 ? section1 : section_dummy, value2 - value1);
610 case ieee_function_plus_enum:
612 bfd_vma value1, value2;
615 ieee_symbol_index_type sy1;
616 ieee_symbol_index_type sy2;
617 next_byte (&(ieee->h));
619 POP (sy1, section1, value1);
620 POP (sy2, section2, value2);
621 PUSH (sy1.letter ? sy1 : sy2,
622 bfd_is_abs_section (section1) ? section2 : section1,
629 BFD_ASSERT (this_byte (&(ieee->h)) < (int) ieee_variable_A_enum
630 || this_byte (&(ieee->h)) > (int) ieee_variable_Z_enum);
631 if (parse_int (&(ieee->h), &va))
633 PUSH (NOSYMBOL, bfd_abs_section_ptr, va);
638 Thats all that we can understand. As far as I can see
639 there is a bug in the Microtec IEEE output which I'm
640 using to scan, whereby the comma operator is omitted
641 sometimes in an expression, giving expressions with too
642 many terms. We can tell if that's the case by ensuring
643 that sp == stack here. If not, then we've pushed
644 something too far, so we keep adding. */
646 while (sp != stack + 1)
649 ieee_symbol_index_type sy1;
650 POP (sy1, section1, *extra);
655 POP (*symbol, dummy, *value);
668 #define ieee_seek(abfd, offset) \
669 IEEE_DATA(abfd)->h.input_p = IEEE_DATA(abfd)->h.first_byte + offset
671 #define ieee_pos(abfd) \
672 (IEEE_DATA(abfd)->h.input_p - IEEE_DATA(abfd)->h.first_byte)
674 static unsigned int last_index;
675 static char last_type; /* is the index for an X or a D */
677 static ieee_symbol_type *
687 ieee_data_type *ieee;
688 ieee_symbol_type *last_symbol;
689 unsigned int *symbol_count;
690 ieee_symbol_type ***pptr;
691 unsigned int *max_index;
695 /* Need a new symbol */
696 unsigned int new_index = must_parse_int (&(ieee->h));
697 if (new_index != last_index || this_type != last_type)
699 ieee_symbol_type *new_symbol = (ieee_symbol_type *) bfd_alloc (ieee->h.abfd,
700 sizeof (ieee_symbol_type));
704 new_symbol->index = new_index;
705 last_index = new_index;
708 *pptr = &new_symbol->next;
709 if (new_index > *max_index)
711 *max_index = new_index;
713 last_type = this_type;
714 new_symbol->symbol.section = bfd_abs_section_ptr;
721 ieee_slurp_external_symbols (abfd)
724 ieee_data_type *ieee = IEEE_DATA (abfd);
725 file_ptr offset = ieee->w.r.external_part;
727 ieee_symbol_type **prev_symbols_ptr = &ieee->external_symbols;
728 ieee_symbol_type **prev_reference_ptr = &ieee->external_reference;
729 ieee_symbol_type *symbol = (ieee_symbol_type *) NULL;
730 unsigned int symbol_count = 0;
732 last_index = 0xffffff;
733 ieee->symbol_table_full = true;
735 ieee_seek (abfd, offset);
739 switch (this_byte (&(ieee->h)))
742 next_byte (&(ieee->h));
744 symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
746 &ieee->external_symbol_max_index, 'I');
750 symbol->symbol.the_bfd = abfd;
751 symbol->symbol.name = read_id (&(ieee->h));
752 symbol->symbol.udata.p = (PTR) NULL;
753 symbol->symbol.flags = BSF_NO_FLAGS;
755 case ieee_external_symbol_enum:
756 next_byte (&(ieee->h));
758 symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
760 &ieee->external_symbol_max_index, 'D');
764 BFD_ASSERT (symbol->index >= ieee->external_symbol_min_index);
766 symbol->symbol.the_bfd = abfd;
767 symbol->symbol.name = read_id (&(ieee->h));
768 symbol->symbol.udata.p = (PTR) NULL;
769 symbol->symbol.flags = BSF_NO_FLAGS;
771 case ieee_attribute_record_enum >> 8:
773 unsigned int symbol_name_index;
774 unsigned int symbol_type_index;
775 unsigned int symbol_attribute_def;
777 switch (read_2bytes (ieee))
779 case ieee_attribute_record_enum:
780 symbol_name_index = must_parse_int (&(ieee->h));
781 symbol_type_index = must_parse_int (&(ieee->h));
782 symbol_attribute_def = must_parse_int (&(ieee->h));
783 switch (symbol_attribute_def)
787 parse_int (&ieee->h, &value);
790 (*_bfd_error_handler)
791 ("%s: unimplemented ATI record %u for symbol %u",
792 bfd_get_filename (abfd), symbol_attribute_def,
794 bfd_set_error (bfd_error_bad_value);
799 case ieee_external_reference_info_record_enum:
800 /* Skip over ATX record. */
801 parse_int (&(ieee->h), &value);
802 parse_int (&(ieee->h), &value);
803 parse_int (&(ieee->h), &value);
804 parse_int (&(ieee->h), &value);
809 case ieee_value_record_enum >> 8:
811 unsigned int symbol_name_index;
812 ieee_symbol_index_type symbol_ignore;
813 boolean pcrel_ignore;
815 next_byte (&(ieee->h));
816 next_byte (&(ieee->h));
818 symbol_name_index = must_parse_int (&(ieee->h));
819 parse_expression (ieee,
820 &symbol->symbol.value,
824 &symbol->symbol.section);
826 symbol->symbol.flags = BSF_GLOBAL | BSF_EXPORT;
830 case ieee_weak_external_reference_enum:
834 next_byte (&(ieee->h));
835 /* Throw away the external reference index */
836 (void) must_parse_int (&(ieee->h));
837 /* Fetch the default size if not resolved */
838 size = must_parse_int (&(ieee->h));
839 /* Fetch the defautlt value if available */
840 if (parse_int (&(ieee->h), &value) == false)
844 /* This turns into a common */
845 symbol->symbol.section = bfd_com_section_ptr;
846 symbol->symbol.value = size;
850 case ieee_external_reference_enum:
851 next_byte (&(ieee->h));
853 symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
855 &ieee->external_reference_max_index, 'X');
859 symbol->symbol.the_bfd = abfd;
860 symbol->symbol.name = read_id (&(ieee->h));
861 symbol->symbol.udata.p = (PTR) NULL;
862 symbol->symbol.section = bfd_und_section_ptr;
863 symbol->symbol.value = (bfd_vma) 0;
864 symbol->symbol.flags = 0;
866 BFD_ASSERT (symbol->index >= ieee->external_reference_min_index);
874 if (ieee->external_symbol_max_index != 0)
876 ieee->external_symbol_count =
877 ieee->external_symbol_max_index -
878 ieee->external_symbol_min_index + 1;
882 ieee->external_symbol_count = 0;
885 if (ieee->external_reference_max_index != 0)
887 ieee->external_reference_count =
888 ieee->external_reference_max_index -
889 ieee->external_reference_min_index + 1;
893 ieee->external_reference_count = 0;
897 ieee->external_reference_count + ieee->external_symbol_count;
899 if (symbol_count != abfd->symcount)
901 /* There are gaps in the table -- */
902 ieee->symbol_table_full = false;
905 *prev_symbols_ptr = (ieee_symbol_type *) NULL;
906 *prev_reference_ptr = (ieee_symbol_type *) NULL;
912 ieee_slurp_symbol_table (abfd)
915 if (IEEE_DATA (abfd)->read_symbols == false)
917 if (! ieee_slurp_external_symbols (abfd))
919 IEEE_DATA (abfd)->read_symbols = true;
925 ieee_get_symtab_upper_bound (abfd)
928 if (! ieee_slurp_symbol_table (abfd))
931 return (abfd->symcount != 0) ?
932 (abfd->symcount + 1) * (sizeof (ieee_symbol_type *)) : 0;
936 Move from our internal lists to the canon table, and insert in
940 extern const bfd_target ieee_vec;
943 ieee_get_symtab (abfd, location)
947 ieee_symbol_type *symp;
948 static bfd dummy_bfd;
949 static asymbol empty_symbol =
950 /* the_bfd, name, value, attr, section */
951 {&dummy_bfd, " ieee empty", (symvalue) 0, BSF_DEBUGGING, bfd_abs_section_ptr};
955 ieee_data_type *ieee = IEEE_DATA (abfd);
956 dummy_bfd.xvec = &ieee_vec;
957 if (! ieee_slurp_symbol_table (abfd))
960 if (ieee->symbol_table_full == false)
962 /* Arrgh - there are gaps in the table, run through and fill them */
963 /* up with pointers to a null place */
965 for (i = 0; i < abfd->symcount; i++)
967 location[i] = &empty_symbol;
971 ieee->external_symbol_base_offset = -ieee->external_symbol_min_index;
972 for (symp = IEEE_DATA (abfd)->external_symbols;
973 symp != (ieee_symbol_type *) NULL;
976 /* Place into table at correct index locations */
977 location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;
980 /* The external refs are indexed in a bit */
981 ieee->external_reference_base_offset =
982 -ieee->external_reference_min_index + ieee->external_symbol_count;
984 for (symp = IEEE_DATA (abfd)->external_reference;
985 symp != (ieee_symbol_type *) NULL;
988 location[symp->index + ieee->external_reference_base_offset] =
995 location[abfd->symcount] = (asymbol *) NULL;
997 return abfd->symcount;
1001 get_section_entry (abfd, ieee, index)
1003 ieee_data_type *ieee;
1006 if (index >= ieee->section_table_size)
1011 c = ieee->section_table_size;
1018 bfd_realloc (ieee->section_table, c * sizeof (asection *)));
1022 for (i = ieee->section_table_size; i < c; i++)
1025 ieee->section_table = n;
1026 ieee->section_table_size = c;
1029 if (ieee->section_table[index] == (asection *) NULL)
1031 char *tmp = bfd_alloc (abfd, 11);
1036 sprintf (tmp, " fsec%4d", index);
1037 section = bfd_make_section (abfd, tmp);
1038 ieee->section_table[index] = section;
1039 section->flags = SEC_NO_FLAGS;
1040 section->target_index = index;
1041 ieee->section_table[index] = section;
1043 return ieee->section_table[index];
1047 ieee_slurp_sections (abfd)
1050 ieee_data_type *ieee = IEEE_DATA (abfd);
1051 file_ptr offset = ieee->w.r.section_part;
1052 asection *section = (asection *) NULL;
1057 bfd_byte section_type[3];
1058 ieee_seek (abfd, offset);
1061 switch (this_byte (&(ieee->h)))
1063 case ieee_section_type_enum:
1065 unsigned int section_index;
1066 next_byte (&(ieee->h));
1067 section_index = must_parse_int (&(ieee->h));
1069 section = get_section_entry (abfd, ieee, section_index);
1071 section_type[0] = this_byte_and_next (&(ieee->h));
1073 /* Set minimal section attributes. Attributes are
1074 extended later, based on section contents. */
1076 switch (section_type[0])
1079 /* Normal attributes for absolute sections */
1080 section_type[1] = this_byte (&(ieee->h));
1081 section->flags = SEC_ALLOC;
1082 switch (section_type[1])
1084 case 0xD3: /* AS Absolute section attributes */
1085 next_byte (&(ieee->h));
1086 section_type[2] = this_byte (&(ieee->h));
1087 switch (section_type[2])
1091 next_byte (&(ieee->h));
1092 section->flags |= SEC_CODE;
1096 next_byte (&(ieee->h));
1097 section->flags |= SEC_DATA;
1100 next_byte (&(ieee->h));
1101 /* Normal rom data */
1102 section->flags |= SEC_ROM | SEC_DATA;
1109 case 0xC3: /* Named relocatable sections (type C) */
1110 section_type[1] = this_byte (&(ieee->h));
1111 section->flags = SEC_ALLOC;
1112 switch (section_type[1])
1114 case 0xD0: /* Normal code (CP) */
1115 next_byte (&(ieee->h));
1116 section->flags |= SEC_CODE;
1118 case 0xC4: /* Normal data (CD) */
1119 next_byte (&(ieee->h));
1120 section->flags |= SEC_DATA;
1122 case 0xD2: /* Normal rom data (CR) */
1123 next_byte (&(ieee->h));
1124 section->flags |= SEC_ROM | SEC_DATA;
1131 /* Read section name, use it if non empty. */
1132 name = read_id (&ieee->h);
1134 section->name = name;
1136 /* Skip these fields, which we don't care about */
1138 bfd_vma parent, brother, context;
1139 parse_int (&(ieee->h), &parent);
1140 parse_int (&(ieee->h), &brother);
1141 parse_int (&(ieee->h), &context);
1145 case ieee_section_alignment_enum:
1147 unsigned int section_index;
1150 next_byte (&(ieee->h));
1151 section_index = must_parse_int (&ieee->h);
1152 section = get_section_entry (abfd, ieee, section_index);
1153 if (section_index > ieee->section_count)
1155 ieee->section_count = section_index;
1157 section->alignment_power =
1158 bfd_log2 (must_parse_int (&ieee->h));
1159 (void) parse_int (&(ieee->h), &value);
1162 case ieee_e2_first_byte_enum:
1164 ieee_record_enum_type t = (ieee_record_enum_type) (read_2bytes (&(ieee->h)));
1168 case ieee_section_size_enum:
1169 section = ieee->section_table[must_parse_int (&(ieee->h))];
1170 section->_raw_size = must_parse_int (&(ieee->h));
1172 case ieee_physical_region_size_enum:
1173 section = ieee->section_table[must_parse_int (&(ieee->h))];
1174 section->_raw_size = must_parse_int (&(ieee->h));
1176 case ieee_region_base_address_enum:
1177 section = ieee->section_table[must_parse_int (&(ieee->h))];
1178 section->vma = must_parse_int (&(ieee->h));
1179 section->lma = section->vma;
1181 case ieee_mau_size_enum:
1182 must_parse_int (&(ieee->h));
1183 must_parse_int (&(ieee->h));
1185 case ieee_m_value_enum:
1186 must_parse_int (&(ieee->h));
1187 must_parse_int (&(ieee->h));
1189 case ieee_section_base_address_enum:
1190 section = ieee->section_table[must_parse_int (&(ieee->h))];
1191 section->vma = must_parse_int (&(ieee->h));
1192 section->lma = section->vma;
1194 case ieee_section_offset_enum:
1195 (void) must_parse_int (&(ieee->h));
1196 (void) must_parse_int (&(ieee->h));
1210 /* Make a section for the debugging information, if any. We don't try
1211 to interpret the debugging information; we just point the section
1212 at the area in the file so that program which understand can dig it
1216 ieee_slurp_debug (abfd)
1219 ieee_data_type *ieee = IEEE_DATA (abfd);
1222 if (ieee->w.r.debug_information_part == 0)
1225 sec = bfd_make_section (abfd, ".debug");
1228 sec->flags |= SEC_DEBUGGING | SEC_HAS_CONTENTS;
1229 sec->filepos = ieee->w.r.debug_information_part;
1230 sec->_raw_size = ieee->w.r.data_part - ieee->w.r.debug_information_part;
1235 /***********************************************************************
1240 ieee_archive_p (abfd)
1245 unsigned char buffer[512];
1246 file_ptr buffer_offset = 0;
1247 ieee_ar_data_type *save = abfd->tdata.ieee_ar_data;
1248 ieee_ar_data_type *ieee;
1249 unsigned int alc_elts;
1250 ieee_ar_obstack_type *elts = NULL;
1252 abfd->tdata.ieee_ar_data =
1253 (ieee_ar_data_type *) bfd_alloc (abfd, sizeof (ieee_ar_data_type));
1254 if (!abfd->tdata.ieee_ar_data)
1256 ieee = IEEE_AR_DATA (abfd);
1258 /* FIXME: Check return value. I'm not sure whether it needs to read
1259 the entire buffer or not. */
1260 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
1262 ieee->h.first_byte = buffer;
1263 ieee->h.input_p = buffer;
1265 ieee->h.abfd = abfd;
1267 if (this_byte (&(ieee->h)) != Module_Beginning)
1269 abfd->tdata.ieee_ar_data = save;
1273 next_byte (&(ieee->h));
1274 library = read_id (&(ieee->h));
1275 if (strcmp (library, "LIBRARY") != 0)
1277 bfd_release (abfd, ieee);
1278 abfd->tdata.ieee_ar_data = save;
1281 /* Throw away the filename */
1282 read_id (&(ieee->h));
1284 ieee->element_count = 0;
1285 ieee->element_index = 0;
1287 next_byte (&(ieee->h)); /* Drop the ad part */
1288 must_parse_int (&(ieee->h)); /* And the two dummy numbers */
1289 must_parse_int (&(ieee->h));
1292 elts = (ieee_ar_obstack_type *) bfd_malloc (alc_elts * sizeof *elts);
1296 /* Read the index of the BB table */
1300 ieee_ar_obstack_type *t;
1302 rec = read_2bytes (&(ieee->h));
1303 if (rec != (int) ieee_assign_value_to_variable_enum)
1306 if (ieee->element_count >= alc_elts)
1308 ieee_ar_obstack_type *n;
1311 n = ((ieee_ar_obstack_type *)
1312 bfd_realloc (elts, alc_elts * sizeof *elts));
1318 t = &elts[ieee->element_count];
1319 ieee->element_count++;
1321 must_parse_int (&(ieee->h));
1322 t->file_offset = must_parse_int (&(ieee->h));
1323 t->abfd = (bfd *) NULL;
1325 /* Make sure that we don't go over the end of the buffer */
1327 if ((size_t) ieee_pos (abfd) > sizeof (buffer) / 2)
1329 /* Past half way, reseek and reprime */
1330 buffer_offset += ieee_pos (abfd);
1331 if (bfd_seek (abfd, buffer_offset, SEEK_SET) != 0)
1333 /* FIXME: Check return value. I'm not sure whether it needs
1334 to read the entire buffer or not. */
1335 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
1336 ieee->h.first_byte = buffer;
1337 ieee->h.input_p = buffer;
1341 ieee->elements = ((ieee_ar_obstack_type *)
1343 ieee->element_count * sizeof *ieee->elements));
1344 if (ieee->elements == NULL)
1346 memcpy (ieee->elements, elts,
1347 ieee->element_count * sizeof *ieee->elements);
1351 /* Now scan the area again, and replace BB offsets with file */
1354 for (i = 2; i < ieee->element_count; i++)
1356 if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0)
1358 /* FIXME: Check return value. I'm not sure whether it needs to
1359 read the entire buffer or not. */
1360 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
1361 ieee->h.first_byte = buffer;
1362 ieee->h.input_p = buffer;
1364 next_byte (&(ieee->h)); /* Drop F8 */
1365 next_byte (&(ieee->h)); /* Drop 14 */
1366 must_parse_int (&(ieee->h)); /* Drop size of block */
1367 if (must_parse_int (&(ieee->h)) != 0)
1369 /* This object has been deleted */
1370 ieee->elements[i].file_offset = 0;
1374 ieee->elements[i].file_offset = must_parse_int (&(ieee->h));
1378 /* abfd->has_armap = ;*/
1389 ieee_mkobject (abfd)
1392 abfd->tdata.ieee_data = (ieee_data_type *) bfd_zalloc (abfd, sizeof (ieee_data_type));
1393 return abfd->tdata.ieee_data ? true : false;
1397 ieee_object_p (abfd)
1402 ieee_data_type *ieee;
1403 unsigned char buffer[300];
1404 ieee_data_type *save = IEEE_DATA (abfd);
1406 abfd->tdata.ieee_data = 0;
1407 ieee_mkobject (abfd);
1409 ieee = IEEE_DATA (abfd);
1410 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
1412 /* Read the first few bytes in to see if it makes sense */
1413 /* FIXME: Check return value. I'm not sure whether it needs to read
1414 the entire buffer or not. */
1415 bfd_read ((PTR) buffer, 1, sizeof (buffer), abfd);
1417 ieee->h.input_p = buffer;
1418 if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
1419 goto got_wrong_format;
1421 ieee->read_symbols = false;
1422 ieee->read_data = false;
1423 ieee->section_count = 0;
1424 ieee->external_symbol_max_index = 0;
1425 ieee->external_symbol_min_index = IEEE_PUBLIC_BASE;
1426 ieee->external_reference_min_index = IEEE_REFERENCE_BASE;
1427 ieee->external_reference_max_index = 0;
1428 ieee->h.abfd = abfd;
1429 ieee->section_table = NULL;
1430 ieee->section_table_size = 0;
1432 processor = ieee->mb.processor = read_id (&(ieee->h));
1433 if (strcmp (processor, "LIBRARY") == 0)
1434 goto got_wrong_format;
1435 ieee->mb.module_name = read_id (&(ieee->h));
1436 if (abfd->filename == (CONST char *) NULL)
1438 abfd->filename = ieee->mb.module_name;
1440 /* Determine the architecture and machine type of the object file.
1443 const bfd_arch_info_type *arch = bfd_scan_arch (processor);
1445 goto got_wrong_format;
1446 abfd->arch_info = arch;
1449 if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum)
1453 next_byte (&(ieee->h));
1455 if (parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau) == false)
1459 if (parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address) == false)
1464 /* If there is a byte order info, take it */
1465 if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum ||
1466 this_byte (&(ieee->h)) == (int) ieee_variable_M_enum)
1467 next_byte (&(ieee->h));
1469 for (part = 0; part < N_W_VARIABLES; part++)
1472 if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum)
1476 if (this_byte_and_next (&(ieee->h)) != part)
1481 ieee->w.offset[part] = parse_i (&(ieee->h), &ok);
1489 if (ieee->w.r.external_part != 0)
1490 abfd->flags = HAS_SYMS;
1492 /* By now we know that this is a real IEEE file, we're going to read
1493 the whole thing into memory so that we can run up and down it
1494 quickly. We can work out how big the file is from the trailer
1497 IEEE_DATA (abfd)->h.first_byte =
1498 (unsigned char *) bfd_alloc (ieee->h.abfd, ieee->w.r.me_record + 1);
1499 if (!IEEE_DATA (abfd)->h.first_byte)
1501 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
1503 /* FIXME: Check return value. I'm not sure whether it needs to read
1504 the entire buffer or not. */
1505 bfd_read ((PTR) (IEEE_DATA (abfd)->h.first_byte), 1,
1506 ieee->w.r.me_record + 1, abfd);
1508 ieee_slurp_sections (abfd);
1510 if (! ieee_slurp_debug (abfd))
1513 /* Parse section data to activate file and section flags implied by
1514 section contents. */
1516 if (! ieee_slurp_section_data (abfd))
1521 bfd_set_error (bfd_error_wrong_format);
1523 (void) bfd_release (abfd, ieee);
1524 abfd->tdata.ieee_data = save;
1525 return (const bfd_target *) NULL;
1529 ieee_get_symbol_info (ignore_abfd, symbol, ret)
1534 bfd_symbol_info (symbol, ret);
1535 if (symbol->name[0] == ' ')
1536 ret->name = "* empty table entry ";
1537 if (!symbol->section)
1538 ret->type = (symbol->flags & BSF_LOCAL) ? 'a' : 'A';
1542 ieee_print_symbol (ignore_abfd, afile, symbol, how)
1546 bfd_print_symbol_type how;
1548 FILE *file = (FILE *) afile;
1552 case bfd_print_symbol_name:
1553 fprintf (file, "%s", symbol->name);
1555 case bfd_print_symbol_more:
1557 fprintf (file, "%4x %2x", aout_symbol (symbol)->desc & 0xffff,
1558 aout_symbol (symbol)->other & 0xff);
1562 case bfd_print_symbol_all:
1564 const char *section_name =
1565 (symbol->section == (asection *) NULL
1567 : symbol->section->name);
1568 if (symbol->name[0] == ' ')
1570 fprintf (file, "* empty table entry ");
1574 bfd_print_symbol_vandf ((PTR) file, symbol);
1576 fprintf (file, " %-5s %04x %02x %s",
1578 (unsigned) ieee_symbol (symbol)->index,
1588 do_one (ieee, current_map, location_ptr, s, iterations)
1589 ieee_data_type *ieee;
1590 ieee_per_section_type *current_map;
1591 unsigned char *location_ptr;
1595 switch (this_byte (&(ieee->h)))
1597 case ieee_load_constant_bytes_enum:
1599 unsigned int number_of_maus;
1601 next_byte (&(ieee->h));
1602 number_of_maus = must_parse_int (&(ieee->h));
1604 for (i = 0; i < number_of_maus; i++)
1606 location_ptr[current_map->pc++] = this_byte (&(ieee->h));
1607 next_byte (&(ieee->h));
1612 case ieee_load_with_relocation_enum:
1614 boolean loop = true;
1615 next_byte (&(ieee->h));
1618 switch (this_byte (&(ieee->h)))
1620 case ieee_variable_R_enum:
1622 case ieee_function_signed_open_b_enum:
1623 case ieee_function_unsigned_open_b_enum:
1624 case ieee_function_either_open_b_enum:
1626 unsigned int extra = 4;
1627 boolean pcrel = false;
1629 ieee_reloc_type *r =
1630 (ieee_reloc_type *) bfd_alloc (ieee->h.abfd,
1631 sizeof (ieee_reloc_type));
1635 *(current_map->reloc_tail_ptr) = r;
1636 current_map->reloc_tail_ptr = &r->next;
1637 r->next = (ieee_reloc_type *) NULL;
1638 next_byte (&(ieee->h));
1640 r->relent.sym_ptr_ptr = 0;
1641 parse_expression (ieee,
1644 &pcrel, &extra, §ion);
1645 r->relent.address = current_map->pc;
1646 s->flags |= SEC_RELOC;
1647 s->owner->flags |= HAS_RELOC;
1649 if (r->relent.sym_ptr_ptr == NULL && section != NULL)
1650 r->relent.sym_ptr_ptr = section->symbol_ptr_ptr;
1652 if (this_byte (&(ieee->h)) == (int) ieee_comma)
1654 next_byte (&(ieee->h));
1655 /* Fetch number of bytes to pad */
1656 extra = must_parse_int (&(ieee->h));
1659 switch (this_byte (&(ieee->h)))
1661 case ieee_function_signed_close_b_enum:
1662 next_byte (&(ieee->h));
1664 case ieee_function_unsigned_close_b_enum:
1665 next_byte (&(ieee->h));
1667 case ieee_function_either_close_b_enum:
1668 next_byte (&(ieee->h));
1673 /* Build a relocation entry for this type */
1674 /* If pc rel then stick -ve pc into instruction
1675 and take out of reloc ..
1677 I've changed this. It's all too complicated. I
1678 keep 0 in the instruction now. */
1687 #if KEEPMINUSPCININST
1688 bfd_put_32 (ieee->h.abfd, -current_map->pc, location_ptr +
1690 r->relent.howto = &rel32_howto;
1694 bfd_put_32 (ieee->h.abfd, 0, location_ptr +
1696 r->relent.howto = &rel32_howto;
1701 bfd_put_32 (ieee->h.abfd, 0, location_ptr +
1703 r->relent.howto = &abs32_howto;
1705 current_map->pc += 4;
1710 #if KEEPMINUSPCININST
1711 bfd_put_16 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc);
1712 r->relent.addend -= current_map->pc;
1713 r->relent.howto = &rel16_howto;
1716 bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1717 r->relent.howto = &rel16_howto;
1723 bfd_put_16 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1724 r->relent.howto = &abs16_howto;
1726 current_map->pc += 2;
1731 #if KEEPMINUSPCININST
1732 bfd_put_8 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc);
1733 r->relent.addend -= current_map->pc;
1734 r->relent.howto = &rel8_howto;
1736 bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1737 r->relent.howto = &rel8_howto;
1742 bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1743 r->relent.howto = &abs8_howto;
1745 current_map->pc += 1;
1757 if (parse_int (&(ieee->h), &this_size) == true)
1760 for (i = 0; i < this_size; i++)
1762 location_ptr[current_map->pc++] = this_byte (&(ieee->h));
1763 next_byte (&(ieee->h));
1773 /* Prevent more than the first load-item of an LR record
1774 from being repeated (MRI convention). */
1775 if (iterations != 1)
1783 /* Read in all the section data and relocation stuff too */
1785 ieee_slurp_section_data (abfd)
1788 bfd_byte *location_ptr = (bfd_byte *) NULL;
1789 ieee_data_type *ieee = IEEE_DATA (abfd);
1790 unsigned int section_number;
1792 ieee_per_section_type *current_map = (ieee_per_section_type *) NULL;
1794 /* Seek to the start of the data area */
1795 if (ieee->read_data == true)
1797 ieee->read_data = true;
1798 ieee_seek (abfd, ieee->w.r.data_part);
1800 /* Allocate enough space for all the section contents */
1802 for (s = abfd->sections; s != (asection *) NULL; s = s->next)
1804 ieee_per_section_type *per = (ieee_per_section_type *) s->used_by_bfd;
1805 if ((s->flags & SEC_DEBUGGING) != 0)
1807 per->data = (bfd_byte *) bfd_alloc (ieee->h.abfd, s->_raw_size);
1811 per->reloc_tail_ptr =
1812 (ieee_reloc_type **) & (s->relocation);
1817 switch (this_byte (&(ieee->h)))
1819 /* IF we see anything strange then quit */
1823 case ieee_set_current_section_enum:
1824 next_byte (&(ieee->h));
1825 section_number = must_parse_int (&(ieee->h));
1826 s = ieee->section_table[section_number];
1827 s->flags |= SEC_LOAD | SEC_HAS_CONTENTS;
1828 current_map = (ieee_per_section_type *) s->used_by_bfd;
1829 location_ptr = current_map->data - s->vma;
1830 /* The document I have says that Microtec's compilers reset */
1831 /* this after a sec section, even though the standard says not */
1833 current_map->pc = s->vma;
1836 case ieee_e2_first_byte_enum:
1837 next_byte (&(ieee->h));
1838 switch (this_byte (&(ieee->h)))
1840 case ieee_set_current_pc_enum & 0xff:
1843 ieee_symbol_index_type symbol;
1846 next_byte (&(ieee->h));
1847 must_parse_int (&(ieee->h)); /* Thow away section #*/
1848 parse_expression (ieee, &value,
1852 current_map->pc = value;
1853 BFD_ASSERT ((unsigned) (value - s->vma) <= s->_raw_size);
1857 case ieee_value_starting_address_enum & 0xff:
1858 next_byte (&(ieee->h));
1859 if (this_byte (&(ieee->h)) == ieee_function_either_open_b_enum)
1860 next_byte (&(ieee->h));
1861 abfd->start_address = must_parse_int (&(ieee->h));
1862 /* We've got to the end of the data now - */
1869 case ieee_repeat_data_enum:
1871 /* Repeat the following LD or LR n times - we do this by
1872 remembering the stream pointer before running it and
1873 resetting it and running it n times. We special case
1874 the repetition of a repeat_data/load_constant
1877 unsigned int iterations;
1878 unsigned char *start;
1879 next_byte (&(ieee->h));
1880 iterations = must_parse_int (&(ieee->h));
1881 start = ieee->h.input_p;
1882 if (start[0] == (int) ieee_load_constant_bytes_enum &&
1885 while (iterations != 0)
1887 location_ptr[current_map->pc++] = start[2];
1890 next_byte (&(ieee->h));
1891 next_byte (&(ieee->h));
1892 next_byte (&(ieee->h));
1896 while (iterations != 0)
1898 ieee->h.input_p = start;
1899 if (!do_one (ieee, current_map, location_ptr, s,
1907 case ieee_load_constant_bytes_enum:
1908 case ieee_load_with_relocation_enum:
1910 if (!do_one (ieee, current_map, location_ptr, s, 1))
1918 ieee_new_section_hook (abfd, newsect)
1922 newsect->used_by_bfd = (PTR)
1923 bfd_alloc (abfd, sizeof (ieee_per_section_type));
1924 if (!newsect->used_by_bfd)
1926 ieee_per_section (newsect)->data = (bfd_byte *) NULL;
1927 ieee_per_section (newsect)->section = newsect;
1932 ieee_get_reloc_upper_bound (abfd, asect)
1936 if ((asect->flags & SEC_DEBUGGING) != 0)
1938 if (! ieee_slurp_section_data (abfd))
1940 return (asect->reloc_count + 1) * sizeof (arelent *);
1944 ieee_get_section_contents (abfd, section, location, offset, count)
1949 bfd_size_type count;
1951 ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;
1952 if ((section->flags & SEC_DEBUGGING) != 0)
1953 return _bfd_generic_get_section_contents (abfd, section, location,
1955 ieee_slurp_section_data (abfd);
1956 (void) memcpy ((PTR) location, (PTR) (p->data + offset), (unsigned) count);
1961 ieee_canonicalize_reloc (abfd, section, relptr, symbols)
1967 /* ieee_per_section_type *p = (ieee_per_section_type *) section->used_by_bfd;*/
1968 ieee_reloc_type *src = (ieee_reloc_type *) (section->relocation);
1969 ieee_data_type *ieee = IEEE_DATA (abfd);
1971 if ((section->flags & SEC_DEBUGGING) != 0)
1974 while (src != (ieee_reloc_type *) NULL)
1976 /* Work out which symbol to attach it this reloc to */
1977 switch (src->symbol.letter)
1980 src->relent.sym_ptr_ptr =
1981 symbols + src->symbol.index + ieee->external_symbol_base_offset;
1984 src->relent.sym_ptr_ptr =
1985 symbols + src->symbol.index + ieee->external_reference_base_offset;
1988 if (src->relent.sym_ptr_ptr != NULL)
1989 src->relent.sym_ptr_ptr =
1990 src->relent.sym_ptr_ptr[0]->section->symbol_ptr_ptr;
1996 *relptr++ = &src->relent;
1999 *relptr = (arelent *) NULL;
2000 return section->reloc_count;
2008 arelent *a = *((arelent **) ap);
2009 arelent *b = *((arelent **) bp);
2010 return a->address - b->address;
2013 /* Write the section headers. */
2016 ieee_write_section_part (abfd)
2019 ieee_data_type *ieee = IEEE_DATA (abfd);
2021 ieee->w.r.section_part = bfd_tell (abfd);
2022 for (s = abfd->sections; s != (asection *) NULL; s = s->next)
2024 if (! bfd_is_abs_section (s)
2025 && (s->flags & SEC_DEBUGGING) == 0)
2027 if (! ieee_write_byte (abfd, ieee_section_type_enum)
2028 || ! ieee_write_byte (abfd,
2029 (bfd_byte) (s->index
2030 + IEEE_SECTION_NUMBER_BASE)))
2033 if (abfd->flags & EXEC_P)
2035 /* This image is executable, so output absolute sections */
2036 if (! ieee_write_byte (abfd, ieee_variable_A_enum)
2037 || ! ieee_write_byte (abfd, ieee_variable_S_enum))
2042 if (! ieee_write_byte (abfd, ieee_variable_C_enum))
2046 switch (s->flags & (SEC_CODE | SEC_DATA | SEC_ROM))
2048 case SEC_CODE | SEC_LOAD:
2050 if (! ieee_write_byte (abfd, ieee_variable_P_enum))
2055 if (! ieee_write_byte (abfd, ieee_variable_D_enum))
2059 case SEC_ROM | SEC_DATA:
2060 case SEC_ROM | SEC_LOAD:
2061 case SEC_ROM | SEC_DATA | SEC_LOAD:
2062 if (! ieee_write_byte (abfd, ieee_variable_R_enum))
2067 if (! ieee_write_id (abfd, s->name))
2070 ieee_write_int (abfd, 0); /* Parent */
2071 ieee_write_int (abfd, 0); /* Brother */
2072 ieee_write_int (abfd, 0); /* Context */
2075 if (! ieee_write_byte (abfd, ieee_section_alignment_enum)
2076 || ! ieee_write_byte (abfd,
2077 (bfd_byte) (s->index
2078 + IEEE_SECTION_NUMBER_BASE))
2079 || ! ieee_write_int (abfd, 1 << s->alignment_power))
2083 if (! ieee_write_2bytes (abfd, ieee_section_size_enum)
2084 || ! ieee_write_byte (abfd,
2085 (bfd_byte) (s->index
2086 + IEEE_SECTION_NUMBER_BASE))
2087 || ! ieee_write_int (abfd, s->_raw_size))
2089 if (abfd->flags & EXEC_P)
2091 /* Relocateable sections don't have asl records */
2093 if (! ieee_write_2bytes (abfd, ieee_section_base_address_enum)
2094 || ! ieee_write_byte (abfd,
2097 + IEEE_SECTION_NUMBER_BASE)))
2098 || ! ieee_write_int (abfd, s->lma))
2109 do_with_relocs (abfd, s)
2113 unsigned int number_of_maus_in_address =
2114 bfd_arch_bits_per_address (abfd) / bfd_arch_bits_per_byte (abfd);
2115 unsigned int relocs_to_go = s->reloc_count;
2116 bfd_byte *stream = ieee_per_section (s)->data;
2117 arelent **p = s->orelocation;
2118 bfd_size_type current_byte_index = 0;
2120 qsort (s->orelocation,
2122 sizeof (arelent **),
2125 /* Output the section preheader */
2126 if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
2127 || ! ieee_write_byte (abfd,
2128 (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE))
2129 || ! ieee_write_2bytes (abfd, ieee_set_current_pc_enum)
2130 || ! ieee_write_byte (abfd,
2131 (bfd_byte) (s->index + IEEE_SECTION_NUMBER_BASE)))
2133 if ((abfd->flags & EXEC_P) != 0 && relocs_to_go == 0)
2135 if (! ieee_write_int (abfd, s->lma))
2140 if (! ieee_write_expression (abfd, 0, s->symbol, 0, 0))
2144 if (relocs_to_go == 0)
2146 /* If there aren't any relocations then output the load constant
2147 byte opcode rather than the load with relocation opcode */
2149 while (current_byte_index < s->_raw_size)
2152 unsigned int MAXRUN = 127;
2154 if (run > s->_raw_size - current_byte_index)
2156 run = s->_raw_size - current_byte_index;
2161 if (! ieee_write_byte (abfd, ieee_load_constant_bytes_enum))
2163 /* Output a stream of bytes */
2164 if (! ieee_write_int (abfd, run))
2166 if (bfd_write ((PTR) (stream + current_byte_index),
2172 current_byte_index += run;
2178 if (! ieee_write_byte (abfd, ieee_load_with_relocation_enum))
2181 /* Output the data stream as the longest sequence of bytes
2182 possible, allowing for the a reasonable packet size and
2183 relocation stuffs. */
2185 if ((PTR) stream == (PTR) NULL)
2187 /* Outputting a section without data, fill it up */
2188 stream = (unsigned char *) (bfd_alloc (abfd, s->_raw_size));
2191 memset ((PTR) stream, 0, (size_t) s->_raw_size);
2193 while (current_byte_index < s->_raw_size)
2196 unsigned int MAXRUN = 127;
2199 run = (*p)->address - current_byte_index;
2207 if (run > s->_raw_size - current_byte_index)
2209 run = s->_raw_size - current_byte_index;
2214 /* Output a stream of bytes */
2215 if (! ieee_write_int (abfd, run))
2217 if (bfd_write ((PTR) (stream + current_byte_index),
2223 current_byte_index += run;
2225 /* Output any relocations here */
2226 if (relocs_to_go && (*p) && (*p)->address == current_byte_index)
2229 && (*p) && (*p)->address == current_byte_index)
2235 if (r->howto->pc_relative)
2237 r->addend += current_byte_index;
2241 switch (r->howto->size)
2245 ov = bfd_get_signed_32 (abfd,
2246 stream + current_byte_index);
2247 current_byte_index += 4;
2250 ov = bfd_get_signed_16 (abfd,
2251 stream + current_byte_index);
2252 current_byte_index += 2;
2255 ov = bfd_get_signed_8 (abfd,
2256 stream + current_byte_index);
2257 current_byte_index++;
2265 ov &= r->howto->src_mask;
2267 if (r->howto->pc_relative
2268 && ! r->howto->pcrel_offset)
2271 if (! ieee_write_byte (abfd,
2272 ieee_function_either_open_b_enum))
2277 if (r->sym_ptr_ptr != (asymbol **) NULL)
2279 if (! ieee_write_expression (abfd, r->addend + ov,
2281 r->howto->pc_relative,
2287 if (! ieee_write_expression (abfd, r->addend + ov,
2289 r->howto->pc_relative,
2294 if (number_of_maus_in_address
2295 != bfd_get_reloc_size (r->howto))
2297 if (! ieee_write_int (abfd,
2298 bfd_get_reloc_size (r->howto)))
2301 if (! ieee_write_byte (abfd,
2302 ieee_function_either_close_b_enum))
2316 /* If there are no relocations in the output section then we can be
2317 clever about how we write. We block items up into a max of 127
2321 do_as_repeat (abfd, s)
2327 if (! ieee_write_byte (abfd, ieee_set_current_section_enum)
2328 || ! ieee_write_byte (abfd,
2329 (bfd_byte) (s->index
2330 + IEEE_SECTION_NUMBER_BASE))
2331 || ! ieee_write_byte (abfd, ieee_set_current_pc_enum >> 8)
2332 || ! ieee_write_byte (abfd, ieee_set_current_pc_enum & 0xff)
2333 || ! ieee_write_byte (abfd,
2334 (bfd_byte) (s->index
2335 + IEEE_SECTION_NUMBER_BASE))
2336 || ! ieee_write_int (abfd, s->lma)
2337 || ! ieee_write_byte (abfd, ieee_repeat_data_enum)
2338 || ! ieee_write_int (abfd, s->_raw_size)
2339 || ! ieee_write_byte (abfd, ieee_load_constant_bytes_enum)
2340 || ! ieee_write_byte (abfd, 1)
2341 || ! ieee_write_byte (abfd, 0))
2349 do_without_relocs (abfd, s)
2353 bfd_byte *stream = ieee_per_section (s)->data;
2355 if (stream == 0 || ((s->flags & SEC_LOAD) == 0))
2357 if (! do_as_repeat (abfd, s))
2363 for (i = 0; i < s->_raw_size; i++)
2367 if (! do_with_relocs (abfd, s))
2372 if (! do_as_repeat (abfd, s))
2380 static unsigned char *output_ptr_start;
2381 static unsigned char *output_ptr;
2382 static unsigned char *output_ptr_end;
2383 static unsigned char *input_ptr_start;
2384 static unsigned char *input_ptr;
2385 static unsigned char *input_ptr_end;
2386 static bfd *input_bfd;
2387 static bfd *output_bfd;
2388 static int output_buffer;
2393 /* FIXME: Check return value. I'm not sure whether it needs to read
2394 the entire buffer or not. */
2395 bfd_read ((PTR) input_ptr_start, 1, input_ptr_end - input_ptr_start, input_bfd);
2396 input_ptr = input_ptr_start;
2401 if (bfd_write ((PTR) (output_ptr_start), 1, output_ptr - output_ptr_start,
2403 != (bfd_size_type) (output_ptr - output_ptr_start))
2405 output_ptr = output_ptr_start;
2409 #define THIS() ( *input_ptr )
2410 #define NEXT() { input_ptr++; if (input_ptr == input_ptr_end) fill(); }
2411 #define OUT(x) { *output_ptr++ = (x); if(output_ptr == output_ptr_end) flush(); }
2417 if (value >= 0 && value <= 127)
2423 unsigned int length;
2424 /* How many significant bytes ? */
2425 /* FIXME FOR LONGER INTS */
2426 if (value & 0xff000000)
2430 else if (value & 0x00ff0000)
2434 else if (value & 0x0000ff00)
2441 OUT ((int) ieee_number_repeat_start_enum + length);
2460 int length = THIS ();
2472 #define VAR(x) ((x | 0x80))
2487 value = (value << 8) | THIS ();
2489 value = (value << 8) | THIS ();
2491 value = (value << 8) | THIS ();
2499 value = (value << 8) | THIS ();
2501 value = (value << 8) | THIS ();
2509 value = (value << 8) | THIS ();
2526 /* Not a number, just bug out with the answer */
2527 write_int (*(--tos));
2537 int value = *(--tos);
2546 ieee_data_type *ieee;
2549 section_number = THIS ();
2552 ieee = IEEE_DATA (input_bfd);
2553 s = ieee->section_table[section_number];
2554 if (s->output_section)
2556 value = s->output_section->lma;
2562 value += s->output_offset;
2570 write_int (*(--tos));
2580 /* Drop the int in the buffer, and copy a null into the gap, which we
2581 will overwrite later */
2583 struct output_buffer_struct
2585 unsigned char *ptrp;
2591 struct output_buffer_struct *buf;
2593 if (buf->buffer == output_buffer)
2595 /* Still a chance to output the size */
2596 int value = output_ptr - buf->ptrp + 3;
2597 buf->ptrp[0] = value >> 24;
2598 buf->ptrp[1] = value >> 16;
2599 buf->ptrp[2] = value >> 8;
2600 buf->ptrp[3] = value >> 0;
2606 struct output_buffer_struct *buf;
2632 buf->ptrp = output_ptr;
2633 buf->buffer = output_buffer;
2673 #define ID copy_id()
2674 #define INT copy_int()
2675 #define EXP copy_expression()
2676 static void copy_till_end ();
2677 #define INTn(q) copy_int()
2678 #define EXPn(q) copy_expression()
2717 EXPn (instruction address);
2751 EXPn (external function);
2761 INTn (locked register);
2784 /* Attribute record */
2842 static void block ();
2854 /* Unique typedefs for module */
2855 /* GLobal typedefs */
2856 /* High level module scope beginning */
2858 struct output_buffer_struct ob;
2873 /* Global function */
2875 struct output_buffer_struct ob;
2889 EXPn (size of block);
2895 /* File name for source line numbers */
2897 struct output_buffer_struct ob;
2917 /* Local function */
2919 struct output_buffer_struct ob;
2937 /* Assembler module scope beginning -*/
2939 struct output_buffer_struct ob;
2965 struct output_buffer_struct ob;
2972 INTn (section index);
2980 EXPn (Size in Maus);
3035 moves all the debug information from the source bfd to the output
3036 bfd, and relocates any expressions it finds
3040 relocate_debug (output, input)
3046 unsigned char input_buffer[IBS];
3048 input_ptr_start = input_ptr = input_buffer;
3049 input_ptr_end = input_buffer + IBS;
3051 /* FIXME: Check return value. I'm not sure whether it needs to read
3052 the entire buffer or not. */
3053 bfd_read ((PTR) input_ptr_start, 1, IBS, input);
3058 During linking, we we told about the bfds which made up our
3059 contents, we have a list of them. They will still be open, so go to
3060 the debug info in each, and copy it out, relocating it as we go.
3064 ieee_write_debug_part (abfd)
3067 ieee_data_type *ieee = IEEE_DATA (abfd);
3068 bfd_chain_type *chain = ieee->chain_root;
3069 unsigned char output_buffer[OBS];
3070 boolean some_debug = false;
3071 file_ptr here = bfd_tell (abfd);
3073 output_ptr_start = output_ptr = output_buffer;
3074 output_ptr_end = output_buffer + OBS;
3075 output_ptr = output_buffer;
3078 if (chain == (bfd_chain_type *) NULL)
3082 for (s = abfd->sections; s != NULL; s = s->next)
3083 if ((s->flags & SEC_DEBUGGING) != 0)
3087 ieee->w.r.debug_information_part = 0;
3091 ieee->w.r.debug_information_part = here;
3092 if (bfd_write (s->contents, 1, s->_raw_size, abfd) != s->_raw_size)
3097 while (chain != (bfd_chain_type *) NULL)
3099 bfd *entry = chain->this;
3100 ieee_data_type *entry_ieee = IEEE_DATA (entry);
3101 if (entry_ieee->w.r.debug_information_part)
3103 if (bfd_seek (entry, entry_ieee->w.r.debug_information_part,
3107 relocate_debug (abfd, entry);
3110 chain = chain->next;
3114 ieee->w.r.debug_information_part = here;
3118 ieee->w.r.debug_information_part = 0;
3127 /* Write the data in an ieee way. */
3130 ieee_write_data_part (abfd)
3134 ieee_data_type *ieee = IEEE_DATA (abfd);
3135 ieee->w.r.data_part = bfd_tell (abfd);
3136 for (s = abfd->sections; s != (asection *) NULL; s = s->next)
3138 /* Skip sections that have no loadable contents (.bss,
3140 if ((s->flags & SEC_LOAD) == 0)
3143 /* Sort the reloc records so we can insert them in the correct
3145 if (s->reloc_count != 0)
3147 if (! do_with_relocs (abfd, s))
3152 if (! do_without_relocs (abfd, s))
3162 init_for_output (abfd)
3166 for (s = abfd->sections; s != (asection *) NULL; s = s->next)
3168 if ((s->flags & SEC_DEBUGGING) != 0)
3170 if (s->_raw_size != 0)
3172 ieee_per_section (s)->data = (bfd_byte *) (bfd_alloc (abfd, s->_raw_size));
3173 if (!ieee_per_section (s)->data)
3180 /** exec and core file sections */
3182 /* set section contents is complicated with IEEE since the format is
3183 * not a byte image, but a record stream.
3186 ieee_set_section_contents (abfd, section, location, offset, count)
3191 bfd_size_type count;
3193 if ((section->flags & SEC_DEBUGGING) != 0)
3195 if (section->contents == NULL)
3197 section->contents = ((unsigned char *)
3198 bfd_alloc (abfd, section->_raw_size));
3199 if (section->contents == NULL)
3202 /* bfd_set_section_contents has already checked that everything
3204 memcpy (section->contents + offset, location, count);
3208 if (ieee_per_section (section)->data == (bfd_byte *) NULL)
3210 if (!init_for_output (abfd))
3213 memcpy ((PTR) (ieee_per_section (section)->data + offset),
3215 (unsigned int) count);
3219 /* Write the external symbols of a file. IEEE considers two sorts of
3220 external symbols, public, and referenced. It uses to internal
3221 forms to index them as well. When we write them out we turn their
3222 symbol values into indexes from the right base. */
3225 ieee_write_external_part (abfd)
3229 ieee_data_type *ieee = IEEE_DATA (abfd);
3231 unsigned int reference_index = IEEE_REFERENCE_BASE;
3232 unsigned int public_index = IEEE_PUBLIC_BASE + 2;
3233 file_ptr here = bfd_tell (abfd);
3234 boolean hadone = false;
3235 if (abfd->outsymbols != (asymbol **) NULL)
3238 for (q = abfd->outsymbols; *q != (asymbol *) NULL; q++)
3241 if (bfd_is_und_section (p->section))
3243 /* This must be a symbol reference .. */
3244 if (! ieee_write_byte (abfd, ieee_external_reference_enum)
3245 || ! ieee_write_int (abfd, reference_index)
3246 || ! ieee_write_id (abfd, p->name))
3248 p->value = reference_index;
3252 else if (bfd_is_com_section (p->section))
3254 /* This is a weak reference */
3255 if (! ieee_write_byte (abfd, ieee_external_reference_enum)
3256 || ! ieee_write_int (abfd, reference_index)
3257 || ! ieee_write_id (abfd, p->name)
3258 || ! ieee_write_byte (abfd,
3259 ieee_weak_external_reference_enum)
3260 || ! ieee_write_int (abfd, reference_index)
3261 || ! ieee_write_int (abfd, p->value))
3263 p->value = reference_index;
3267 else if (p->flags & BSF_GLOBAL)
3269 /* This must be a symbol definition */
3271 if (! ieee_write_byte (abfd, ieee_external_symbol_enum)
3272 || ! ieee_write_int (abfd, public_index)
3273 || ! ieee_write_id (abfd, p->name)
3274 || ! ieee_write_2bytes (abfd, ieee_attribute_record_enum)
3275 || ! ieee_write_int (abfd, public_index)
3276 || ! ieee_write_byte (abfd, 15) /* instruction address */
3277 || ! ieee_write_byte (abfd, 19) /* static symbol */
3278 || ! ieee_write_byte (abfd, 1)) /* one of them */
3281 /* Write out the value */
3282 if (! ieee_write_2bytes (abfd, ieee_value_record_enum)
3283 || ! ieee_write_int (abfd, public_index))
3285 if (! bfd_is_abs_section (p->section))
3287 if (abfd->flags & EXEC_P)
3289 /* If fully linked, then output all symbols
3291 if (! (ieee_write_int
3294 + p->section->output_offset
3295 + p->section->output_section->vma))))
3300 if (! (ieee_write_expression
3302 p->value + p->section->output_offset,
3303 p->section->output_section->symbol,
3310 if (! ieee_write_expression (abfd,
3312 bfd_abs_section_ptr->symbol,
3316 p->value = public_index;
3322 /* This can happen - when there are gaps in the symbols read */
3323 /* from an input ieee file */
3328 ieee->w.r.external_part = here;
3334 static CONST unsigned char exten[] =
3337 0xf1, 0xce, 0x20, 0x00, 37, 3, 3, /* Set version 3 rev 3 */
3338 0xf1, 0xce, 0x20, 0x00, 39, 2,/* keep symbol in original case */
3339 0xf1, 0xce, 0x20, 0x00, 38 /* set object type relocateable to x */
3342 static CONST unsigned char envi[] =
3346 /* 0xf1, 0xce, 0x21, 00, 50, 0x82, 0x07, 0xc7, 0x09, 0x11, 0x11,
3349 0xf1, 0xce, 0x21, 00, 52, 0x00, /* exec ok */
3351 0xf1, 0xce, 0x21, 0, 53, 0x03,/* host unix */
3352 /* 0xf1, 0xce, 0x21, 0, 54, 2,1,1 tool & version # */
3356 ieee_write_me_part (abfd)
3359 ieee_data_type *ieee = IEEE_DATA (abfd);
3360 ieee->w.r.trailer_part = bfd_tell (abfd);
3361 if (abfd->start_address)
3363 if (! ieee_write_2bytes (abfd, ieee_value_starting_address_enum)
3364 || ! ieee_write_byte (abfd, ieee_function_either_open_b_enum)
3365 || ! ieee_write_int (abfd, abfd->start_address)
3366 || ! ieee_write_byte (abfd, ieee_function_either_close_b_enum))
3369 ieee->w.r.me_record = bfd_tell (abfd);
3370 if (! ieee_write_byte (abfd, ieee_module_end_enum))
3375 /* Write out the IEEE processor ID. */
3378 ieee_write_processor (abfd)
3381 const bfd_arch_info_type *arch;
3383 arch = bfd_get_arch_info (abfd);
3387 if (! ieee_write_id (abfd, bfd_printable_name (abfd)))
3392 if (! ieee_write_id (abfd, "29000"))
3396 case bfd_arch_h8300:
3397 if (! ieee_write_id (abfd, "H8/300"))
3401 case bfd_arch_h8500:
3402 if (! ieee_write_id (abfd, "H8/500"))
3410 case bfd_mach_i960_core:
3411 case bfd_mach_i960_ka_sa:
3412 if (! ieee_write_id (abfd, "80960KA"))
3416 case bfd_mach_i960_kb_sb:
3417 if (! ieee_write_id (abfd, "80960KB"))
3421 case bfd_mach_i960_ca:
3422 if (! ieee_write_id (abfd, "80960CA"))
3426 case bfd_mach_i960_mc:
3427 case bfd_mach_i960_xa:
3428 if (! ieee_write_id (abfd, "80960MC"))
3438 sprintf (ab, "%lu", arch->mach);
3439 if (! ieee_write_id (abfd, ab))
3449 ieee_write_object_contents (abfd)
3452 ieee_data_type *ieee = IEEE_DATA (abfd);
3456 /* Fast forward over the header area */
3457 if (bfd_seek (abfd, (file_ptr) 0, SEEK_SET) != 0)
3460 if (! ieee_write_byte (abfd, ieee_module_beginning_enum)
3461 || ! ieee_write_processor (abfd)
3462 || ! ieee_write_id (abfd, abfd->filename))
3465 /* Fast forward over the variable bits */
3466 if (! ieee_write_byte (abfd, ieee_address_descriptor_enum))
3470 if (! ieee_write_byte (abfd, (bfd_byte) (bfd_arch_bits_per_byte (abfd))))
3472 /* MAU's per address */
3473 if (! ieee_write_byte (abfd,
3474 (bfd_byte) (bfd_arch_bits_per_address (abfd)
3475 / bfd_arch_bits_per_byte (abfd))))
3478 old = bfd_tell (abfd);
3479 if (bfd_seek (abfd, (file_ptr) (8 * N_W_VARIABLES), SEEK_CUR) != 0)
3482 ieee->w.r.extension_record = bfd_tell (abfd);
3483 if (bfd_write ((char *) exten, 1, sizeof (exten), abfd) != sizeof (exten))
3485 if (abfd->flags & EXEC_P)
3487 if (! ieee_write_byte (abfd, 0x1)) /* Absolute */
3492 if (! ieee_write_byte (abfd, 0x2)) /* Relocateable */
3496 ieee->w.r.environmental_record = bfd_tell (abfd);
3497 if (bfd_write ((char *) envi, 1, sizeof (envi), abfd) != sizeof (envi))
3500 /* The HP emulator database requires a timestamp in the file. */
3506 t = (struct tm *) localtime (&now);
3507 if (! ieee_write_2bytes (abfd, (int) ieee_atn_record_enum)
3508 || ! ieee_write_byte (abfd, 0x21)
3509 || ! ieee_write_byte (abfd, 0)
3510 || ! ieee_write_byte (abfd, 50)
3511 || ! ieee_write_int (abfd, t->tm_year + 1900)
3512 || ! ieee_write_int (abfd, t->tm_mon + 1)
3513 || ! ieee_write_int (abfd, t->tm_mday)
3514 || ! ieee_write_int (abfd, t->tm_hour)
3515 || ! ieee_write_int (abfd, t->tm_min)
3516 || ! ieee_write_int (abfd, t->tm_sec))
3524 if (! ieee_write_section_part (abfd))
3526 /* First write the symbols. This changes their values into table
3527 indeces so we cant use it after this point. */
3528 if (! ieee_write_external_part (abfd))
3531 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
3533 /* ieee_write_byte(abfd, ieee_record_seperator_enum);*/
3536 /* Write any debugs we have been told about. */
3537 if (! ieee_write_debug_part (abfd))
3540 /* Can only write the data once the symbols have been written, since
3541 the data contains relocation information which points to the
3543 if (! ieee_write_data_part (abfd))
3546 /* At the end we put the end! */
3547 if (! ieee_write_me_part (abfd))
3550 /* Generate the header */
3551 if (bfd_seek (abfd, old, SEEK_SET) != 0)
3554 for (i = 0; i < N_W_VARIABLES; i++)
3556 if (! ieee_write_2bytes (abfd, ieee_assign_value_to_variable_enum)
3557 || ! ieee_write_byte (abfd, (bfd_byte) i)
3558 || ! ieee_write_int5_out (abfd, ieee->w.offset[i]))
3565 /* Native-level interface to symbols. */
3567 /* We read the symbols into a buffer, which is discarded when this
3568 function exits. We read the strings into a buffer large enough to
3569 hold them all plus all the cached symbol entries. */
3572 ieee_make_empty_symbol (abfd)
3575 ieee_symbol_type *new =
3576 (ieee_symbol_type *) bfd_zmalloc (sizeof (ieee_symbol_type));
3579 new->symbol.the_bfd = abfd;
3580 return &new->symbol;
3584 ieee_openr_next_archived_file (arch, prev)
3588 ieee_ar_data_type *ar = IEEE_AR_DATA (arch);
3589 /* take the next one from the arch state, or reset */
3590 if (prev == (bfd *) NULL)
3592 /* Reset the index - the first two entries are bogus*/
3593 ar->element_index = 2;
3597 ieee_ar_obstack_type *p = ar->elements + ar->element_index;
3598 ar->element_index++;
3599 if (ar->element_index <= ar->element_count)
3601 if (p->file_offset != (file_ptr) 0)
3603 if (p->abfd == (bfd *) NULL)
3605 p->abfd = _bfd_create_empty_archive_element_shell (arch);
3606 p->abfd->origin = p->file_offset;
3613 bfd_set_error (bfd_error_no_more_archived_files);
3614 return (bfd *) NULL;
3621 ieee_find_nearest_line (abfd,
3632 char **filename_ptr;
3633 char **functionname_ptr;
3640 ieee_generic_stat_arch_elt (abfd, buf)
3644 ieee_ar_data_type *ar = (ieee_ar_data_type *) NULL;
3645 ieee_data_type *ieee;
3647 if (abfd->my_archive != NULL)
3648 ar = abfd->my_archive->tdata.ieee_ar_data;
3649 if (ar == (ieee_ar_data_type *) NULL)
3651 bfd_set_error (bfd_error_invalid_operation);
3655 if (IEEE_DATA (abfd) == NULL)
3657 if (ieee_object_p (abfd) == NULL)
3659 bfd_set_error (bfd_error_wrong_format);
3664 ieee = IEEE_DATA (abfd);
3666 buf->st_size = ieee->w.r.me_record + 1;
3667 buf->st_mode = 0644;
3672 ieee_sizeof_headers (abfd, x)
3680 /* The debug info routines are never used. */
3684 ieee_bfd_debug_info_start (abfd)
3691 ieee_bfd_debug_info_end (abfd)
3698 /* Add this section to the list of sections we have debug info for, to
3699 be ready to output it at close time
3702 ieee_bfd_debug_info_accumulate (abfd, section)
3706 ieee_data_type *ieee = IEEE_DATA (section->owner);
3707 ieee_data_type *output_ieee = IEEE_DATA (abfd);
3708 /* can only accumulate data from other ieee bfds */
3709 if (section->owner->xvec != abfd->xvec)
3711 /* Only bother once per bfd */
3712 if (ieee->done_debug == true)
3714 ieee->done_debug = true;
3716 /* Don't bother if there is no debug info */
3717 if (ieee->w.r.debug_information_part == 0)
3723 bfd_chain_type *n = (bfd_chain_type *) bfd_alloc (abfd, sizeof (bfd_chain_type));
3725 abort (); /* FIXME */
3726 n->this = section->owner;
3727 n->next = (bfd_chain_type *) NULL;
3729 if (output_ieee->chain_head)
3731 output_ieee->chain_head->next = n;
3735 output_ieee->chain_root = n;
3738 output_ieee->chain_head = n;
3744 #define ieee_close_and_cleanup _bfd_generic_close_and_cleanup
3745 #define ieee_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
3747 #define ieee_slurp_armap bfd_true
3748 #define ieee_slurp_extended_name_table bfd_true
3749 #define ieee_construct_extended_name_table \
3750 ((boolean (*) PARAMS ((bfd *, char **, bfd_size_type *, const char **))) \
3752 #define ieee_truncate_arname bfd_dont_truncate_arname
3753 #define ieee_write_armap \
3755 PARAMS ((bfd *, unsigned int, struct orl *, unsigned int, int))) \
3757 #define ieee_read_ar_hdr bfd_nullvoidptr
3758 #define ieee_update_armap_timestamp bfd_true
3759 #define ieee_get_elt_at_index _bfd_generic_get_elt_at_index
3761 #define ieee_bfd_is_local_label_name bfd_generic_is_local_label_name
3762 #define ieee_get_lineno _bfd_nosymbols_get_lineno
3763 #define ieee_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
3764 #define ieee_read_minisymbols _bfd_generic_read_minisymbols
3765 #define ieee_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
3767 #define ieee_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
3769 #define ieee_set_arch_mach _bfd_generic_set_arch_mach
3771 #define ieee_get_section_contents_in_window \
3772 _bfd_generic_get_section_contents_in_window
3773 #define ieee_bfd_get_relocated_section_contents \
3774 bfd_generic_get_relocated_section_contents
3775 #define ieee_bfd_relax_section bfd_generic_relax_section
3776 #define ieee_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
3777 #define ieee_bfd_link_add_symbols _bfd_generic_link_add_symbols
3778 #define ieee_bfd_final_link _bfd_generic_final_link
3779 #define ieee_bfd_link_split_section _bfd_generic_link_split_section
3782 const bfd_target ieee_vec =
3785 bfd_target_ieee_flavour,
3786 BFD_ENDIAN_UNKNOWN, /* target byte order */
3787 BFD_ENDIAN_UNKNOWN, /* target headers byte order */
3788 (HAS_RELOC | EXEC_P | /* object flags */
3789 HAS_LINENO | HAS_DEBUG |
3790 HAS_SYMS | HAS_LOCALS | WP_TEXT | D_PAGED),
3791 (SEC_CODE | SEC_DATA | SEC_ROM | SEC_HAS_CONTENTS
3792 | SEC_ALLOC | SEC_LOAD | SEC_RELOC), /* section flags */
3793 '_', /* leading underscore */
3794 ' ', /* ar_pad_char */
3795 16, /* ar_max_namelen */
3796 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
3797 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
3798 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
3799 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
3800 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
3801 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
3804 ieee_object_p, /* bfd_check_format */
3811 _bfd_generic_mkarchive,
3816 ieee_write_object_contents,
3817 _bfd_write_archive_contents,
3821 BFD_JUMP_TABLE_GENERIC (ieee),
3822 BFD_JUMP_TABLE_COPY (_bfd_generic),
3823 BFD_JUMP_TABLE_CORE (_bfd_nocore),
3824 BFD_JUMP_TABLE_ARCHIVE (ieee),
3825 BFD_JUMP_TABLE_SYMBOLS (ieee),
3826 BFD_JUMP_TABLE_RELOCS (ieee),
3827 BFD_JUMP_TABLE_WRITE (ieee),
3828 BFD_JUMP_TABLE_LINK (ieee),
3829 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),