Lines Matching full:ieee
1 /* BFD back-end for ieee-695 objects.
26 /* IEEE 695 format is a stream of records, which we parse using a simple one-
33 #include "ieee.h"
57 /* Functions for writing to ieee files in the strange way that the
170 /* Functions for reading from ieee files in the strange way that the
173 #define this_byte(ieee) *((ieee)->input_p)
174 #define next_byte(ieee) ((ieee)->input_p++)
175 #define this_byte_and_next(ieee) (*((ieee)->input_p++))
178 read_2bytes (common_header_type *ieee)
180 unsigned char c1 = this_byte_and_next (ieee);
181 unsigned char c2 = this_byte_and_next (ieee);
187 bfd_get_string (common_header_type *ieee, char *string, size_t length)
192 string[i] = this_byte_and_next (ieee);
196 read_id (common_header_type *ieee)
201 length = this_byte_and_next (ieee);
208 length = this_byte_and_next (ieee);
213 length = this_byte_and_next (ieee);
214 length = (length * 256) + this_byte_and_next (ieee);
218 string = bfd_alloc (ieee->abfd, (bfd_size_type) length + 1);
221 bfd_get_string (ieee, string, length);
345 parse_int (common_header_type *ieee, bfd_vma *value_ptr)
347 int value = this_byte (ieee);
353 next_byte (ieee);
361 next_byte (ieee);
364 result = (result << 8) | this_byte_and_next (ieee);
374 parse_i (common_header_type *ieee, bfd_boolean *ok)
377 *ok = parse_int (ieee, &x);
382 must_parse_int (common_header_type *ieee)
385 BFD_ASSERT (parse_int (ieee, &result));
502 parse_expression (ieee_data_type *ieee,
525 while (loop && ieee->h.input_p < ieee->h.last_byte)
527 switch (this_byte (&(ieee->h)))
534 next_byte (&(ieee->h));
536 section_n = must_parse_int (&(ieee->h));
543 next_byte (&(ieee->h));
544 PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
549 next_byte (&(ieee->h));
550 PUSH (NOSYMBOL, ieee->section_table[must_parse_int (&(ieee->h))], 0);
554 next_byte (&(ieee->h));
557 ieee->section_table[must_parse_int (&(ieee->h))]->size);
564 next_byte (&(ieee->h));
565 sy.index = (int) must_parse_int (&(ieee->h));
576 next_byte (&(ieee->h));
577 sy.index = (int) (must_parse_int (&(ieee->h)));
589 next_byte (&(ieee->h));
604 next_byte (&(ieee->h));
617 BFD_ASSERT (this_byte (&(ieee->h)) < (int) ieee_variable_A_enum
618 || this_byte (&(ieee->h)) > (int) ieee_variable_Z_enum);
619 if (parse_int (&(ieee->h), &va))
630 /* As far as I can see there is a bug in the Microtec IEEE output
652 #define ieee_seek(ieee, offset) \
655 ieee->h.input_p = ieee->h.first_byte + offset; \
656 ieee->h.last_byte = (ieee->h.first_byte \
657 + ieee_part_after (ieee, offset)); \
661 #define ieee_pos(ieee) \
662 (ieee->h.input_p - ieee->h.first_byte)
664 /* Find the first part of the ieee file after HERE. */
667 ieee_part_after (ieee_data_type *ieee, file_ptr here)
670 file_ptr after = ieee->w.r.me_record;
675 if (ieee->w.offset[part] > here && after > ieee->w.offset[part])
676 after = ieee->w.offset[part];
686 ieee_data_type *ieee,
694 unsigned int new_index = must_parse_int (&(ieee->h));
701 new_symbol = bfd_alloc (ieee->h.abfd, amt);
723 ieee_data_type *ieee = IEEE_DATA (abfd);
724 file_ptr offset = ieee->w.r.external_part;
726 ieee->external_symbols;
727 ieee_symbol_type **prev_reference_ptr = &ieee->external_reference;
733 ieee->symbol_table_full = TRUE;
735 ieee_seek (ieee, 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');
751 symbol->symbol.name = read_id (&(ieee->h));
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);
767 symbol->symbol.name = read_id (&(ieee->h));
778 switch (read_2bytes (&ieee->h))
781 symbol_name_index = must_parse_int (&(ieee->h));
782 symbol_type_index = must_parse_int (&(ieee->h));
784 symbol_attribute_def = must_parse_int (&(ieee->h));
789 parse_int (&ieee->h, &value);
802 parse_int (&(ieee->h), &value);
803 parse_int (&(ieee->h), &value);
804 parse_int (&(ieee->h), &value);
805 parse_int (&(ieee->h), &value);
811 parse_int (&ieee->h, &value);
812 parse_int (&ieee->h, &value);
813 parse_int (&ieee->h, &value);
822 parse_int (&ieee->h, &value);
823 parse_int (&ieee->h, &value);
830 switch (read_2bytes (&ieee->h))
833 parse_int (&ieee->h, &val1);
834 parse_int (&ieee->h, &val1);
854 next_byte (&(ieee->h));
855 next_byte (&(ieee->h));
857 symbol_name_index = must_parse_int (&(ieee->h));
859 parse_expression (ieee,
866 /* Fully linked IEEE-695 files tend to give every symbol
897 next_byte (&(ieee->h));
899 (void) must_parse_int (&(ieee->h));
901 size = must_parse_int (&(ieee->h));
903 if (! parse_int (&(ieee->h), &value))
912 next_byte (&(ieee->h));
914 symbol = get_symbol (abfd, ieee, symbol, &symbol_count,
916 &ieee->external_reference_max_index, 'X');
921 symbol->symbol.name = read_id (&(ieee->h));
927 BFD_ASSERT (symbol->index >= ieee->external_reference_min_index);
935 if (ieee->external_symbol_max_index != 0)
937 ieee->external_symbol_count =
938 ieee->external_symbol_max_index -
939 ieee->external_symbol_min_index + 1;
942 ieee->external_symbol_count = 0;
944 if (ieee->external_reference_max_index != 0)
946 ieee->external_reference_count =
947 ieee->external_reference_max_index -
948 ieee->external_reference_min_index + 1;
951 ieee->external_reference_count = 0;
954 ieee->external_reference_count + ieee->external_symbol_count;
958 ieee->symbol_table_full = FALSE;
1001 " ieee empty",
1013 ieee_data_type *ieee = IEEE_DATA (abfd);
1019 if (! ieee->symbol_table_full)
1029 ieee->external_symbol_base_offset = -ieee->external_symbol_min_index;
1034 location[symp->index + ieee->external_symbol_base_offset] = &symp->symbol;
1037 ieee->external_reference_base_offset =
1038 -ieee->external_reference_min_index + ieee->external_symbol_count;
1043 location[symp->index + ieee->external_reference_base_offset] =
1054 get_section_entry (bfd *abfd, ieee_data_type *ieee, unsigned int sindex)
1056 if (sindex >= ieee->section_table_size)
1062 c = ieee->section_table_size;
1070 n = bfd_realloc (ieee->section_table, amt);
1074 for (i = ieee->section_table_size; i < c; i++)
1077 ieee->section_table = n;
1078 ieee->section_table_size = c;
1081 if (ieee->section_table[sindex] == (asection *) NULL)
1090 ieee->section_table[sindex] = section;
1092 ieee->section_table[sindex] = section;
1094 return ieee->section_table[sindex];
1100 ieee_data_type *ieee = IEEE_DATA (abfd);
1101 file_ptr offset = ieee->w.r.section_part;
1108 ieee_seek (ieee, offset);
1111 switch (this_byte (&(ieee->h)))
1118 next_byte (&(ieee->h));
1119 section_index = must_parse_int (&(ieee->h));
1121 section = get_section_entry (abfd, ieee, section_index);
1123 section_type[0] = this_byte_and_next (&(ieee->h));
1131 section_type[1] = this_byte (&(ieee->h));
1137 next_byte (&(ieee->h));
1138 section_type[2] = this_byte (&(ieee->h));
1143 next_byte (&(ieee->h));
1148 next_byte (&(ieee->h));
1152 next_byte (&(ieee->h));
1164 section_type[1] = this_byte (&(ieee->h));
1169 next_byte (&(ieee->h));
1173 next_byte (&(ieee->h));
1177 next_byte (&(ieee->h));
1186 name = read_id (&ieee->h);
1194 parse_int (&(ieee->h), &parent);
1195 parse_int (&(ieee->h), &brother);
1196 parse_int (&(ieee->h), &context);
1206 next_byte (&(ieee->h));
1207 section_index = must_parse_int (&ieee->h);
1208 section = get_section_entry (abfd, ieee, section_index);
1209 if (section_index > ieee->section_count)
1210 ieee->section_count = section_index;
1213 bfd_log2 (must_parse_int (&ieee->h));
1214 (void) parse_int (&(ieee->h), &value);
1222 t = (ieee_record_enum_type) (read_2bytes (&(ieee->h)));
1226 section = ieee->section_table[must_parse_int (&(ieee->h))];
1227 section->size = must_parse_int (&(ieee->h));
1230 section = ieee->section_table[must_parse_int (&(ieee->h))];
1231 section->size = must_parse_int (&(ieee->h));
1234 section = ieee->section_table[must_parse_int (&(ieee->h))];
1235 section->vma = must_parse_int (&(ieee->h));
1239 must_parse_int (&(ieee->h));
1240 must_parse_int (&(ieee->h));
1243 must_parse_int (&(ieee->h));
1244 must_parse_int (&(ieee->h));
1247 section = ieee->section_table[must_parse_int (&(ieee->h))];
1248 section->vma = must_parse_int (&(ieee->h));
1252 (void) must_parse_int (&(ieee->h));
1253 (void) must_parse_int (&(ieee->h));
1275 ieee_data_type *ieee = IEEE_DATA (abfd);
1280 if (ieee->w.r.debug_information_part == 0)
1287 sec->filepos = ieee->w.r.debug_information_part;
1289 debug_end = ieee_part_after (ieee, ieee->w.r.debug_information_part);
1290 sec->size = debug_end - ieee->w.r.debug_information_part;
1306 ieee_ar_data_type *ieee;
1314 ieee = IEEE_AR_DATA (abfd);
1317 the entire buffer. We might have a very small ieee file. */
1321 ieee->h.first_byte = buffer;
1322 ieee->h.input_p = buffer;
1324 ieee->h.abfd = abfd;
1326 if (this_byte (&(ieee->h)) != Module_Beginning)
1329 next_byte (&(ieee->h));
1330 library = read_id (&(ieee->h));
1335 read_id (&(ieee->h));
1337 ieee->element_count = 0;
1338 ieee->element_index = 0;
1340 next_byte (&(ieee->h)); /* Drop the ad part. */
1341 must_parse_int (&(ieee->h)); /* And the two dummy numbers. */
1342 must_parse_int (&(ieee->h));
1355 rec = read_2bytes (&(ieee->h));
1359 if (ieee->element_count >= alc_elts)
1370 ieee->element_count];
1371 ieee->element_count++;
1373 must_parse_int (&(ieee->h));
1374 t->file_offset = must_parse_int (&(ieee->h));
1387 ieee->h.first_byte = buffer;
1388 ieee->h.input_p = buffer;
1392 amt = ieee->element_count;
1393 amt *= sizeof *ieee->elements;
1394 ieee->elements = bfd_alloc (abfd, amt);
1395 if (ieee->elements == NULL)
1398 memcpy (ieee->elements, elts, (size_t) amt);
1403 for (i = 2; i < ieee->element_count; i++)
1405 if (bfd_seek (abfd, ieee->elements[i].file_offset, SEEK_SET) != 0)
1410 ieee->h.first_byte = buffer;
1411 ieee->h.input_p = buffer;
1413 next_byte (&(ieee->h)); /* Drop F8. */
1414 next_byte (&(ieee->h)); /* Drop 14. */
1415 must_parse_int (&(ieee->h)); /* Drop size of block. */
1417 if (must_parse_int (&(ieee->h)) != 0)
1419 ieee->elements[i].file_offset = 0;
1421 ieee->elements[i].file_offset = must_parse_int (&(ieee->h));
1433 bfd_release (abfd, ieee);
1460 do_one (ieee_data_type *ieee,
1466 switch (this_byte (&(ieee->h)))
1473 next_byte (&(ieee->h));
1474 number_of_maus = must_parse_int (&(ieee->h));
1478 location_ptr[current_map->pc++] = this_byte (&(ieee->h));
1479 next_byte (&(ieee->h));
1488 next_byte (&(ieee->h));
1491 switch (this_byte (&(ieee->h)))
1504 r = bfd_alloc (ieee->h.abfd, sizeof (* r));
1511 next_byte (&(ieee->h));
1514 parse_expression (ieee,
1525 if (this_byte (&(ieee->h)) == (int) ieee_comma)
1527 next_byte (&(ieee->h));
1529 extra = must_parse_int (&(ieee->h));
1532 switch (this_byte (&(ieee->h)))
1535 next_byte (&(ieee->h));
1538 next_byte (&(ieee->h));
1541 next_byte (&(ieee->h));
1561 bfd_put_32 (ieee->h.abfd, -current_map->pc,
1566 bfd_put_32 (ieee->h.abfd, (bfd_vma) 0, location_ptr +
1573 bfd_put_32 (ieee->h.abfd, (bfd_vma) 0,
1583 bfd_put_16 (ieee->h.abfd, (bfd_vma) -current_map->pc,
1589 bfd_put_16 (ieee->h.abfd, (bfd_vma) 0,
1597 bfd_put_16 (ieee->h.abfd, (bfd_vma) 0,
1607 bfd_put_8 (ieee->h.abfd, (int) (-current_map->pc), location_ptr + current_map->pc);
1611 bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1617 bfd_put_8 (ieee->h.abfd, 0, location_ptr + current_map->pc);
1633 if (parse_int (&(ieee->h), &this_size))
1639 location_ptr[current_map->pc++] = this_byte (&(ieee->h));
1640 next_byte (&(ieee->h));
1664 ieee_data_type *ieee = IEEE_DATA (abfd);
1670 if (ieee->read_data)
1672 ieee->read_data = TRUE;
1673 ieee_seek (ieee, ieee->w.r.data_part);
1683 per->data = bfd_alloc (ieee->h.abfd, s->size);
1692 switch (this_byte (&(ieee->h)))
1699 next_byte (&(ieee->h));
1700 section_number = must_parse_int (&(ieee->h));
1701 s = ieee->section_table[section_number];
1712 next_byte (&(ieee->h));
1713 switch (this_byte (&(ieee->h)))
1722 next_byte (&(ieee->h));
1723 must_parse_int (&(ieee->h)); /* Throw away section #. */
1724 parse_expression (ieee, &value,
1734 next_byte (&(ieee->h));
1735 if (this_byte (&(ieee->h)) == ieee_function_either_open_b_enum)
1736 next_byte (&(ieee->h));
1737 abfd->start_address = must_parse_int (&(ieee->h));
1754 next_byte (&(ieee->h));
1755 iterations = must_parse_int (&(ieee->h));
1756 start = ieee->h.input_p;
1765 next_byte (&(ieee->h));
1766 next_byte (&(ieee->h));
1767 next_byte (&(ieee->h));
1773 ieee->h.input_p = start;
1774 if (!do_one (ieee, current_map, location_ptr, s,
1784 if (!do_one (ieee, current_map, location_ptr, s, 1))
1795 ieee_data_type *ieee;
1803 ieee = IEEE_DATA (abfd);
1811 ieee->h.input_p = buffer;
1812 if (this_byte_and_next (&(ieee->h)) != Module_Beginning)
1815 ieee->read_symbols = FALSE;
1816 ieee->read_data = FALSE;
1817 ieee->section_count = 0;
1818 ieee->external_symbol_max_index = 0;
1819 ieee->external_symbol_min_index = IEEE_PUBLIC_BASE;
1820 ieee->external_reference_min_index = IEEE_REFERENCE_BASE;
1821 ieee->external_reference_max_index = 0;
1822 ieee->h.abfd = abfd;
1823 ieee->section_table = NULL;
1824 ieee->section_table_size = 0;
1826 processor = ieee->mb.processor = read_id (&(ieee->h));
1829 ieee->mb.module_name = read_id (&(ieee->h));
1831 abfd->filename = xstrdup (ieee->mb.module_name);
1838 /* IEEE does not specify the format of the processor identification
1904 if (this_byte (&(ieee->h)) != (int) ieee_address_descriptor_enum)
1907 next_byte (&(ieee->h));
1909 if (! parse_int (&(ieee->h), &ieee->ad.number_of_bits_mau))
1912 if (! parse_int (&(ieee->h), &ieee->ad.number_of_maus_in_address))
1916 if (this_byte (&(ieee->h)) == (int) ieee_variable_L_enum
1917 || this_byte (&(ieee->h)) == (int) ieee_variable_M_enum)
1918 next_byte (&(ieee->h));
1924 if (read_2bytes (&(ieee->h)) != (int) ieee_assign_value_to_variable_enum)
1927 if (this_byte_and_next (&(ieee->h)) != part)
1930 ieee->w.offset[part] = parse_i (&(ieee->h), &ok);
1935 if (ieee->w.r.external_part != 0)
1938 /* By now we know that this is a real IEEE file, we're going to read
1943 amt = ieee->w.r.me_record + 1;
1944 IEEE_DATA (abfd)->h.first_byte = bfd_alloc (ieee->h.abfd, amt);
1952 (bfd_size_type) ieee->w.r.me_record + 1, abfd);
1968 bfd_release (abfd, ieee);
2072 ieee_data_type *ieee = IEEE_DATA (abfd);
2084 symbols + src->symbol.index + ieee->external_symbol_base_offset;
2088 symbols + src->symbol.index + ieee->external_reference_base_offset;
2119 ieee_data_type *ieee = IEEE_DATA (abfd);
2122 ieee->w.r.section_part = bfd_tell (abfd);
2610 ieee_data_type *ieee;
2617 ieee = IEEE_DATA (input_bfd);
2618 s = ieee->section_table[section_number];
3113 ieee_data_type *ieee = IEEE_DATA (abfd);
3114 bfd_chain_type *chain = ieee->chain_root;
3133 ieee->w.r.debug_information_part = 0;
3137 ieee->w.r.debug_information_part = here;
3160 ieee->w.r.debug_information_part = here;
3162 ieee->w.r.debug_information_part = 0;
3170 /* Write the data in an ieee way. */
3177 ieee_data_type *ieee = IEEE_DATA (abfd);
3178 ieee->w.r.data_part = bfd_tell (abfd);
3227 /* Set section contents is complicated with IEEE since the format is
3263 /* Write the external symbols of a file. IEEE considers two sorts of
3272 ieee_data_type *ieee = IEEE_DATA (abfd);
3366 from an input ieee file. */
3371 ieee->w.r.external_part = here;
3401 ieee_data_type *ieee = IEEE_DATA (abfd);
3402 ieee->w.r.trailer_part = bfd_tell (abfd);
3411 ieee->w.r.me_record = bfd_tell (abfd);
3417 /* Write out the IEEE processor ID. */
3521 ieee_data_type *ieee = IEEE_DATA (abfd);
3551 ieee
3566 ieee->w.r.environmental_record = bfd_tell (abfd);
3624 || ! ieee_write_int5_out (abfd, (bfd_vma) ieee->w.offset[i]))
3693 ieee_data_type *ieee;
3712 ieee = IEEE_DATA (abfd);
3714 buf->st_size = ieee->w.r.me_record + 1;
3781 "ieee", /* Name. */
3821 BFD_JUMP_TABLE_GENERIC (ieee),
3831 BFD_JUMP_TABLE_ARCHIVE (ieee),
3838 BFD_JUMP_TABLE_SYMBOLS (ieee),
3842 BFD_JUMP_TABLE_RELOCS (ieee),
3845 BFD_JUMP_TABLE_WRITE (ieee),
3852 BFD_JUMP_TABLE_LINK (ieee),