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_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
48 #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
49 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
50 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
51 #define bfd_sym_bfd_final_link _bfd_generic_final_link
52 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
53 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
55 static int pstrcmp PARAMS ((unsigned char *, unsigned char *));
56 static unsigned long compute_offset
57 PARAMS ((unsigned long, unsigned long, unsigned long, unsigned long));
59 extern const bfd_target sym_vec;
69 clen = (a[0] > b[0]) ? a[0] : b[0];
70 ret = memcmp (a + 1, b + 1, clen);
83 compute_offset (first_page, page_size, entry_size, index)
84 unsigned long first_page;
85 unsigned long page_size;
86 unsigned long entry_size;
89 unsigned long entries_per_page = page_size / entry_size;
90 unsigned long page_number = first_page + (index / entries_per_page);
91 unsigned long page_offset = (index % entries_per_page) * entry_size;
93 return (page_number * page_size) + page_offset;
97 bfd_sym_mkobject (abfd)
98 bfd *abfd ATTRIBUTE_UNUSED;
104 bfd_sym_print_symbol (abfd, afile, symbol, how)
105 bfd *abfd ATTRIBUTE_UNUSED;
106 PTR afile ATTRIBUTE_UNUSED;
107 asymbol *symbol ATTRIBUTE_UNUSED;
108 bfd_print_symbol_type how ATTRIBUTE_UNUSED;
117 if (abfd == NULL || abfd->xvec == NULL)
120 return abfd->xvec == &sym_vec;
124 bfd_sym_read_name_table (abfd, dshb)
126 bfd_sym_header_block *dshb;
130 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
131 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
133 rstr = (unsigned char *) bfd_alloc (abfd, table_size);
137 bfd_seek (abfd, table_offset, SEEK_SET);
138 ret = bfd_bread (rstr, table_size, abfd);
139 if (ret < 0 || (unsigned long) ret != table_size)
141 bfd_release (abfd, rstr);
149 bfd_sym_parse_file_reference_v32 (buf, len, entry)
152 bfd_sym_file_reference *entry;
154 BFD_ASSERT (len == 6);
156 entry->fref_frte_index = bfd_getb16 (buf);
157 entry->fref_offset = bfd_getb32 (buf + 2);
161 bfd_sym_parse_disk_table_v32 (buf, len, table)
164 bfd_sym_table_info *table;
166 BFD_ASSERT (len == 8);
168 table->dti_first_page = bfd_getb16 (buf);
169 table->dti_page_count = bfd_getb16 (buf + 2);
170 table->dti_object_count = bfd_getb32 (buf + 4);
174 bfd_sym_parse_header_v32 (buf, len, header)
177 bfd_sym_header_block *header;
179 BFD_ASSERT (len == 154);
181 memcpy (header->dshb_id, buf, 32);
182 header->dshb_page_size = bfd_getb16 (buf + 32);
183 header->dshb_hash_page = bfd_getb16 (buf + 34);
184 header->dshb_root_mte = bfd_getb16 (buf + 36);
185 header->dshb_mod_date = bfd_getb32 (buf + 38);
187 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
188 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
189 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
190 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
191 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
192 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
193 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
194 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
195 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
196 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
197 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
198 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
199 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
201 memcpy (&header->dshb_file_creator, buf + 146, 4);
202 memcpy (&header->dshb_file_type, buf + 150, 4);
206 bfd_sym_read_header_v32 (abfd, header)
208 bfd_sym_header_block *header;
210 unsigned char buf[154];
213 ret = bfd_bread (buf, 154, abfd);
217 bfd_sym_parse_header_v32 (buf, 154, header);
223 bfd_sym_read_header_v34 (abfd, header)
224 bfd *abfd ATTRIBUTE_UNUSED;
225 bfd_sym_header_block *header ATTRIBUTE_UNUSED;
231 bfd_sym_read_header (abfd, header, version)
233 bfd_sym_header_block *header;
234 bfd_sym_version version;
238 case BFD_SYM_VERSION_3_5:
239 case BFD_SYM_VERSION_3_4:
240 return bfd_sym_read_header_v34 (abfd, header);
241 case BFD_SYM_VERSION_3_3:
242 case BFD_SYM_VERSION_3_2:
243 return bfd_sym_read_header_v32 (abfd, header);
244 case BFD_SYM_VERSION_3_1:
251 bfd_sym_read_version (abfd, version)
253 bfd_sym_version *version;
255 unsigned char version_string[32];
258 ret = bfd_bread (version_string, sizeof (version_string), abfd);
259 if (ret != sizeof (version_string))
262 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
263 *version = BFD_SYM_VERSION_3_1;
264 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
265 *version = BFD_SYM_VERSION_3_2;
266 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
267 *version = BFD_SYM_VERSION_3_3;
268 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
269 *version = BFD_SYM_VERSION_3_4;
270 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
271 *version = BFD_SYM_VERSION_3_5;
279 bfd_sym_display_table_summary (f, dti, name)
281 bfd_sym_table_info *dti;
284 fprintf (f, "%-6s %13ld %13ld %13ld\n",
288 dti->dti_object_count);
292 bfd_sym_display_header (f, dshb)
294 bfd_sym_header_block *dshb;
296 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
297 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
298 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
299 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
300 fprintf (f, " Modification Date: ");
301 fprintf (f, "[unimplemented]");
302 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
304 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
305 dshb->dshb_file_creator, dshb->dshb_file_type);
307 fprintf (f, "Table Name First Page Page Count Object Count\n");
308 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
310 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
311 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
312 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
313 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
314 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
315 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
316 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
317 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
318 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
319 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
320 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
321 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
322 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
328 bfd_sym_parse_resources_table_entry_v32 (buf, len, entry)
331 bfd_sym_resources_table_entry *entry;
333 BFD_ASSERT (len == 18);
335 memcpy (&entry->rte_res_type, buf, 4);
336 entry->rte_res_number = bfd_getb16 (buf + 4);
337 entry->rte_nte_index = bfd_getb32 (buf + 6);
338 entry->rte_mte_first = bfd_getb16 (buf + 10);
339 entry->rte_mte_last = bfd_getb16 (buf + 12);
340 entry->rte_res_size = bfd_getb32 (buf + 14);
344 bfd_sym_parse_modules_table_entry_v33 (buf, len, entry)
347 bfd_sym_modules_table_entry *entry;
349 BFD_ASSERT (len == 46);
351 entry->mte_rte_index = bfd_getb16 (buf);
352 entry->mte_res_offset = bfd_getb32 (buf + 2);
353 entry->mte_size = bfd_getb32 (buf + 6);
354 entry->mte_kind = buf[10];
355 entry->mte_scope = buf[11];
356 entry->mte_parent = bfd_getb16 (buf + 12);
357 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
358 entry->mte_imp_end = bfd_getb32 (buf + 20);
359 entry->mte_nte_index = bfd_getb32 (buf + 24);
360 entry->mte_cmte_index = bfd_getb16 (buf + 28);
361 entry->mte_cvte_index = bfd_getb32 (buf + 30);
362 entry->mte_clte_index = bfd_getb16 (buf + 34);
363 entry->mte_ctte_index = bfd_getb16 (buf + 36);
364 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
365 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
369 bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry)
372 bfd_sym_file_references_table_entry *entry;
376 BFD_ASSERT (len == 10);
378 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
379 type = bfd_getb16 (buf);
383 case BFD_SYM_END_OF_LIST_3_2:
384 entry->generic.type = BFD_SYM_END_OF_LIST;
387 case BFD_SYM_FILE_NAME_INDEX_3_2:
388 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
389 entry->filename.nte_index = bfd_getb32 (buf + 2);
390 entry->filename.mod_date = bfd_getb32 (buf + 6);
394 entry->entry.mte_index = type;
395 entry->entry.file_offset = bfd_getb32 (buf + 2);
400 bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry)
403 bfd_sym_contained_modules_table_entry *entry;
407 BFD_ASSERT (len == 6);
409 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
410 type = bfd_getb16 (buf);
414 case BFD_SYM_END_OF_LIST_3_2:
415 entry->generic.type = BFD_SYM_END_OF_LIST;
419 entry->entry.mte_index = type;
420 entry->entry.nte_index = bfd_getb32 (buf + 2);
426 bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry)
429 bfd_sym_contained_variables_table_entry *entry;
433 BFD_ASSERT (len == 26);
435 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
436 type = bfd_getb16 (buf);
440 case BFD_SYM_END_OF_LIST_3_2:
441 entry->generic.type = BFD_SYM_END_OF_LIST;
444 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
445 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
446 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
450 entry->entry.tte_index = type;
451 entry->entry.nte_index = bfd_getb32 (buf + 2);
452 entry->entry.file_delta = bfd_getb16 (buf + 6);
453 entry->entry.scope = buf[8];
454 entry->entry.la_size = buf[9];
456 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
458 entry->entry.address.scstruct.sca_kind = buf[10];
459 entry->entry.address.scstruct.sca_class = buf[11];
460 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
462 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
464 memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA);
465 entry->entry.address.lastruct.la_kind = buf[23];
467 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
469 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
470 entry->entry.address.biglastruct.big_la_kind = buf[12];
476 bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
479 bfd_sym_contained_statements_table_entry *entry;
483 BFD_ASSERT (len == 8);
485 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
486 type = bfd_getb16 (buf);
490 case BFD_SYM_END_OF_LIST_3_2:
491 entry->generic.type = BFD_SYM_END_OF_LIST;
494 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
495 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
496 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
500 entry->entry.mte_index = type;
501 entry->entry.mte_offset = bfd_getb16 (buf + 2);
502 entry->entry.file_delta = bfd_getb32 (buf + 4);
508 bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
511 bfd_sym_contained_labels_table_entry *entry;
515 BFD_ASSERT (len == 12);
517 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
518 type = bfd_getb16 (buf);
522 case BFD_SYM_END_OF_LIST_3_2:
523 entry->generic.type = BFD_SYM_END_OF_LIST;
526 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
527 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
528 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
532 entry->entry.mte_index = type;
533 entry->entry.mte_offset = bfd_getb16 (buf + 2);
534 entry->entry.nte_index = bfd_getb32 (buf + 4);
535 entry->entry.file_delta = bfd_getb16 (buf + 8);
536 entry->entry.scope = bfd_getb16 (buf + 10);
542 bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
545 bfd_sym_type_table_entry *entry;
547 BFD_ASSERT (len == 4);
549 *entry = bfd_getb32 (buf);
553 bfd_sym_fetch_resources_table_entry (abfd, entry, index)
555 bfd_sym_resources_table_entry *entry;
558 void (*parser) PARAMS ((unsigned char *, size_t,
559 bfd_sym_resources_table_entry *));
560 unsigned long offset;
561 unsigned long entry_size;
562 unsigned char buf[18];
563 bfd_sym_data_struct *sdata = NULL;
566 BFD_ASSERT (bfd_sym_valid (abfd));
567 sdata = abfd->tdata.sym_data;
572 switch (sdata->version)
574 case BFD_SYM_VERSION_3_5:
575 case BFD_SYM_VERSION_3_4:
578 case BFD_SYM_VERSION_3_3:
579 case BFD_SYM_VERSION_3_2:
581 parser = bfd_sym_parse_resources_table_entry_v32;
584 case BFD_SYM_VERSION_3_1:
591 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
592 sdata->header.dshb_page_size,
595 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
597 if (bfd_bread (buf, entry_size, abfd) != entry_size)
600 (*parser) (buf, entry_size, entry);
606 bfd_sym_fetch_modules_table_entry (abfd, entry, index)
608 bfd_sym_modules_table_entry *entry;
611 void (*parser) PARAMS ((unsigned char *, size_t,
612 bfd_sym_modules_table_entry *));
613 unsigned long offset;
614 unsigned long entry_size;
615 unsigned char buf[46];
616 bfd_sym_data_struct *sdata = NULL;
619 BFD_ASSERT (bfd_sym_valid (abfd));
620 sdata = abfd->tdata.sym_data;
625 switch (sdata->version)
627 case BFD_SYM_VERSION_3_5:
628 case BFD_SYM_VERSION_3_4:
631 case BFD_SYM_VERSION_3_3:
633 parser = bfd_sym_parse_modules_table_entry_v33;
636 case BFD_SYM_VERSION_3_2:
637 case BFD_SYM_VERSION_3_1:
644 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
645 sdata->header.dshb_page_size,
648 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
650 if (bfd_bread (buf, entry_size, abfd) != entry_size)
653 (*parser) (buf, entry_size, entry);
659 bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
661 bfd_sym_file_references_table_entry *entry;
664 void (*parser) PARAMS ((unsigned char *, size_t,
665 bfd_sym_file_references_table_entry *));
666 unsigned long offset;
667 unsigned long entry_size = 0;
668 unsigned char buf[8];
669 bfd_sym_data_struct *sdata = NULL;
672 BFD_ASSERT (bfd_sym_valid (abfd));
673 sdata = abfd->tdata.sym_data;
678 switch (sdata->version)
680 case BFD_SYM_VERSION_3_3:
681 case BFD_SYM_VERSION_3_2:
683 parser = bfd_sym_parse_file_references_table_entry_v32;
686 case BFD_SYM_VERSION_3_5:
687 case BFD_SYM_VERSION_3_4:
688 case BFD_SYM_VERSION_3_1:
696 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
697 sdata->header.dshb_page_size,
700 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
702 if (bfd_bread (buf, entry_size, abfd) != entry_size)
705 (*parser) (buf, entry_size, entry);
711 bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
713 bfd_sym_contained_modules_table_entry *entry;
716 void (*parser) PARAMS ((unsigned char *, size_t,
717 bfd_sym_contained_modules_table_entry *));
718 unsigned long offset;
719 unsigned long entry_size = 0;
720 unsigned char buf[6];
721 bfd_sym_data_struct *sdata = NULL;
724 BFD_ASSERT (bfd_sym_valid (abfd));
725 sdata = abfd->tdata.sym_data;
730 switch (sdata->version)
732 case BFD_SYM_VERSION_3_3:
733 case BFD_SYM_VERSION_3_2:
735 parser = bfd_sym_parse_contained_modules_table_entry_v32;
738 case BFD_SYM_VERSION_3_5:
739 case BFD_SYM_VERSION_3_4:
740 case BFD_SYM_VERSION_3_1:
748 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
749 sdata->header.dshb_page_size,
752 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
754 if (bfd_bread (buf, entry_size, abfd) != entry_size)
757 (*parser) (buf, entry_size, entry);
763 bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
765 bfd_sym_contained_variables_table_entry *entry;
768 void (*parser) PARAMS ((unsigned char *, size_t,
769 bfd_sym_contained_variables_table_entry *));
770 unsigned long offset;
771 unsigned long entry_size = 0;
772 unsigned char buf[26];
773 bfd_sym_data_struct *sdata = NULL;
776 BFD_ASSERT (bfd_sym_valid (abfd));
777 sdata = abfd->tdata.sym_data;
782 switch (sdata->version)
784 case BFD_SYM_VERSION_3_3:
785 case BFD_SYM_VERSION_3_2:
787 parser = bfd_sym_parse_contained_variables_table_entry_v32;
790 case BFD_SYM_VERSION_3_5:
791 case BFD_SYM_VERSION_3_4:
792 case BFD_SYM_VERSION_3_1:
800 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
801 sdata->header.dshb_page_size,
804 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
806 if (bfd_bread (buf, entry_size, abfd) != entry_size)
809 (*parser) (buf, entry_size, entry);
815 bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
817 bfd_sym_contained_statements_table_entry *entry;
820 void (*parser) PARAMS ((unsigned char *, size_t,
821 bfd_sym_contained_statements_table_entry *));
822 unsigned long offset;
823 unsigned long entry_size = 0;
824 unsigned char buf[8];
825 bfd_sym_data_struct *sdata = NULL;
828 BFD_ASSERT (bfd_sym_valid (abfd));
829 sdata = abfd->tdata.sym_data;
834 switch (sdata->version)
836 case BFD_SYM_VERSION_3_3:
837 case BFD_SYM_VERSION_3_2:
839 parser = bfd_sym_parse_contained_statements_table_entry_v32;
842 case BFD_SYM_VERSION_3_5:
843 case BFD_SYM_VERSION_3_4:
844 case BFD_SYM_VERSION_3_1:
852 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
853 sdata->header.dshb_page_size,
856 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
858 if (bfd_bread (buf, entry_size, abfd) != entry_size)
861 (*parser) (buf, entry_size, entry);
867 bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
869 bfd_sym_contained_labels_table_entry *entry;
872 void (*parser) PARAMS ((unsigned char *, size_t,
873 bfd_sym_contained_labels_table_entry *));
874 unsigned long offset;
875 unsigned long entry_size = 0;
876 unsigned char buf[12];
877 bfd_sym_data_struct *sdata = NULL;
880 BFD_ASSERT (bfd_sym_valid (abfd));
881 sdata = abfd->tdata.sym_data;
886 switch (sdata->version)
888 case BFD_SYM_VERSION_3_3:
889 case BFD_SYM_VERSION_3_2:
891 parser = bfd_sym_parse_contained_labels_table_entry_v32;
894 case BFD_SYM_VERSION_3_5:
895 case BFD_SYM_VERSION_3_4:
896 case BFD_SYM_VERSION_3_1:
904 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
905 sdata->header.dshb_page_size,
908 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
910 if (bfd_bread (buf, entry_size, abfd) != entry_size)
913 (*parser) (buf, entry_size, entry);
919 bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
921 bfd_sym_contained_types_table_entry *entry;
924 void (*parser) PARAMS ((unsigned char *, size_t,
925 bfd_sym_contained_types_table_entry *));
926 unsigned long offset;
927 unsigned long entry_size = 0;
928 unsigned char buf[0];
929 bfd_sym_data_struct *sdata = NULL;
932 BFD_ASSERT (bfd_sym_valid (abfd));
933 sdata = abfd->tdata.sym_data;
938 switch (sdata->version)
940 case BFD_SYM_VERSION_3_3:
941 case BFD_SYM_VERSION_3_2:
946 case BFD_SYM_VERSION_3_5:
947 case BFD_SYM_VERSION_3_4:
948 case BFD_SYM_VERSION_3_1:
956 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
957 sdata->header.dshb_page_size,
960 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
962 if (bfd_bread (buf, entry_size, abfd) != entry_size)
965 (*parser) (buf, entry_size, entry);
971 bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
973 bfd_sym_file_references_index_table_entry *entry;
976 void (*parser) PARAMS ((unsigned char *, size_t,
977 bfd_sym_file_references_index_table_entry *));
978 unsigned long offset;
979 unsigned long entry_size = 0;
980 unsigned char buf[0];
981 bfd_sym_data_struct *sdata = NULL;
984 BFD_ASSERT (bfd_sym_valid (abfd));
985 sdata = abfd->tdata.sym_data;
990 switch (sdata->version)
992 case BFD_SYM_VERSION_3_3:
993 case BFD_SYM_VERSION_3_2:
998 case BFD_SYM_VERSION_3_5:
999 case BFD_SYM_VERSION_3_4:
1000 case BFD_SYM_VERSION_3_1:
1008 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1009 sdata->header.dshb_page_size,
1012 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1014 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1017 (*parser) (buf, entry_size, entry);
1023 bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
1025 bfd_sym_constant_pool_entry *entry;
1026 unsigned long index;
1028 void (*parser) PARAMS ((unsigned char *, size_t,
1029 bfd_sym_constant_pool_entry *));
1030 unsigned long offset;
1031 unsigned long entry_size = 0;
1032 unsigned char buf[0];
1033 bfd_sym_data_struct *sdata = NULL;
1036 BFD_ASSERT (bfd_sym_valid (abfd));
1037 sdata = abfd->tdata.sym_data;
1042 switch (sdata->version)
1044 case BFD_SYM_VERSION_3_3:
1045 case BFD_SYM_VERSION_3_2:
1050 case BFD_SYM_VERSION_3_5:
1051 case BFD_SYM_VERSION_3_4:
1052 case BFD_SYM_VERSION_3_1:
1060 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1061 sdata->header.dshb_page_size,
1064 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1066 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1069 (*parser) (buf, entry_size, entry);
1075 bfd_sym_fetch_type_table_entry (abfd, entry, index)
1077 bfd_sym_type_table_entry *entry;
1078 unsigned long index;
1080 void (*parser) PARAMS ((unsigned char *, size_t,
1081 bfd_sym_type_table_entry *));
1082 unsigned long offset;
1083 unsigned long entry_size = 0;
1084 unsigned char buf[4];
1085 bfd_sym_data_struct *sdata = NULL;
1088 BFD_ASSERT (bfd_sym_valid (abfd));
1089 sdata = abfd->tdata.sym_data;
1091 switch (sdata->version)
1093 case BFD_SYM_VERSION_3_3:
1094 case BFD_SYM_VERSION_3_2:
1096 parser = bfd_sym_parse_type_table_entry_v32;
1099 case BFD_SYM_VERSION_3_5:
1100 case BFD_SYM_VERSION_3_4:
1101 case BFD_SYM_VERSION_3_1:
1109 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1110 sdata->header.dshb_page_size,
1113 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1115 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1118 (*parser) (buf, entry_size, entry);
1124 bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
1126 bfd_sym_type_information_table_entry *entry;
1127 unsigned long offset;
1129 unsigned char buf[4];
1130 bfd_sym_data_struct *sdata = NULL;
1132 BFD_ASSERT (bfd_sym_valid (abfd));
1133 sdata = abfd->tdata.sym_data;
1138 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1141 if (bfd_bread (buf, 4, abfd) != 4)
1143 entry->nte_index = bfd_getb32 (buf);
1145 if (bfd_bread (buf, 2, abfd) != 2)
1147 entry->physical_size = bfd_getb16 (buf);
1149 if (entry->physical_size & 0x8000)
1151 if (bfd_bread (buf, 4, abfd) != 4)
1153 entry->physical_size &= 0x7fff;
1154 entry->logical_size = bfd_getb32 (buf);
1155 entry->offset = offset + 10;
1159 if (bfd_bread (buf, 2, abfd) != 2)
1161 entry->physical_size &= 0x7fff;
1162 entry->logical_size = bfd_getb16 (buf);
1163 entry->offset = offset + 8;
1170 bfd_sym_fetch_type_table_information (abfd, entry, index)
1172 bfd_sym_type_information_table_entry *entry;
1173 unsigned long index;
1175 bfd_sym_type_table_entry tindex;
1176 bfd_sym_data_struct *sdata = NULL;
1178 BFD_ASSERT (bfd_sym_valid (abfd));
1179 sdata = abfd->tdata.sym_data;
1181 if (sdata->header.dshb_tte.dti_object_count <= 99)
1186 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
1188 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1194 const unsigned char *
1195 bfd_sym_symbol_name (abfd, index)
1197 unsigned long index;
1199 bfd_sym_data_struct *sdata = NULL;
1201 BFD_ASSERT (bfd_sym_valid (abfd));
1202 sdata = abfd->tdata.sym_data;
1208 if ((index / sdata->header.dshb_page_size)
1209 > sdata->header.dshb_nte.dti_page_count)
1210 return "\009[INVALID]";
1212 return (const unsigned char *) sdata->name_table + index;
1215 const unsigned char *
1216 bfd_sym_module_name (abfd, index)
1218 unsigned long index;
1220 bfd_sym_modules_table_entry entry;
1222 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
1223 return "\011[INVALID]";
1225 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1229 bfd_sym_unparse_storage_kind (kind)
1230 enum bfd_sym_storage_kind kind;
1234 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1235 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1236 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1237 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1238 default: return "[UNKNOWN]";
1243 bfd_sym_unparse_storage_class (kind)
1244 enum bfd_sym_storage_class kind;
1248 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1249 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1250 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1251 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1252 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1253 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1254 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1255 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1256 default: return "[UNKNOWN]";
1261 bfd_sym_unparse_module_kind (kind)
1262 enum bfd_sym_module_kind kind;
1266 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1267 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1268 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1269 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1270 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1271 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1272 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1273 default: return "[UNKNOWN]";
1278 bfd_sym_unparse_symbol_scope (scope)
1279 enum bfd_sym_symbol_scope scope;
1283 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1284 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1291 bfd_sym_print_file_reference (abfd, f, entry)
1294 bfd_sym_file_reference *entry;
1296 bfd_sym_file_references_table_entry frtentry;
1299 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1300 entry->fref_frte_index);
1301 fprintf (f, "FILE ");
1303 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1304 fprintf (f, "[INVALID]");
1306 fprintf (f, "\"%.*s\"",
1307 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1308 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1310 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1314 bfd_sym_print_resources_table_entry (abfd, f, entry)
1317 bfd_sym_resources_table_entry *entry;
1319 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1320 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1321 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1322 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1323 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1327 bfd_sym_print_modules_table_entry (abfd, f, entry)
1330 bfd_sym_modules_table_entry *entry;
1332 fprintf (f, "\"%.*s\" (NTE %lu)",
1333 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1334 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1335 entry->mte_nte_index);
1339 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1340 fprintf (f, " range %lu -- %lu",
1341 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1345 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1346 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1348 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1349 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1353 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1354 entry->mte_cmte_index, entry->mte_cvte_index,
1355 entry->mte_clte_index, entry->mte_ctte_index,
1356 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1358 if (entry->mte_parent != 0)
1359 fprintf (f, ", parent %lu", entry->mte_parent);
1361 fprintf (f, ", no parent");
1363 if (entry->mte_cmte_index != 0)
1364 fprintf (f, ", child %lu", entry->mte_cmte_index);
1366 fprintf (f, ", no child");
1370 MTE bfd_sym_modules_table_entry pentry;
1372 ret = bfd_sym_fetch_modules_table_entry (abfd, &pentry, entry->mte_parent);
1374 fprintf (f, " parent MTE %lu [INVALID]\n", entry->mte_parent);
1376 fprintf (f, " parent MTE %lu \"%.*s\"\n",
1378 bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[0],
1379 &bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[1]);
1385 bfd_sym_print_file_references_table_entry (abfd, f, entry)
1388 bfd_sym_file_references_table_entry *entry;
1390 switch (entry->generic.type)
1392 case BFD_SYM_FILE_NAME_INDEX:
1393 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1394 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1395 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1396 entry->filename.nte_index);
1398 fprintf (f, "[UNIMPLEMENTED]");
1399 /* printModDate (entry->filename.mod_date); */
1400 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1403 case BFD_SYM_END_OF_LIST:
1408 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1409 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1410 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1411 entry->entry.mte_index,
1412 entry->entry.file_offset);
1418 bfd_sym_print_contained_modules_table_entry (abfd, f, entry)
1421 bfd_sym_contained_modules_table_entry *entry;
1423 switch (entry->generic.type)
1425 case BFD_SYM_END_OF_LIST:
1430 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
1431 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1432 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1433 entry->entry.mte_index,
1434 entry->entry.nte_index);
1440 bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
1443 bfd_sym_contained_variables_table_entry *entry;
1445 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1451 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1453 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1454 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1458 fprintf (f, "\"%.*s\" (NTE %lu)",
1459 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1460 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1461 entry->entry.nte_index);
1463 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1464 fprintf (f, ", offset %lu", entry->entry.file_delta);
1465 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1467 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1468 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1469 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1470 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1471 entry->entry.address.scstruct.sca_offset);
1472 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1476 fprintf (f, ", la [");
1477 for (i = 0; i < entry->entry.la_size; i++)
1478 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1481 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1482 fprintf (f, ", bigla %lu, biglakind %u",
1483 entry->entry.address.biglastruct.big_la,
1484 entry->entry.address.biglastruct.big_la_kind);
1487 fprintf (f, ", la [INVALID]");
1491 bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
1494 bfd_sym_contained_statements_table_entry *entry;
1496 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1502 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1504 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1505 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1509 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1510 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1511 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1512 entry->entry.mte_index,
1513 entry->entry.mte_offset,
1514 entry->entry.file_delta);
1518 bfd_sym_print_contained_labels_table_entry (abfd, f, entry)
1521 bfd_sym_contained_labels_table_entry *entry;
1523 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1529 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1531 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1532 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1536 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1537 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1538 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1539 entry->entry.mte_index,
1540 entry->entry.mte_offset,
1541 entry->entry.file_delta,
1542 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1546 bfd_sym_print_contained_types_table_entry (abfd, f, entry)
1547 bfd *abfd ATTRIBUTE_UNUSED;
1549 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED;
1551 fprintf (f, "[UNIMPLEMENTED]");
1555 bfd_sym_type_operator_name (num)
1560 case 1: return "TTE";
1561 case 2: return "PointerTo";
1562 case 3: return "ScalarOf";
1563 case 4: return "ConstantOf";
1564 case 5: return "EnumerationOf";
1565 case 6: return "VectorOf";
1566 case 7: return "RecordOf";
1567 case 8: return "UnionOf";
1568 case 9: return "SubRangeOf";
1569 case 10: return "SetOf";
1570 case 11: return "NamedTypeOf";
1571 case 12: return "ProcOf";
1572 case 13: return "ValueOf";
1573 case 14: return "ArrayOf";
1574 default: return "[UNKNOWN OPERATOR]";
1579 bfd_sym_type_basic_name (num)
1584 case 0: return "void";
1585 case 1: return "pascal string";
1586 case 2: return "unsigned long";
1587 case 3: return "signed long";
1588 case 4: return "extended (10 bytes)";
1589 case 5: return "pascal boolean (1 byte)";
1590 case 6: return "unsigned byte";
1591 case 7: return "signed byte";
1592 case 8: return "character (1 byte)";
1593 case 9: return "wide character (2 bytes)";
1594 case 10: return "unsigned short";
1595 case 11: return "signed short";
1596 case 12: return "singled";
1597 case 13: return "double";
1598 case 14: return "extended (12 bytes)";
1599 case 15: return "computational (8 bytes)";
1600 case 16: return "c string";
1601 case 17: return "as-is string";
1602 default: return "[UNKNOWN BASIC TYPE]";
1607 bfd_sym_fetch_long (buf, len, offset, offsetptr, value)
1610 unsigned long offset;
1611 unsigned long *offsetptr;
1622 else if (! (buf[offset] & 0x80))
1624 *value = buf[offset];
1628 else if (buf[offset] == 0xc0)
1630 if ((offset + 5) > len)
1638 *value = bfd_getb32 (buf + offset + 1);
1643 else if ((buf[offset] & 0xc0) == 0xc0)
1645 *value = -(buf[offset] & 0x3f);
1649 else if ((buf[offset] & 0xc0) == 0x80)
1651 if ((offset + 2) > len)
1659 *value = bfd_getb16 (buf + offset) & 0x3fff;
1667 if (offsetptr != NULL)
1668 *offsetptr = offset;
1674 bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
1679 unsigned long offset;
1680 unsigned long *offsetptr;
1686 fprintf (f, "[NULL]");
1688 if (offsetptr != NULL)
1689 *offsetptr = offset;
1696 if (! (type & 0x80))
1698 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1700 if (offsetptr != NULL)
1701 *offsetptr = offset;
1706 fprintf (f, "[packed ");
1710 switch (type & 0x3f)
1715 bfd_sym_type_information_table_entry tinfo;
1717 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1719 fprintf (f, "[INVALID]");
1722 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1723 fprintf (f, "[INVALID]");
1725 fprintf (f, "\"%.*s\"",
1726 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1727 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1729 fprintf (f, " (TTE %lu)", value);
1734 fprintf (f, "pointer (0x%x) to ", type);
1735 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1740 unsigned long value;
1742 fprintf (f, "scalar (0x%x) of ", type);
1743 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1744 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1745 fprintf (f, " (%lu)", value);
1751 unsigned long lower, upper, nelem;
1754 fprintf (f, "enumeration (0x%x) of ", type);
1755 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1756 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1757 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1758 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1759 fprintf (f, " from %lu to %lu with %lu elements: ", lower, upper, nelem);
1761 for (i = 0; i < nelem; i++)
1764 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1770 fprintf (f, "vector (0x%x)", type);
1771 fprintf (f, "\n index ");
1772 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1773 fprintf (f, "\n target ");
1774 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1780 long nrec, eloff, i;
1782 if ((type & 0x3f) == 7)
1783 fprintf (f, "record (0x%x) of ", type);
1785 fprintf (f, "union (0x%x) of ", type);
1787 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1788 fprintf (f, "%lu elements: ", nrec);
1790 for (i = 0; i < nrec; i++)
1792 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1794 fprintf (f, "offset %lu: ", eloff);
1795 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1801 fprintf (f, "subrange (0x%x) of ", type);
1802 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1803 fprintf (f, " lower ");
1804 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1805 fprintf (f, " upper ");
1806 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1813 fprintf (f, "named type (0x%x) ", type);
1814 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1816 fprintf (f, "[INVALID]");
1818 fprintf (f, "\"%.*s\"",
1819 bfd_sym_symbol_name (abfd, value)[0],
1820 &bfd_sym_symbol_name (abfd, value)[1]);
1822 fprintf (f, " (NTE %lu) with type ", value);
1823 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1828 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1832 if (type == (0x40 | 0x6))
1839 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1840 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1841 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1842 /* fprintf (f, "\n "); */
1843 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1844 for (i = 0; i < m; i++)
1846 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1849 fprintf (f, "%ld", l);
1852 else if (type & 0x40)
1854 /* Other packed type. */
1857 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1858 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1859 /* fprintf (f, "\n "); */
1860 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1865 if (offsetptr != NULL)
1866 *offsetptr = offset;
1870 bfd_sym_print_type_information_table_entry (abfd, f, entry)
1873 bfd_sym_type_information_table_entry *entry;
1876 unsigned long offset;
1879 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1880 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1881 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1883 entry->physical_size, entry->offset, entry->logical_size);
1887 buf = alloca (entry->physical_size);
1890 fprintf (f, "[ERROR]\n");
1893 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1895 fprintf (f, "[ERROR]\n");
1898 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1900 fprintf (f, "[ERROR]\n");
1905 for (i = 0; i < entry->physical_size; i++)
1908 fprintf (f, "0x%02x", buf[i]);
1910 fprintf (f, " 0x%02x", buf[i]);
1916 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1918 if (offset != entry->physical_size)
1919 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); }
1922 bfd_sym_print_file_references_index_table_entry (abfd, f, entry)
1923 bfd *abfd ATTRIBUTE_UNUSED;
1925 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED;
1927 fprintf (f, "[UNIMPLEMENTED]");
1931 bfd_sym_print_constant_pool_entry (abfd, f, entry)
1932 bfd *abfd ATTRIBUTE_UNUSED;
1934 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED;
1936 fprintf (f, "[UNIMPLEMENTED]");
1940 bfd_sym_display_name_table_entry (abfd, f, entry)
1943 unsigned char *entry;
1945 unsigned long index;
1946 unsigned long offset;
1947 bfd_sym_data_struct *sdata = NULL;
1949 BFD_ASSERT (bfd_sym_valid (abfd));
1950 sdata = abfd->tdata.sym_data;
1951 index = (entry - sdata->name_table) / 2;
1953 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1955 unsigned short length = bfd_getb16 (entry + 2);
1956 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
1957 offset = 2 + length + 1;
1961 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1962 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
1964 if (sdata->version >= BFD_SYM_VERSION_3_4)
1965 offset = entry[0] + 2;
1967 offset = entry[0] + 1;
1970 return (entry + offset + (offset % 2));
1974 bfd_sym_display_name_table (abfd, f)
1978 unsigned long name_table_len;
1979 unsigned char *name_table, *name_table_end, *cur;
1980 bfd_sym_data_struct *sdata = NULL;
1982 BFD_ASSERT (bfd_sym_valid (abfd));
1983 sdata = abfd->tdata.sym_data;
1985 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1986 name_table = sdata->name_table;
1987 name_table_end = name_table + name_table_len;
1989 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1994 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1995 if (cur >= name_table_end)
2001 bfd_sym_display_resources_table (abfd, f)
2006 bfd_sym_resources_table_entry entry;
2007 bfd_sym_data_struct *sdata = NULL;
2009 BFD_ASSERT (bfd_sym_valid (abfd));
2010 sdata = abfd->tdata.sym_data;
2012 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
2013 sdata->header.dshb_rte.dti_object_count);
2015 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
2017 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
2018 fprintf (f, " [%8lu] [INVALID]\n", i);
2021 fprintf (f, " [%8lu] ", i);
2022 bfd_sym_print_resources_table_entry (abfd, f, &entry);
2029 bfd_sym_display_modules_table (abfd, f)
2034 bfd_sym_modules_table_entry entry;
2035 bfd_sym_data_struct *sdata = NULL;
2037 BFD_ASSERT (bfd_sym_valid (abfd));
2038 sdata = abfd->tdata.sym_data;
2040 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
2041 sdata->header.dshb_mte.dti_object_count);
2043 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
2045 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
2046 fprintf (f, " [%8lu] [INVALID]\n", i);
2049 fprintf (f, " [%8lu] ", i);
2050 bfd_sym_print_modules_table_entry (abfd, f, &entry);
2057 bfd_sym_display_file_references_table (abfd, f)
2062 bfd_sym_file_references_table_entry entry;
2063 bfd_sym_data_struct *sdata = NULL;
2065 BFD_ASSERT (bfd_sym_valid (abfd));
2066 sdata = abfd->tdata.sym_data;
2068 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
2069 sdata->header.dshb_frte.dti_object_count);
2071 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
2073 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
2074 fprintf (f, " [%8lu] [INVALID]\n", i);
2077 fprintf (f, " [%8lu] ", i);
2078 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
2085 bfd_sym_display_contained_modules_table (abfd, f)
2090 bfd_sym_contained_modules_table_entry entry;
2091 bfd_sym_data_struct *sdata = NULL;
2093 BFD_ASSERT (bfd_sym_valid (abfd));
2094 sdata = abfd->tdata.sym_data;
2096 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
2097 sdata->header.dshb_cmte.dti_object_count);
2099 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2101 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
2102 fprintf (f, " [%8lu] [INVALID]\n", i);
2105 fprintf (f, " [%8lu] ", i);
2106 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
2113 bfd_sym_display_contained_variables_table (abfd, f)
2118 bfd_sym_contained_variables_table_entry entry;
2119 bfd_sym_data_struct *sdata = NULL;
2121 BFD_ASSERT (bfd_sym_valid (abfd));
2122 sdata = abfd->tdata.sym_data;
2124 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2125 sdata->header.dshb_cvte.dti_object_count);
2127 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2129 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2130 fprintf (f, " [%8lu] [INVALID]\n", i);
2133 fprintf (f, " [%8lu] ", i);
2134 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2143 bfd_sym_display_contained_statements_table (abfd, f)
2148 bfd_sym_contained_statements_table_entry entry;
2149 bfd_sym_data_struct *sdata = NULL;
2151 BFD_ASSERT (bfd_sym_valid (abfd));
2152 sdata = abfd->tdata.sym_data;
2154 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
2155 sdata->header.dshb_csnte.dti_object_count);
2157 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2159 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
2160 fprintf (f, " [%8lu] [INVALID]\n", i);
2163 fprintf (f, " [%8lu] ", i);
2164 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
2171 bfd_sym_display_contained_labels_table (abfd, f)
2176 bfd_sym_contained_labels_table_entry entry;
2177 bfd_sym_data_struct *sdata = NULL;
2179 BFD_ASSERT (bfd_sym_valid (abfd));
2180 sdata = abfd->tdata.sym_data;
2182 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
2183 sdata->header.dshb_clte.dti_object_count);
2185 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2187 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
2188 fprintf (f, " [%8lu] [INVALID]\n", i);
2191 fprintf (f, " [%8lu] ", i);
2192 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
2199 bfd_sym_display_contained_types_table (abfd, f)
2204 bfd_sym_contained_types_table_entry entry;
2205 bfd_sym_data_struct *sdata = NULL;
2207 BFD_ASSERT (bfd_sym_valid (abfd));
2208 sdata = abfd->tdata.sym_data;
2210 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
2211 sdata->header.dshb_ctte.dti_object_count);
2213 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2215 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2216 fprintf (f, " [%8lu] [INVALID]\n", i);
2219 fprintf (f, " [%8lu] ", i);
2220 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2227 bfd_sym_display_file_references_index_table (abfd, f)
2232 bfd_sym_file_references_index_table_entry entry;
2233 bfd_sym_data_struct *sdata = NULL;
2235 BFD_ASSERT (bfd_sym_valid (abfd));
2236 sdata = abfd->tdata.sym_data;
2238 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
2239 sdata->header.dshb_fite.dti_object_count);
2241 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2243 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2244 fprintf (f, " [%8lu] [INVALID]\n", i);
2247 fprintf (f, " [%8lu] ", i);
2248 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2255 bfd_sym_display_constant_pool (abfd, f)
2260 bfd_sym_constant_pool_entry entry;
2261 bfd_sym_data_struct *sdata = NULL;
2263 BFD_ASSERT (bfd_sym_valid (abfd));
2264 sdata = abfd->tdata.sym_data;
2266 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2267 sdata->header.dshb_const.dti_object_count);
2269 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2271 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2272 fprintf (f, " [%8lu] [INVALID]\n", i);
2275 fprintf (f, " [%8lu] ", i);
2276 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2283 bfd_sym_display_type_information_table (abfd, f)
2288 bfd_sym_type_table_entry index;
2289 bfd_sym_type_information_table_entry entry;
2290 bfd_sym_data_struct *sdata = NULL;
2292 BFD_ASSERT (bfd_sym_valid (abfd));
2293 sdata = abfd->tdata.sym_data;
2295 if (sdata->header.dshb_tte.dti_object_count > 99)
2296 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2297 sdata->header.dshb_tte.dti_object_count - 99);
2300 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2304 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2306 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
2307 fprintf (f, " [%8lu] [INVALID]\n", i);
2310 fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
2312 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
2313 fprintf (f, "[INVALID]");
2315 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2323 bfd_sym_scan (abfd, version, mdata)
2325 bfd_sym_version version;
2326 bfd_sym_data_struct *mdata;
2329 const char *name = "symbols";
2331 mdata->name_table = 0;
2333 mdata->version = version;
2335 bfd_seek (abfd, 0, SEEK_SET);
2336 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2339 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2340 if (mdata->name_table == NULL)
2343 bfdsec = bfd_make_section_anyway (abfd, name);
2350 bfdsec->filepos = 0;
2351 bfdsec->alignment_power = 0;
2353 bfdsec->flags = SEC_HAS_CONTENTS;
2355 abfd->tdata.sym_data = mdata;
2361 bfd_sym_object_p (abfd)
2364 struct bfd_preserve preserve;
2365 bfd_sym_version version = -1;
2367 preserve.marker = NULL;
2368 bfd_seek (abfd, 0, SEEK_SET);
2369 if (bfd_sym_read_version (abfd, &version) != 0)
2372 preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
2373 if (preserve.marker == NULL
2374 || ! bfd_preserve_save (abfd, &preserve))
2377 if (bfd_sym_scan (abfd, version,
2378 (bfd_sym_data_struct *) preserve.marker) != 0)
2381 bfd_preserve_finish (abfd, &preserve);
2385 bfd_set_error (bfd_error_wrong_format);
2388 if (preserve.marker != NULL)
2389 bfd_preserve_restore (abfd, &preserve);
2394 bfd_sym_make_empty_symbol (abfd)
2397 return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
2401 bfd_sym_get_symbol_info (abfd, symbol, ret)
2402 bfd *abfd ATTRIBUTE_UNUSED;
2406 bfd_symbol_info (symbol, ret);
2410 bfd_sym_get_symtab_upper_bound (abfd)
2411 bfd *abfd ATTRIBUTE_UNUSED;
2417 bfd_sym_canonicalize_symtab (abfd, sym)
2418 bfd *abfd ATTRIBUTE_UNUSED;
2419 asymbol **sym ATTRIBUTE_UNUSED;
2425 bfd_sym_sizeof_headers (abfd, exec)
2426 bfd *abfd ATTRIBUTE_UNUSED;
2427 bfd_boolean exec ATTRIBUTE_UNUSED;
2432 const bfd_target sym_vec =
2435 bfd_target_sym_flavour, /* flavour */
2436 BFD_ENDIAN_BIG, /* byteorder */
2437 BFD_ENDIAN_BIG, /* header_byteorder */
2438 (HAS_RELOC | EXEC_P | /* object flags */
2439 HAS_LINENO | HAS_DEBUG |
2440 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2441 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2442 | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
2443 0, /* symbol_leading_char */
2444 ' ', /* ar_pad_char */
2445 16, /* ar_max_namelen */
2446 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2447 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2448 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
2449 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2450 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2451 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
2452 { /* bfd_check_format */
2454 bfd_sym_object_p, /* bfd_check_format */
2458 { /* bfd_set_format */
2464 { /* bfd_write_contents */
2471 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2472 BFD_JUMP_TABLE_COPY (_bfd_generic),
2473 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2474 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2475 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2476 BFD_JUMP_TABLE_RELOCS (bfd_sym),
2477 BFD_JUMP_TABLE_WRITE (bfd_sym),
2478 BFD_JUMP_TABLE_LINK (bfd_sym),
2479 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),