1 /* xSYM symbol-file support for BFD.
2 Copyright 1999, 2000, 2001, 2002, 2003, 2004
3 Free Software Foundation, Inc.
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. */
26 #define bfd_sym_close_and_cleanup _bfd_generic_close_and_cleanup
27 #define bfd_sym_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
28 #define bfd_sym_new_section_hook _bfd_generic_new_section_hook
29 #define bfd_sym_bfd_is_local_label_name bfd_generic_is_local_label_name
30 #define bfd_sym_get_lineno _bfd_nosymbols_get_lineno
31 #define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line
32 #define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
33 #define bfd_sym_read_minisymbols _bfd_generic_read_minisymbols
34 #define bfd_sym_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
35 #define bfd_sym_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
36 #define bfd_sym_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
37 #define bfd_sym_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
38 #define bfd_sym_set_arch_mach _bfd_generic_set_arch_mach
39 #define bfd_sym_get_section_contents _bfd_generic_get_section_contents
40 #define bfd_sym_set_section_contents _bfd_generic_set_section_contents
41 #define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
42 #define bfd_sym_bfd_relax_section bfd_generic_relax_section
43 #define bfd_sym_bfd_gc_sections bfd_generic_gc_sections
44 #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections
45 #define bfd_sym_bfd_is_group_section bfd_generic_is_group_section
46 #define bfd_sym_bfd_discard_group bfd_generic_discard_group
47 #define bfd_sym_section_already_linked \
48 _bfd_generic_section_already_linked
49 #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
50 #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
51 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
52 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
53 #define bfd_sym_bfd_final_link _bfd_generic_final_link
54 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
55 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
57 static int pstrcmp PARAMS ((unsigned char *, unsigned char *));
58 static unsigned long compute_offset
59 PARAMS ((unsigned long, unsigned long, unsigned long, unsigned long));
61 extern const bfd_target sym_vec;
71 clen = (a[0] > b[0]) ? a[0] : b[0];
72 ret = memcmp (a + 1, b + 1, clen);
85 compute_offset (first_page, page_size, entry_size, index)
86 unsigned long first_page;
87 unsigned long page_size;
88 unsigned long entry_size;
91 unsigned long entries_per_page = page_size / entry_size;
92 unsigned long page_number = first_page + (index / entries_per_page);
93 unsigned long page_offset = (index % entries_per_page) * entry_size;
95 return (page_number * page_size) + page_offset;
99 bfd_sym_mkobject (abfd)
100 bfd *abfd ATTRIBUTE_UNUSED;
106 bfd_sym_print_symbol (abfd, afile, symbol, how)
107 bfd *abfd ATTRIBUTE_UNUSED;
108 PTR afile ATTRIBUTE_UNUSED;
109 asymbol *symbol ATTRIBUTE_UNUSED;
110 bfd_print_symbol_type how ATTRIBUTE_UNUSED;
119 if (abfd == NULL || abfd->xvec == NULL)
122 return abfd->xvec == &sym_vec;
126 bfd_sym_read_name_table (abfd, dshb)
128 bfd_sym_header_block *dshb;
132 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
133 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
135 rstr = (unsigned char *) bfd_alloc (abfd, table_size);
139 bfd_seek (abfd, table_offset, SEEK_SET);
140 ret = bfd_bread (rstr, table_size, abfd);
141 if (ret < 0 || (unsigned long) ret != table_size)
143 bfd_release (abfd, rstr);
151 bfd_sym_parse_file_reference_v32 (buf, len, entry)
154 bfd_sym_file_reference *entry;
156 BFD_ASSERT (len == 6);
158 entry->fref_frte_index = bfd_getb16 (buf);
159 entry->fref_offset = bfd_getb32 (buf + 2);
163 bfd_sym_parse_disk_table_v32 (buf, len, table)
166 bfd_sym_table_info *table;
168 BFD_ASSERT (len == 8);
170 table->dti_first_page = bfd_getb16 (buf);
171 table->dti_page_count = bfd_getb16 (buf + 2);
172 table->dti_object_count = bfd_getb32 (buf + 4);
176 bfd_sym_parse_header_v32 (buf, len, header)
179 bfd_sym_header_block *header;
181 BFD_ASSERT (len == 154);
183 memcpy (header->dshb_id, buf, 32);
184 header->dshb_page_size = bfd_getb16 (buf + 32);
185 header->dshb_hash_page = bfd_getb16 (buf + 34);
186 header->dshb_root_mte = bfd_getb16 (buf + 36);
187 header->dshb_mod_date = bfd_getb32 (buf + 38);
189 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
190 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
191 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
192 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
193 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
194 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
195 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
196 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
197 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
198 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
199 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
200 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
201 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
203 memcpy (&header->dshb_file_creator, buf + 146, 4);
204 memcpy (&header->dshb_file_type, buf + 150, 4);
208 bfd_sym_read_header_v32 (abfd, header)
210 bfd_sym_header_block *header;
212 unsigned char buf[154];
215 ret = bfd_bread (buf, 154, abfd);
219 bfd_sym_parse_header_v32 (buf, 154, header);
225 bfd_sym_read_header_v34 (abfd, header)
226 bfd *abfd ATTRIBUTE_UNUSED;
227 bfd_sym_header_block *header ATTRIBUTE_UNUSED;
233 bfd_sym_read_header (abfd, header, version)
235 bfd_sym_header_block *header;
236 bfd_sym_version version;
240 case BFD_SYM_VERSION_3_5:
241 case BFD_SYM_VERSION_3_4:
242 return bfd_sym_read_header_v34 (abfd, header);
243 case BFD_SYM_VERSION_3_3:
244 case BFD_SYM_VERSION_3_2:
245 return bfd_sym_read_header_v32 (abfd, header);
246 case BFD_SYM_VERSION_3_1:
253 bfd_sym_read_version (abfd, version)
255 bfd_sym_version *version;
257 unsigned char version_string[32];
260 ret = bfd_bread (version_string, sizeof (version_string), abfd);
261 if (ret != sizeof (version_string))
264 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
265 *version = BFD_SYM_VERSION_3_1;
266 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
267 *version = BFD_SYM_VERSION_3_2;
268 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
269 *version = BFD_SYM_VERSION_3_3;
270 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
271 *version = BFD_SYM_VERSION_3_4;
272 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
273 *version = BFD_SYM_VERSION_3_5;
281 bfd_sym_display_table_summary (f, dti, name)
283 bfd_sym_table_info *dti;
286 fprintf (f, "%-6s %13ld %13ld %13ld\n",
290 dti->dti_object_count);
294 bfd_sym_display_header (f, dshb)
296 bfd_sym_header_block *dshb;
298 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
299 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
300 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
301 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
302 fprintf (f, " Modification Date: ");
303 fprintf (f, "[unimplemented]");
304 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
306 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
307 dshb->dshb_file_creator, dshb->dshb_file_type);
309 fprintf (f, "Table Name First Page Page Count Object Count\n");
310 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
312 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
313 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
314 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
315 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
316 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
317 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
318 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
319 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
320 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
321 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
322 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
323 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
324 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
330 bfd_sym_parse_resources_table_entry_v32 (buf, len, entry)
333 bfd_sym_resources_table_entry *entry;
335 BFD_ASSERT (len == 18);
337 memcpy (&entry->rte_res_type, buf, 4);
338 entry->rte_res_number = bfd_getb16 (buf + 4);
339 entry->rte_nte_index = bfd_getb32 (buf + 6);
340 entry->rte_mte_first = bfd_getb16 (buf + 10);
341 entry->rte_mte_last = bfd_getb16 (buf + 12);
342 entry->rte_res_size = bfd_getb32 (buf + 14);
346 bfd_sym_parse_modules_table_entry_v33 (buf, len, entry)
349 bfd_sym_modules_table_entry *entry;
351 BFD_ASSERT (len == 46);
353 entry->mte_rte_index = bfd_getb16 (buf);
354 entry->mte_res_offset = bfd_getb32 (buf + 2);
355 entry->mte_size = bfd_getb32 (buf + 6);
356 entry->mte_kind = buf[10];
357 entry->mte_scope = buf[11];
358 entry->mte_parent = bfd_getb16 (buf + 12);
359 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
360 entry->mte_imp_end = bfd_getb32 (buf + 20);
361 entry->mte_nte_index = bfd_getb32 (buf + 24);
362 entry->mte_cmte_index = bfd_getb16 (buf + 28);
363 entry->mte_cvte_index = bfd_getb32 (buf + 30);
364 entry->mte_clte_index = bfd_getb16 (buf + 34);
365 entry->mte_ctte_index = bfd_getb16 (buf + 36);
366 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
367 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
371 bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry)
374 bfd_sym_file_references_table_entry *entry;
378 BFD_ASSERT (len == 10);
380 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
381 type = bfd_getb16 (buf);
385 case BFD_SYM_END_OF_LIST_3_2:
386 entry->generic.type = BFD_SYM_END_OF_LIST;
389 case BFD_SYM_FILE_NAME_INDEX_3_2:
390 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
391 entry->filename.nte_index = bfd_getb32 (buf + 2);
392 entry->filename.mod_date = bfd_getb32 (buf + 6);
396 entry->entry.mte_index = type;
397 entry->entry.file_offset = bfd_getb32 (buf + 2);
402 bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry)
405 bfd_sym_contained_modules_table_entry *entry;
409 BFD_ASSERT (len == 6);
411 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
412 type = bfd_getb16 (buf);
416 case BFD_SYM_END_OF_LIST_3_2:
417 entry->generic.type = BFD_SYM_END_OF_LIST;
421 entry->entry.mte_index = type;
422 entry->entry.nte_index = bfd_getb32 (buf + 2);
428 bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry)
431 bfd_sym_contained_variables_table_entry *entry;
435 BFD_ASSERT (len == 26);
437 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
438 type = bfd_getb16 (buf);
442 case BFD_SYM_END_OF_LIST_3_2:
443 entry->generic.type = BFD_SYM_END_OF_LIST;
446 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
447 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
448 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
452 entry->entry.tte_index = type;
453 entry->entry.nte_index = bfd_getb32 (buf + 2);
454 entry->entry.file_delta = bfd_getb16 (buf + 6);
455 entry->entry.scope = buf[8];
456 entry->entry.la_size = buf[9];
458 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
460 entry->entry.address.scstruct.sca_kind = buf[10];
461 entry->entry.address.scstruct.sca_class = buf[11];
462 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
464 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
466 memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA);
467 entry->entry.address.lastruct.la_kind = buf[23];
469 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
471 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
472 entry->entry.address.biglastruct.big_la_kind = buf[12];
478 bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
481 bfd_sym_contained_statements_table_entry *entry;
485 BFD_ASSERT (len == 8);
487 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
488 type = bfd_getb16 (buf);
492 case BFD_SYM_END_OF_LIST_3_2:
493 entry->generic.type = BFD_SYM_END_OF_LIST;
496 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
497 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
498 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
502 entry->entry.mte_index = type;
503 entry->entry.mte_offset = bfd_getb16 (buf + 2);
504 entry->entry.file_delta = bfd_getb32 (buf + 4);
510 bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
513 bfd_sym_contained_labels_table_entry *entry;
517 BFD_ASSERT (len == 12);
519 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
520 type = bfd_getb16 (buf);
524 case BFD_SYM_END_OF_LIST_3_2:
525 entry->generic.type = BFD_SYM_END_OF_LIST;
528 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
529 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
530 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
534 entry->entry.mte_index = type;
535 entry->entry.mte_offset = bfd_getb16 (buf + 2);
536 entry->entry.nte_index = bfd_getb32 (buf + 4);
537 entry->entry.file_delta = bfd_getb16 (buf + 8);
538 entry->entry.scope = bfd_getb16 (buf + 10);
544 bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
547 bfd_sym_type_table_entry *entry;
549 BFD_ASSERT (len == 4);
551 *entry = bfd_getb32 (buf);
555 bfd_sym_fetch_resources_table_entry (abfd, entry, index)
557 bfd_sym_resources_table_entry *entry;
560 void (*parser) PARAMS ((unsigned char *, size_t,
561 bfd_sym_resources_table_entry *));
562 unsigned long offset;
563 unsigned long entry_size;
564 unsigned char buf[18];
565 bfd_sym_data_struct *sdata = NULL;
568 BFD_ASSERT (bfd_sym_valid (abfd));
569 sdata = abfd->tdata.sym_data;
574 switch (sdata->version)
576 case BFD_SYM_VERSION_3_5:
577 case BFD_SYM_VERSION_3_4:
580 case BFD_SYM_VERSION_3_3:
581 case BFD_SYM_VERSION_3_2:
583 parser = bfd_sym_parse_resources_table_entry_v32;
586 case BFD_SYM_VERSION_3_1:
593 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
594 sdata->header.dshb_page_size,
597 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
599 if (bfd_bread (buf, entry_size, abfd) != entry_size)
602 (*parser) (buf, entry_size, entry);
608 bfd_sym_fetch_modules_table_entry (abfd, entry, index)
610 bfd_sym_modules_table_entry *entry;
613 void (*parser) PARAMS ((unsigned char *, size_t,
614 bfd_sym_modules_table_entry *));
615 unsigned long offset;
616 unsigned long entry_size;
617 unsigned char buf[46];
618 bfd_sym_data_struct *sdata = NULL;
621 BFD_ASSERT (bfd_sym_valid (abfd));
622 sdata = abfd->tdata.sym_data;
627 switch (sdata->version)
629 case BFD_SYM_VERSION_3_5:
630 case BFD_SYM_VERSION_3_4:
633 case BFD_SYM_VERSION_3_3:
635 parser = bfd_sym_parse_modules_table_entry_v33;
638 case BFD_SYM_VERSION_3_2:
639 case BFD_SYM_VERSION_3_1:
646 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
647 sdata->header.dshb_page_size,
650 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
652 if (bfd_bread (buf, entry_size, abfd) != entry_size)
655 (*parser) (buf, entry_size, entry);
661 bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
663 bfd_sym_file_references_table_entry *entry;
666 void (*parser) PARAMS ((unsigned char *, size_t,
667 bfd_sym_file_references_table_entry *));
668 unsigned long offset;
669 unsigned long entry_size = 0;
670 unsigned char buf[8];
671 bfd_sym_data_struct *sdata = NULL;
674 BFD_ASSERT (bfd_sym_valid (abfd));
675 sdata = abfd->tdata.sym_data;
680 switch (sdata->version)
682 case BFD_SYM_VERSION_3_3:
683 case BFD_SYM_VERSION_3_2:
685 parser = bfd_sym_parse_file_references_table_entry_v32;
688 case BFD_SYM_VERSION_3_5:
689 case BFD_SYM_VERSION_3_4:
690 case BFD_SYM_VERSION_3_1:
698 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
699 sdata->header.dshb_page_size,
702 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
704 if (bfd_bread (buf, entry_size, abfd) != entry_size)
707 (*parser) (buf, entry_size, entry);
713 bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
715 bfd_sym_contained_modules_table_entry *entry;
718 void (*parser) PARAMS ((unsigned char *, size_t,
719 bfd_sym_contained_modules_table_entry *));
720 unsigned long offset;
721 unsigned long entry_size = 0;
722 unsigned char buf[6];
723 bfd_sym_data_struct *sdata = NULL;
726 BFD_ASSERT (bfd_sym_valid (abfd));
727 sdata = abfd->tdata.sym_data;
732 switch (sdata->version)
734 case BFD_SYM_VERSION_3_3:
735 case BFD_SYM_VERSION_3_2:
737 parser = bfd_sym_parse_contained_modules_table_entry_v32;
740 case BFD_SYM_VERSION_3_5:
741 case BFD_SYM_VERSION_3_4:
742 case BFD_SYM_VERSION_3_1:
750 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
751 sdata->header.dshb_page_size,
754 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
756 if (bfd_bread (buf, entry_size, abfd) != entry_size)
759 (*parser) (buf, entry_size, entry);
765 bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
767 bfd_sym_contained_variables_table_entry *entry;
770 void (*parser) PARAMS ((unsigned char *, size_t,
771 bfd_sym_contained_variables_table_entry *));
772 unsigned long offset;
773 unsigned long entry_size = 0;
774 unsigned char buf[26];
775 bfd_sym_data_struct *sdata = NULL;
778 BFD_ASSERT (bfd_sym_valid (abfd));
779 sdata = abfd->tdata.sym_data;
784 switch (sdata->version)
786 case BFD_SYM_VERSION_3_3:
787 case BFD_SYM_VERSION_3_2:
789 parser = bfd_sym_parse_contained_variables_table_entry_v32;
792 case BFD_SYM_VERSION_3_5:
793 case BFD_SYM_VERSION_3_4:
794 case BFD_SYM_VERSION_3_1:
802 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
803 sdata->header.dshb_page_size,
806 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
808 if (bfd_bread (buf, entry_size, abfd) != entry_size)
811 (*parser) (buf, entry_size, entry);
817 bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
819 bfd_sym_contained_statements_table_entry *entry;
822 void (*parser) PARAMS ((unsigned char *, size_t,
823 bfd_sym_contained_statements_table_entry *));
824 unsigned long offset;
825 unsigned long entry_size = 0;
826 unsigned char buf[8];
827 bfd_sym_data_struct *sdata = NULL;
830 BFD_ASSERT (bfd_sym_valid (abfd));
831 sdata = abfd->tdata.sym_data;
836 switch (sdata->version)
838 case BFD_SYM_VERSION_3_3:
839 case BFD_SYM_VERSION_3_2:
841 parser = bfd_sym_parse_contained_statements_table_entry_v32;
844 case BFD_SYM_VERSION_3_5:
845 case BFD_SYM_VERSION_3_4:
846 case BFD_SYM_VERSION_3_1:
854 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
855 sdata->header.dshb_page_size,
858 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
860 if (bfd_bread (buf, entry_size, abfd) != entry_size)
863 (*parser) (buf, entry_size, entry);
869 bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
871 bfd_sym_contained_labels_table_entry *entry;
874 void (*parser) PARAMS ((unsigned char *, size_t,
875 bfd_sym_contained_labels_table_entry *));
876 unsigned long offset;
877 unsigned long entry_size = 0;
878 unsigned char buf[12];
879 bfd_sym_data_struct *sdata = NULL;
882 BFD_ASSERT (bfd_sym_valid (abfd));
883 sdata = abfd->tdata.sym_data;
888 switch (sdata->version)
890 case BFD_SYM_VERSION_3_3:
891 case BFD_SYM_VERSION_3_2:
893 parser = bfd_sym_parse_contained_labels_table_entry_v32;
896 case BFD_SYM_VERSION_3_5:
897 case BFD_SYM_VERSION_3_4:
898 case BFD_SYM_VERSION_3_1:
906 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
907 sdata->header.dshb_page_size,
910 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
912 if (bfd_bread (buf, entry_size, abfd) != entry_size)
915 (*parser) (buf, entry_size, entry);
921 bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
923 bfd_sym_contained_types_table_entry *entry;
926 void (*parser) PARAMS ((unsigned char *, size_t,
927 bfd_sym_contained_types_table_entry *));
928 unsigned long offset;
929 unsigned long entry_size = 0;
930 unsigned char buf[0];
931 bfd_sym_data_struct *sdata = NULL;
934 BFD_ASSERT (bfd_sym_valid (abfd));
935 sdata = abfd->tdata.sym_data;
940 switch (sdata->version)
942 case BFD_SYM_VERSION_3_3:
943 case BFD_SYM_VERSION_3_2:
948 case BFD_SYM_VERSION_3_5:
949 case BFD_SYM_VERSION_3_4:
950 case BFD_SYM_VERSION_3_1:
958 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
959 sdata->header.dshb_page_size,
962 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
964 if (bfd_bread (buf, entry_size, abfd) != entry_size)
967 (*parser) (buf, entry_size, entry);
973 bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
975 bfd_sym_file_references_index_table_entry *entry;
978 void (*parser) PARAMS ((unsigned char *, size_t,
979 bfd_sym_file_references_index_table_entry *));
980 unsigned long offset;
981 unsigned long entry_size = 0;
982 unsigned char buf[0];
983 bfd_sym_data_struct *sdata = NULL;
986 BFD_ASSERT (bfd_sym_valid (abfd));
987 sdata = abfd->tdata.sym_data;
992 switch (sdata->version)
994 case BFD_SYM_VERSION_3_3:
995 case BFD_SYM_VERSION_3_2:
1000 case BFD_SYM_VERSION_3_5:
1001 case BFD_SYM_VERSION_3_4:
1002 case BFD_SYM_VERSION_3_1:
1010 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1011 sdata->header.dshb_page_size,
1014 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1016 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1019 (*parser) (buf, entry_size, entry);
1025 bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
1027 bfd_sym_constant_pool_entry *entry;
1028 unsigned long index;
1030 void (*parser) PARAMS ((unsigned char *, size_t,
1031 bfd_sym_constant_pool_entry *));
1032 unsigned long offset;
1033 unsigned long entry_size = 0;
1034 unsigned char buf[0];
1035 bfd_sym_data_struct *sdata = NULL;
1038 BFD_ASSERT (bfd_sym_valid (abfd));
1039 sdata = abfd->tdata.sym_data;
1044 switch (sdata->version)
1046 case BFD_SYM_VERSION_3_3:
1047 case BFD_SYM_VERSION_3_2:
1052 case BFD_SYM_VERSION_3_5:
1053 case BFD_SYM_VERSION_3_4:
1054 case BFD_SYM_VERSION_3_1:
1062 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1063 sdata->header.dshb_page_size,
1066 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1068 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1071 (*parser) (buf, entry_size, entry);
1077 bfd_sym_fetch_type_table_entry (abfd, entry, index)
1079 bfd_sym_type_table_entry *entry;
1080 unsigned long index;
1082 void (*parser) PARAMS ((unsigned char *, size_t,
1083 bfd_sym_type_table_entry *));
1084 unsigned long offset;
1085 unsigned long entry_size = 0;
1086 unsigned char buf[4];
1087 bfd_sym_data_struct *sdata = NULL;
1090 BFD_ASSERT (bfd_sym_valid (abfd));
1091 sdata = abfd->tdata.sym_data;
1093 switch (sdata->version)
1095 case BFD_SYM_VERSION_3_3:
1096 case BFD_SYM_VERSION_3_2:
1098 parser = bfd_sym_parse_type_table_entry_v32;
1101 case BFD_SYM_VERSION_3_5:
1102 case BFD_SYM_VERSION_3_4:
1103 case BFD_SYM_VERSION_3_1:
1111 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1112 sdata->header.dshb_page_size,
1115 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1117 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1120 (*parser) (buf, entry_size, entry);
1126 bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
1128 bfd_sym_type_information_table_entry *entry;
1129 unsigned long offset;
1131 unsigned char buf[4];
1132 bfd_sym_data_struct *sdata = NULL;
1134 BFD_ASSERT (bfd_sym_valid (abfd));
1135 sdata = abfd->tdata.sym_data;
1140 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1143 if (bfd_bread (buf, 4, abfd) != 4)
1145 entry->nte_index = bfd_getb32 (buf);
1147 if (bfd_bread (buf, 2, abfd) != 2)
1149 entry->physical_size = bfd_getb16 (buf);
1151 if (entry->physical_size & 0x8000)
1153 if (bfd_bread (buf, 4, abfd) != 4)
1155 entry->physical_size &= 0x7fff;
1156 entry->logical_size = bfd_getb32 (buf);
1157 entry->offset = offset + 10;
1161 if (bfd_bread (buf, 2, abfd) != 2)
1163 entry->physical_size &= 0x7fff;
1164 entry->logical_size = bfd_getb16 (buf);
1165 entry->offset = offset + 8;
1172 bfd_sym_fetch_type_table_information (abfd, entry, index)
1174 bfd_sym_type_information_table_entry *entry;
1175 unsigned long index;
1177 bfd_sym_type_table_entry tindex;
1178 bfd_sym_data_struct *sdata = NULL;
1180 BFD_ASSERT (bfd_sym_valid (abfd));
1181 sdata = abfd->tdata.sym_data;
1183 if (sdata->header.dshb_tte.dti_object_count <= 99)
1188 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
1190 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1196 const unsigned char *
1197 bfd_sym_symbol_name (abfd, index)
1199 unsigned long index;
1201 bfd_sym_data_struct *sdata = NULL;
1203 BFD_ASSERT (bfd_sym_valid (abfd));
1204 sdata = abfd->tdata.sym_data;
1210 if ((index / sdata->header.dshb_page_size)
1211 > sdata->header.dshb_nte.dti_page_count)
1212 return "\009[INVALID]";
1214 return (const unsigned char *) sdata->name_table + index;
1217 const unsigned char *
1218 bfd_sym_module_name (abfd, index)
1220 unsigned long index;
1222 bfd_sym_modules_table_entry entry;
1224 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
1225 return "\011[INVALID]";
1227 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1231 bfd_sym_unparse_storage_kind (kind)
1232 enum bfd_sym_storage_kind kind;
1236 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1237 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1238 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1239 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1240 default: return "[UNKNOWN]";
1245 bfd_sym_unparse_storage_class (kind)
1246 enum bfd_sym_storage_class kind;
1250 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1251 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1252 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1253 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1254 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1255 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1256 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1257 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1258 default: return "[UNKNOWN]";
1263 bfd_sym_unparse_module_kind (kind)
1264 enum bfd_sym_module_kind kind;
1268 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1269 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1270 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1271 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1272 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1273 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1274 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1275 default: return "[UNKNOWN]";
1280 bfd_sym_unparse_symbol_scope (scope)
1281 enum bfd_sym_symbol_scope scope;
1285 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1286 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1293 bfd_sym_print_file_reference (abfd, f, entry)
1296 bfd_sym_file_reference *entry;
1298 bfd_sym_file_references_table_entry frtentry;
1301 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1302 entry->fref_frte_index);
1303 fprintf (f, "FILE ");
1305 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1306 fprintf (f, "[INVALID]");
1308 fprintf (f, "\"%.*s\"",
1309 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1310 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1312 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1316 bfd_sym_print_resources_table_entry (abfd, f, entry)
1319 bfd_sym_resources_table_entry *entry;
1321 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1322 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1323 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1324 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1325 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1329 bfd_sym_print_modules_table_entry (abfd, f, entry)
1332 bfd_sym_modules_table_entry *entry;
1334 fprintf (f, "\"%.*s\" (NTE %lu)",
1335 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1336 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1337 entry->mte_nte_index);
1341 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1342 fprintf (f, " range %lu -- %lu",
1343 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1347 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1348 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1350 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1351 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1355 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1356 entry->mte_cmte_index, entry->mte_cvte_index,
1357 entry->mte_clte_index, entry->mte_ctte_index,
1358 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1360 if (entry->mte_parent != 0)
1361 fprintf (f, ", parent %lu", entry->mte_parent);
1363 fprintf (f, ", no parent");
1365 if (entry->mte_cmte_index != 0)
1366 fprintf (f, ", child %lu", entry->mte_cmte_index);
1368 fprintf (f, ", no child");
1372 MTE bfd_sym_modules_table_entry pentry;
1374 ret = bfd_sym_fetch_modules_table_entry (abfd, &pentry, entry->mte_parent);
1376 fprintf (f, " parent MTE %lu [INVALID]\n", entry->mte_parent);
1378 fprintf (f, " parent MTE %lu \"%.*s\"\n",
1380 bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[0],
1381 &bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[1]);
1387 bfd_sym_print_file_references_table_entry (abfd, f, entry)
1390 bfd_sym_file_references_table_entry *entry;
1392 switch (entry->generic.type)
1394 case BFD_SYM_FILE_NAME_INDEX:
1395 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1396 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1397 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1398 entry->filename.nte_index);
1400 fprintf (f, "[UNIMPLEMENTED]");
1401 /* printModDate (entry->filename.mod_date); */
1402 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1405 case BFD_SYM_END_OF_LIST:
1410 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1411 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1412 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1413 entry->entry.mte_index,
1414 entry->entry.file_offset);
1420 bfd_sym_print_contained_modules_table_entry (abfd, f, entry)
1423 bfd_sym_contained_modules_table_entry *entry;
1425 switch (entry->generic.type)
1427 case BFD_SYM_END_OF_LIST:
1432 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
1433 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1434 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1435 entry->entry.mte_index,
1436 entry->entry.nte_index);
1442 bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
1445 bfd_sym_contained_variables_table_entry *entry;
1447 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1453 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1455 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1456 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1460 fprintf (f, "\"%.*s\" (NTE %lu)",
1461 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1462 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1463 entry->entry.nte_index);
1465 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1466 fprintf (f, ", offset %lu", entry->entry.file_delta);
1467 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1469 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1470 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1471 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1472 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1473 entry->entry.address.scstruct.sca_offset);
1474 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1478 fprintf (f, ", la [");
1479 for (i = 0; i < entry->entry.la_size; i++)
1480 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1483 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1484 fprintf (f, ", bigla %lu, biglakind %u",
1485 entry->entry.address.biglastruct.big_la,
1486 entry->entry.address.biglastruct.big_la_kind);
1489 fprintf (f, ", la [INVALID]");
1493 bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
1496 bfd_sym_contained_statements_table_entry *entry;
1498 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1504 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1506 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1507 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1511 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1512 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1513 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1514 entry->entry.mte_index,
1515 entry->entry.mte_offset,
1516 entry->entry.file_delta);
1520 bfd_sym_print_contained_labels_table_entry (abfd, f, entry)
1523 bfd_sym_contained_labels_table_entry *entry;
1525 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1531 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1533 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1534 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1538 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1539 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1540 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1541 entry->entry.mte_index,
1542 entry->entry.mte_offset,
1543 entry->entry.file_delta,
1544 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1548 bfd_sym_print_contained_types_table_entry (abfd, f, entry)
1549 bfd *abfd ATTRIBUTE_UNUSED;
1551 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED;
1553 fprintf (f, "[UNIMPLEMENTED]");
1557 bfd_sym_type_operator_name (num)
1562 case 1: return "TTE";
1563 case 2: return "PointerTo";
1564 case 3: return "ScalarOf";
1565 case 4: return "ConstantOf";
1566 case 5: return "EnumerationOf";
1567 case 6: return "VectorOf";
1568 case 7: return "RecordOf";
1569 case 8: return "UnionOf";
1570 case 9: return "SubRangeOf";
1571 case 10: return "SetOf";
1572 case 11: return "NamedTypeOf";
1573 case 12: return "ProcOf";
1574 case 13: return "ValueOf";
1575 case 14: return "ArrayOf";
1576 default: return "[UNKNOWN OPERATOR]";
1581 bfd_sym_type_basic_name (num)
1586 case 0: return "void";
1587 case 1: return "pascal string";
1588 case 2: return "unsigned long";
1589 case 3: return "signed long";
1590 case 4: return "extended (10 bytes)";
1591 case 5: return "pascal boolean (1 byte)";
1592 case 6: return "unsigned byte";
1593 case 7: return "signed byte";
1594 case 8: return "character (1 byte)";
1595 case 9: return "wide character (2 bytes)";
1596 case 10: return "unsigned short";
1597 case 11: return "signed short";
1598 case 12: return "singled";
1599 case 13: return "double";
1600 case 14: return "extended (12 bytes)";
1601 case 15: return "computational (8 bytes)";
1602 case 16: return "c string";
1603 case 17: return "as-is string";
1604 default: return "[UNKNOWN BASIC TYPE]";
1609 bfd_sym_fetch_long (buf, len, offset, offsetptr, value)
1612 unsigned long offset;
1613 unsigned long *offsetptr;
1624 else if (! (buf[offset] & 0x80))
1626 *value = buf[offset];
1630 else if (buf[offset] == 0xc0)
1632 if ((offset + 5) > len)
1640 *value = bfd_getb32 (buf + offset + 1);
1645 else if ((buf[offset] & 0xc0) == 0xc0)
1647 *value = -(buf[offset] & 0x3f);
1651 else if ((buf[offset] & 0xc0) == 0x80)
1653 if ((offset + 2) > len)
1661 *value = bfd_getb16 (buf + offset) & 0x3fff;
1669 if (offsetptr != NULL)
1670 *offsetptr = offset;
1676 bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
1681 unsigned long offset;
1682 unsigned long *offsetptr;
1688 fprintf (f, "[NULL]");
1690 if (offsetptr != NULL)
1691 *offsetptr = offset;
1698 if (! (type & 0x80))
1700 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1702 if (offsetptr != NULL)
1703 *offsetptr = offset;
1708 fprintf (f, "[packed ");
1712 switch (type & 0x3f)
1717 bfd_sym_type_information_table_entry tinfo;
1719 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1721 fprintf (f, "[INVALID]");
1724 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1725 fprintf (f, "[INVALID]");
1727 fprintf (f, "\"%.*s\"",
1728 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1729 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1731 fprintf (f, " (TTE %lu)", value);
1736 fprintf (f, "pointer (0x%x) to ", type);
1737 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1742 unsigned long value;
1744 fprintf (f, "scalar (0x%x) of ", type);
1745 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1746 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1747 fprintf (f, " (%lu)", value);
1753 unsigned long lower, upper, nelem;
1756 fprintf (f, "enumeration (0x%x) of ", type);
1757 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1758 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1759 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1760 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1761 fprintf (f, " from %lu to %lu with %lu elements: ", lower, upper, nelem);
1763 for (i = 0; i < nelem; i++)
1766 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1772 fprintf (f, "vector (0x%x)", type);
1773 fprintf (f, "\n index ");
1774 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1775 fprintf (f, "\n target ");
1776 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1782 long nrec, eloff, i;
1784 if ((type & 0x3f) == 7)
1785 fprintf (f, "record (0x%x) of ", type);
1787 fprintf (f, "union (0x%x) of ", type);
1789 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1790 fprintf (f, "%lu elements: ", nrec);
1792 for (i = 0; i < nrec; i++)
1794 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1796 fprintf (f, "offset %lu: ", eloff);
1797 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1803 fprintf (f, "subrange (0x%x) of ", type);
1804 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1805 fprintf (f, " lower ");
1806 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1807 fprintf (f, " upper ");
1808 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1815 fprintf (f, "named type (0x%x) ", type);
1816 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1818 fprintf (f, "[INVALID]");
1820 fprintf (f, "\"%.*s\"",
1821 bfd_sym_symbol_name (abfd, value)[0],
1822 &bfd_sym_symbol_name (abfd, value)[1]);
1824 fprintf (f, " (NTE %lu) with type ", value);
1825 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1830 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1834 if (type == (0x40 | 0x6))
1841 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1842 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1843 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1844 /* fprintf (f, "\n "); */
1845 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1846 for (i = 0; i < m; i++)
1848 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1851 fprintf (f, "%ld", l);
1854 else if (type & 0x40)
1856 /* Other packed type. */
1859 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1860 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1861 /* fprintf (f, "\n "); */
1862 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1867 if (offsetptr != NULL)
1868 *offsetptr = offset;
1872 bfd_sym_print_type_information_table_entry (abfd, f, entry)
1875 bfd_sym_type_information_table_entry *entry;
1878 unsigned long offset;
1881 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1882 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1883 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1885 entry->physical_size, entry->offset, entry->logical_size);
1889 buf = alloca (entry->physical_size);
1892 fprintf (f, "[ERROR]\n");
1895 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1897 fprintf (f, "[ERROR]\n");
1900 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1902 fprintf (f, "[ERROR]\n");
1907 for (i = 0; i < entry->physical_size; i++)
1910 fprintf (f, "0x%02x", buf[i]);
1912 fprintf (f, " 0x%02x", buf[i]);
1918 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1920 if (offset != entry->physical_size)
1921 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); }
1924 bfd_sym_print_file_references_index_table_entry (abfd, f, entry)
1925 bfd *abfd ATTRIBUTE_UNUSED;
1927 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED;
1929 fprintf (f, "[UNIMPLEMENTED]");
1933 bfd_sym_print_constant_pool_entry (abfd, f, entry)
1934 bfd *abfd ATTRIBUTE_UNUSED;
1936 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED;
1938 fprintf (f, "[UNIMPLEMENTED]");
1942 bfd_sym_display_name_table_entry (abfd, f, entry)
1945 unsigned char *entry;
1947 unsigned long index;
1948 unsigned long offset;
1949 bfd_sym_data_struct *sdata = NULL;
1951 BFD_ASSERT (bfd_sym_valid (abfd));
1952 sdata = abfd->tdata.sym_data;
1953 index = (entry - sdata->name_table) / 2;
1955 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1957 unsigned short length = bfd_getb16 (entry + 2);
1958 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
1959 offset = 2 + length + 1;
1963 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1964 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
1966 if (sdata->version >= BFD_SYM_VERSION_3_4)
1967 offset = entry[0] + 2;
1969 offset = entry[0] + 1;
1972 return (entry + offset + (offset % 2));
1976 bfd_sym_display_name_table (abfd, f)
1980 unsigned long name_table_len;
1981 unsigned char *name_table, *name_table_end, *cur;
1982 bfd_sym_data_struct *sdata = NULL;
1984 BFD_ASSERT (bfd_sym_valid (abfd));
1985 sdata = abfd->tdata.sym_data;
1987 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1988 name_table = sdata->name_table;
1989 name_table_end = name_table + name_table_len;
1991 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1996 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1997 if (cur >= name_table_end)
2003 bfd_sym_display_resources_table (abfd, f)
2008 bfd_sym_resources_table_entry entry;
2009 bfd_sym_data_struct *sdata = NULL;
2011 BFD_ASSERT (bfd_sym_valid (abfd));
2012 sdata = abfd->tdata.sym_data;
2014 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
2015 sdata->header.dshb_rte.dti_object_count);
2017 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
2019 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
2020 fprintf (f, " [%8lu] [INVALID]\n", i);
2023 fprintf (f, " [%8lu] ", i);
2024 bfd_sym_print_resources_table_entry (abfd, f, &entry);
2031 bfd_sym_display_modules_table (abfd, f)
2036 bfd_sym_modules_table_entry entry;
2037 bfd_sym_data_struct *sdata = NULL;
2039 BFD_ASSERT (bfd_sym_valid (abfd));
2040 sdata = abfd->tdata.sym_data;
2042 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
2043 sdata->header.dshb_mte.dti_object_count);
2045 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
2047 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
2048 fprintf (f, " [%8lu] [INVALID]\n", i);
2051 fprintf (f, " [%8lu] ", i);
2052 bfd_sym_print_modules_table_entry (abfd, f, &entry);
2059 bfd_sym_display_file_references_table (abfd, f)
2064 bfd_sym_file_references_table_entry entry;
2065 bfd_sym_data_struct *sdata = NULL;
2067 BFD_ASSERT (bfd_sym_valid (abfd));
2068 sdata = abfd->tdata.sym_data;
2070 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
2071 sdata->header.dshb_frte.dti_object_count);
2073 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
2075 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
2076 fprintf (f, " [%8lu] [INVALID]\n", i);
2079 fprintf (f, " [%8lu] ", i);
2080 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
2087 bfd_sym_display_contained_modules_table (abfd, f)
2092 bfd_sym_contained_modules_table_entry entry;
2093 bfd_sym_data_struct *sdata = NULL;
2095 BFD_ASSERT (bfd_sym_valid (abfd));
2096 sdata = abfd->tdata.sym_data;
2098 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
2099 sdata->header.dshb_cmte.dti_object_count);
2101 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2103 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
2104 fprintf (f, " [%8lu] [INVALID]\n", i);
2107 fprintf (f, " [%8lu] ", i);
2108 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
2115 bfd_sym_display_contained_variables_table (abfd, f)
2120 bfd_sym_contained_variables_table_entry entry;
2121 bfd_sym_data_struct *sdata = NULL;
2123 BFD_ASSERT (bfd_sym_valid (abfd));
2124 sdata = abfd->tdata.sym_data;
2126 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2127 sdata->header.dshb_cvte.dti_object_count);
2129 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2131 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2132 fprintf (f, " [%8lu] [INVALID]\n", i);
2135 fprintf (f, " [%8lu] ", i);
2136 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2145 bfd_sym_display_contained_statements_table (abfd, f)
2150 bfd_sym_contained_statements_table_entry entry;
2151 bfd_sym_data_struct *sdata = NULL;
2153 BFD_ASSERT (bfd_sym_valid (abfd));
2154 sdata = abfd->tdata.sym_data;
2156 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
2157 sdata->header.dshb_csnte.dti_object_count);
2159 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2161 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
2162 fprintf (f, " [%8lu] [INVALID]\n", i);
2165 fprintf (f, " [%8lu] ", i);
2166 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
2173 bfd_sym_display_contained_labels_table (abfd, f)
2178 bfd_sym_contained_labels_table_entry entry;
2179 bfd_sym_data_struct *sdata = NULL;
2181 BFD_ASSERT (bfd_sym_valid (abfd));
2182 sdata = abfd->tdata.sym_data;
2184 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
2185 sdata->header.dshb_clte.dti_object_count);
2187 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2189 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
2190 fprintf (f, " [%8lu] [INVALID]\n", i);
2193 fprintf (f, " [%8lu] ", i);
2194 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
2201 bfd_sym_display_contained_types_table (abfd, f)
2206 bfd_sym_contained_types_table_entry entry;
2207 bfd_sym_data_struct *sdata = NULL;
2209 BFD_ASSERT (bfd_sym_valid (abfd));
2210 sdata = abfd->tdata.sym_data;
2212 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
2213 sdata->header.dshb_ctte.dti_object_count);
2215 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2217 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2218 fprintf (f, " [%8lu] [INVALID]\n", i);
2221 fprintf (f, " [%8lu] ", i);
2222 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2229 bfd_sym_display_file_references_index_table (abfd, f)
2234 bfd_sym_file_references_index_table_entry entry;
2235 bfd_sym_data_struct *sdata = NULL;
2237 BFD_ASSERT (bfd_sym_valid (abfd));
2238 sdata = abfd->tdata.sym_data;
2240 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
2241 sdata->header.dshb_fite.dti_object_count);
2243 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2245 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2246 fprintf (f, " [%8lu] [INVALID]\n", i);
2249 fprintf (f, " [%8lu] ", i);
2250 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2257 bfd_sym_display_constant_pool (abfd, f)
2262 bfd_sym_constant_pool_entry entry;
2263 bfd_sym_data_struct *sdata = NULL;
2265 BFD_ASSERT (bfd_sym_valid (abfd));
2266 sdata = abfd->tdata.sym_data;
2268 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2269 sdata->header.dshb_const.dti_object_count);
2271 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2273 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2274 fprintf (f, " [%8lu] [INVALID]\n", i);
2277 fprintf (f, " [%8lu] ", i);
2278 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2285 bfd_sym_display_type_information_table (abfd, f)
2290 bfd_sym_type_table_entry index;
2291 bfd_sym_type_information_table_entry entry;
2292 bfd_sym_data_struct *sdata = NULL;
2294 BFD_ASSERT (bfd_sym_valid (abfd));
2295 sdata = abfd->tdata.sym_data;
2297 if (sdata->header.dshb_tte.dti_object_count > 99)
2298 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2299 sdata->header.dshb_tte.dti_object_count - 99);
2302 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2306 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2308 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
2309 fprintf (f, " [%8lu] [INVALID]\n", i);
2312 fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
2314 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
2315 fprintf (f, "[INVALID]");
2317 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2325 bfd_sym_scan (abfd, version, mdata)
2327 bfd_sym_version version;
2328 bfd_sym_data_struct *mdata;
2331 const char *name = "symbols";
2333 mdata->name_table = 0;
2335 mdata->version = version;
2337 bfd_seek (abfd, 0, SEEK_SET);
2338 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2341 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2342 if (mdata->name_table == NULL)
2345 bfdsec = bfd_make_section_anyway (abfd, name);
2352 bfdsec->filepos = 0;
2353 bfdsec->alignment_power = 0;
2355 bfdsec->flags = SEC_HAS_CONTENTS;
2357 abfd->tdata.sym_data = mdata;
2363 bfd_sym_object_p (abfd)
2366 struct bfd_preserve preserve;
2367 bfd_sym_version version = -1;
2369 preserve.marker = NULL;
2370 bfd_seek (abfd, 0, SEEK_SET);
2371 if (bfd_sym_read_version (abfd, &version) != 0)
2374 preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
2375 if (preserve.marker == NULL
2376 || ! bfd_preserve_save (abfd, &preserve))
2379 if (bfd_sym_scan (abfd, version,
2380 (bfd_sym_data_struct *) preserve.marker) != 0)
2383 bfd_preserve_finish (abfd, &preserve);
2387 bfd_set_error (bfd_error_wrong_format);
2390 if (preserve.marker != NULL)
2391 bfd_preserve_restore (abfd, &preserve);
2396 bfd_sym_make_empty_symbol (abfd)
2399 return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
2403 bfd_sym_get_symbol_info (abfd, symbol, ret)
2404 bfd *abfd ATTRIBUTE_UNUSED;
2408 bfd_symbol_info (symbol, ret);
2412 bfd_sym_get_symtab_upper_bound (abfd)
2413 bfd *abfd ATTRIBUTE_UNUSED;
2419 bfd_sym_canonicalize_symtab (abfd, sym)
2420 bfd *abfd ATTRIBUTE_UNUSED;
2421 asymbol **sym ATTRIBUTE_UNUSED;
2427 bfd_sym_sizeof_headers (abfd, exec)
2428 bfd *abfd ATTRIBUTE_UNUSED;
2429 bfd_boolean exec ATTRIBUTE_UNUSED;
2434 const bfd_target sym_vec =
2437 bfd_target_sym_flavour, /* flavour */
2438 BFD_ENDIAN_BIG, /* byteorder */
2439 BFD_ENDIAN_BIG, /* header_byteorder */
2440 (HAS_RELOC | EXEC_P | /* object flags */
2441 HAS_LINENO | HAS_DEBUG |
2442 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2443 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2444 | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
2445 0, /* symbol_leading_char */
2446 ' ', /* ar_pad_char */
2447 16, /* ar_max_namelen */
2448 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2449 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2450 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
2451 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2452 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2453 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
2454 { /* bfd_check_format */
2456 bfd_sym_object_p, /* bfd_check_format */
2460 { /* bfd_set_format */
2466 { /* bfd_write_contents */
2473 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2474 BFD_JUMP_TABLE_COPY (_bfd_generic),
2475 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2476 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2477 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2478 BFD_JUMP_TABLE_RELOCS (bfd_sym),
2479 BFD_JUMP_TABLE_WRITE (bfd_sym),
2480 BFD_JUMP_TABLE_LINK (bfd_sym),
2481 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),