1 /* xSYM symbol-file support for BFD.
2 Copyright (C) 1999-2018 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
21 /* xSYM is the debugging format used by CodeWarrior on Mac OS classic. */
24 #include "alloca-conf.h"
29 #define bfd_sym_close_and_cleanup _bfd_generic_close_and_cleanup
30 #define bfd_sym_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
31 #define bfd_sym_new_section_hook _bfd_generic_new_section_hook
32 #define bfd_sym_bfd_is_local_label_name bfd_generic_is_local_label_name
33 #define bfd_sym_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false_any)
34 #define bfd_sym_get_lineno _bfd_nosymbols_get_lineno
35 #define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line
36 #define bfd_sym_find_line _bfd_nosymbols_find_line
37 #define bfd_sym_find_inliner_info _bfd_nosymbols_find_inliner_info
38 #define bfd_sym_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string
39 #define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
40 #define bfd_sym_read_minisymbols _bfd_generic_read_minisymbols
41 #define bfd_sym_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
42 #define bfd_sym_set_arch_mach _bfd_generic_set_arch_mach
43 #define bfd_sym_get_section_contents _bfd_generic_get_section_contents
44 #define bfd_sym_set_section_contents _bfd_generic_set_section_contents
45 #define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
46 #define bfd_sym_bfd_relax_section bfd_generic_relax_section
47 #define bfd_sym_bfd_gc_sections bfd_generic_gc_sections
48 #define bfd_sym_bfd_lookup_section_flags bfd_generic_lookup_section_flags
49 #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections
50 #define bfd_sym_bfd_is_group_section bfd_generic_is_group_section
51 #define bfd_sym_bfd_discard_group bfd_generic_discard_group
52 #define bfd_sym_section_already_linked _bfd_generic_section_already_linked
53 #define bfd_sym_bfd_define_common_symbol bfd_generic_define_common_symbol
54 #define bfd_sym_bfd_define_start_stop bfd_generic_define_start_stop
55 #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
56 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
57 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
58 #define bfd_sym_bfd_copy_link_hash_symbol_type \
59 _bfd_generic_copy_link_hash_symbol_type
60 #define bfd_sym_bfd_final_link _bfd_generic_final_link
61 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
62 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
63 #define bfd_sym_bfd_link_check_relocs _bfd_generic_link_check_relocs
65 extern const bfd_target sym_vec;
68 pstrcmp (const char *as, const char *bs)
70 const unsigned char *a = (const unsigned char *) as;
71 const unsigned char *b = (const unsigned char *) bs;
75 clen = (a[0] > b[0]) ? b[0] : a[0];
76 ret = memcmp (a + 1, b + 1, clen);
89 compute_offset (unsigned long first_page,
90 unsigned long page_size,
91 unsigned long entry_size,
92 unsigned long sym_index)
94 unsigned long entries_per_page = page_size / entry_size;
95 unsigned long page_number = first_page + (sym_index / entries_per_page);
96 unsigned long page_offset = (sym_index % entries_per_page) * entry_size;
98 return (page_number * page_size) + page_offset;
102 bfd_sym_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
108 bfd_sym_print_symbol (bfd *abfd ATTRIBUTE_UNUSED,
109 void * afile ATTRIBUTE_UNUSED,
110 asymbol *symbol ATTRIBUTE_UNUSED,
111 bfd_print_symbol_type how ATTRIBUTE_UNUSED)
117 bfd_sym_valid (bfd *abfd)
119 if (abfd == NULL || abfd->xvec == NULL)
122 return abfd->xvec == &sym_vec;
126 bfd_sym_read_name_table (bfd *abfd, 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 = 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 (unsigned char *buf,
151 bfd_sym_file_reference *entry)
153 BFD_ASSERT (len == 6);
155 entry->fref_frte_index = bfd_getb16 (buf);
156 entry->fref_offset = bfd_getb32 (buf + 2);
160 bfd_sym_parse_disk_table_v32 (unsigned char *buf,
162 bfd_sym_table_info *table)
164 BFD_ASSERT (len == 8);
166 table->dti_first_page = bfd_getb16 (buf);
167 table->dti_page_count = bfd_getb16 (buf + 2);
168 table->dti_object_count = bfd_getb32 (buf + 4);
172 bfd_sym_parse_header_v32 (unsigned char *buf,
174 bfd_sym_header_block *header)
176 BFD_ASSERT (len == 154);
178 memcpy (header->dshb_id, buf, 32);
179 header->dshb_page_size = bfd_getb16 (buf + 32);
180 header->dshb_hash_page = bfd_getb16 (buf + 34);
181 header->dshb_root_mte = bfd_getb16 (buf + 36);
182 header->dshb_mod_date = bfd_getb32 (buf + 38);
184 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
185 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
186 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
187 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
188 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
189 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
190 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
191 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
192 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
193 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
194 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
195 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
196 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
198 memcpy (&header->dshb_file_creator, buf + 146, 4);
199 memcpy (&header->dshb_file_type, buf + 150, 4);
203 bfd_sym_read_header_v32 (bfd *abfd, bfd_sym_header_block *header)
205 unsigned char buf[154];
208 ret = bfd_bread (buf, 154, abfd);
212 bfd_sym_parse_header_v32 (buf, 154, header);
218 bfd_sym_read_header_v34 (bfd *abfd ATTRIBUTE_UNUSED,
219 bfd_sym_header_block *header ATTRIBUTE_UNUSED)
225 bfd_sym_read_header (bfd *abfd,
226 bfd_sym_header_block *header,
227 bfd_sym_version version)
231 case BFD_SYM_VERSION_3_5:
232 case BFD_SYM_VERSION_3_4:
233 return bfd_sym_read_header_v34 (abfd, header);
234 case BFD_SYM_VERSION_3_3:
235 case BFD_SYM_VERSION_3_2:
236 return bfd_sym_read_header_v32 (abfd, header);
237 case BFD_SYM_VERSION_3_1:
244 bfd_sym_read_version (bfd *abfd, bfd_sym_version *version)
246 char version_string[32];
249 ret = bfd_bread (version_string, sizeof (version_string), abfd);
250 if (ret != sizeof (version_string))
253 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
254 *version = BFD_SYM_VERSION_3_1;
255 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
256 *version = BFD_SYM_VERSION_3_2;
257 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
258 *version = BFD_SYM_VERSION_3_3;
259 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
260 *version = BFD_SYM_VERSION_3_4;
261 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
262 *version = BFD_SYM_VERSION_3_5;
270 bfd_sym_display_table_summary (FILE *f,
271 bfd_sym_table_info *dti,
274 fprintf (f, "%-6s %13ld %13ld %13ld\n",
278 dti->dti_object_count);
282 bfd_sym_display_header (FILE *f, bfd_sym_header_block *dshb)
284 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
285 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
286 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
287 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
288 fprintf (f, " Modification Date: ");
289 fprintf (f, "[unimplemented]");
290 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
292 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
293 dshb->dshb_file_creator, dshb->dshb_file_type);
295 fprintf (f, "Table Name First Page Page Count Object Count\n");
296 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
298 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
299 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
300 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
301 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
302 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
303 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
304 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
305 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
306 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
307 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
308 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
309 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
310 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
316 bfd_sym_parse_resources_table_entry_v32 (unsigned char *buf,
318 bfd_sym_resources_table_entry *entry)
320 BFD_ASSERT (len == 18);
322 memcpy (&entry->rte_res_type, buf, 4);
323 entry->rte_res_number = bfd_getb16 (buf + 4);
324 entry->rte_nte_index = bfd_getb32 (buf + 6);
325 entry->rte_mte_first = bfd_getb16 (buf + 10);
326 entry->rte_mte_last = bfd_getb16 (buf + 12);
327 entry->rte_res_size = bfd_getb32 (buf + 14);
331 bfd_sym_parse_modules_table_entry_v33 (unsigned char *buf,
333 bfd_sym_modules_table_entry *entry)
335 BFD_ASSERT (len == 46);
337 entry->mte_rte_index = bfd_getb16 (buf);
338 entry->mte_res_offset = bfd_getb32 (buf + 2);
339 entry->mte_size = bfd_getb32 (buf + 6);
340 entry->mte_kind = buf[10];
341 entry->mte_scope = buf[11];
342 entry->mte_parent = bfd_getb16 (buf + 12);
343 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
344 entry->mte_imp_end = bfd_getb32 (buf + 20);
345 entry->mte_nte_index = bfd_getb32 (buf + 24);
346 entry->mte_cmte_index = bfd_getb16 (buf + 28);
347 entry->mte_cvte_index = bfd_getb32 (buf + 30);
348 entry->mte_clte_index = bfd_getb16 (buf + 34);
349 entry->mte_ctte_index = bfd_getb16 (buf + 36);
350 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
351 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
355 bfd_sym_parse_file_references_table_entry_v32 (unsigned char *buf,
357 bfd_sym_file_references_table_entry *entry)
361 BFD_ASSERT (len == 10);
363 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
364 type = bfd_getb16 (buf);
368 case BFD_SYM_END_OF_LIST_3_2:
369 entry->generic.type = BFD_SYM_END_OF_LIST;
372 case BFD_SYM_FILE_NAME_INDEX_3_2:
373 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
374 entry->filename.nte_index = bfd_getb32 (buf + 2);
375 entry->filename.mod_date = bfd_getb32 (buf + 6);
379 entry->entry.mte_index = type;
380 entry->entry.file_offset = bfd_getb32 (buf + 2);
385 bfd_sym_parse_contained_modules_table_entry_v32 (unsigned char *buf,
387 bfd_sym_contained_modules_table_entry *entry)
391 BFD_ASSERT (len == 6);
393 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
394 type = bfd_getb16 (buf);
398 case BFD_SYM_END_OF_LIST_3_2:
399 entry->generic.type = BFD_SYM_END_OF_LIST;
403 entry->entry.mte_index = type;
404 entry->entry.nte_index = bfd_getb32 (buf + 2);
410 bfd_sym_parse_contained_variables_table_entry_v32 (unsigned char *buf,
412 bfd_sym_contained_variables_table_entry *entry)
416 BFD_ASSERT (len == 26);
418 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
419 type = bfd_getb16 (buf);
423 case BFD_SYM_END_OF_LIST_3_2:
424 entry->generic.type = BFD_SYM_END_OF_LIST;
427 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
428 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
429 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
433 entry->entry.tte_index = type;
434 entry->entry.nte_index = bfd_getb32 (buf + 2);
435 entry->entry.file_delta = bfd_getb16 (buf + 6);
436 entry->entry.scope = buf[8];
437 entry->entry.la_size = buf[9];
439 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
441 entry->entry.address.scstruct.sca_kind = buf[10];
442 entry->entry.address.scstruct.sca_class = buf[11];
443 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
445 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
447 #if BFD_SYM_CVTE_SCA > 0
448 memcpy (&entry->entry.address.lastruct.la, buf + 10,
451 entry->entry.address.lastruct.la_kind = buf[23];
453 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
455 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
456 entry->entry.address.biglastruct.big_la_kind = buf[12];
462 bfd_sym_parse_contained_statements_table_entry_v32 (unsigned char *buf,
464 bfd_sym_contained_statements_table_entry *entry)
468 BFD_ASSERT (len == 8);
470 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
471 type = bfd_getb16 (buf);
475 case BFD_SYM_END_OF_LIST_3_2:
476 entry->generic.type = BFD_SYM_END_OF_LIST;
479 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
480 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
481 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
485 entry->entry.mte_index = type;
486 entry->entry.mte_offset = bfd_getb16 (buf + 2);
487 entry->entry.file_delta = bfd_getb32 (buf + 4);
493 bfd_sym_parse_contained_labels_table_entry_v32 (unsigned char *buf,
495 bfd_sym_contained_labels_table_entry *entry)
499 BFD_ASSERT (len == 12);
501 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
502 type = bfd_getb16 (buf);
506 case BFD_SYM_END_OF_LIST_3_2:
507 entry->generic.type = BFD_SYM_END_OF_LIST;
510 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
511 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
512 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
516 entry->entry.mte_index = type;
517 entry->entry.mte_offset = bfd_getb16 (buf + 2);
518 entry->entry.nte_index = bfd_getb32 (buf + 4);
519 entry->entry.file_delta = bfd_getb16 (buf + 8);
520 entry->entry.scope = bfd_getb16 (buf + 10);
526 bfd_sym_parse_type_table_entry_v32 (unsigned char *buf,
528 bfd_sym_type_table_entry *entry)
530 BFD_ASSERT (len == 4);
532 *entry = bfd_getb32 (buf);
536 bfd_sym_fetch_resources_table_entry (bfd *abfd,
537 bfd_sym_resources_table_entry *entry,
538 unsigned long sym_index)
540 void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *);
541 unsigned long offset;
542 unsigned long entry_size;
543 unsigned char buf[18];
544 bfd_sym_data_struct *sdata = NULL;
547 BFD_ASSERT (bfd_sym_valid (abfd));
548 sdata = abfd->tdata.sym_data;
553 switch (sdata->version)
555 case BFD_SYM_VERSION_3_5:
556 case BFD_SYM_VERSION_3_4:
559 case BFD_SYM_VERSION_3_3:
560 case BFD_SYM_VERSION_3_2:
562 parser = bfd_sym_parse_resources_table_entry_v32;
565 case BFD_SYM_VERSION_3_1:
572 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
573 sdata->header.dshb_page_size,
574 entry_size, sym_index);
576 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
578 if (bfd_bread (buf, entry_size, abfd) != entry_size)
581 (*parser) (buf, entry_size, entry);
587 bfd_sym_fetch_modules_table_entry (bfd *abfd,
588 bfd_sym_modules_table_entry *entry,
589 unsigned long sym_index)
591 void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *);
592 unsigned long offset;
593 unsigned long entry_size;
594 unsigned char buf[46];
595 bfd_sym_data_struct *sdata = NULL;
598 BFD_ASSERT (bfd_sym_valid (abfd));
599 sdata = abfd->tdata.sym_data;
604 switch (sdata->version)
606 case BFD_SYM_VERSION_3_5:
607 case BFD_SYM_VERSION_3_4:
610 case BFD_SYM_VERSION_3_3:
612 parser = bfd_sym_parse_modules_table_entry_v33;
615 case BFD_SYM_VERSION_3_2:
616 case BFD_SYM_VERSION_3_1:
623 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
624 sdata->header.dshb_page_size,
625 entry_size, sym_index);
627 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
629 if (bfd_bread (buf, entry_size, abfd) != entry_size)
632 (*parser) (buf, entry_size, entry);
638 bfd_sym_fetch_file_references_table_entry (bfd *abfd,
639 bfd_sym_file_references_table_entry *entry,
640 unsigned long sym_index)
642 void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *);
643 unsigned long offset;
644 unsigned long entry_size = 0;
645 unsigned char buf[8];
646 bfd_sym_data_struct *sdata = NULL;
649 BFD_ASSERT (bfd_sym_valid (abfd));
650 sdata = abfd->tdata.sym_data;
655 switch (sdata->version)
657 case BFD_SYM_VERSION_3_3:
658 case BFD_SYM_VERSION_3_2:
660 parser = bfd_sym_parse_file_references_table_entry_v32;
663 case BFD_SYM_VERSION_3_5:
664 case BFD_SYM_VERSION_3_4:
665 case BFD_SYM_VERSION_3_1:
673 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
674 sdata->header.dshb_page_size,
675 entry_size, sym_index);
677 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
679 if (bfd_bread (buf, entry_size, abfd) != entry_size)
682 (*parser) (buf, entry_size, entry);
688 bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
689 bfd_sym_contained_modules_table_entry *entry,
690 unsigned long sym_index)
692 void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *);
693 unsigned long offset;
694 unsigned long entry_size = 0;
695 unsigned char buf[6];
696 bfd_sym_data_struct *sdata = NULL;
699 BFD_ASSERT (bfd_sym_valid (abfd));
700 sdata = abfd->tdata.sym_data;
705 switch (sdata->version)
707 case BFD_SYM_VERSION_3_3:
708 case BFD_SYM_VERSION_3_2:
710 parser = bfd_sym_parse_contained_modules_table_entry_v32;
713 case BFD_SYM_VERSION_3_5:
714 case BFD_SYM_VERSION_3_4:
715 case BFD_SYM_VERSION_3_1:
723 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
724 sdata->header.dshb_page_size,
725 entry_size, sym_index);
727 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
729 if (bfd_bread (buf, entry_size, abfd) != entry_size)
732 (*parser) (buf, entry_size, entry);
738 bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
739 bfd_sym_contained_variables_table_entry *entry,
740 unsigned long sym_index)
742 void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *);
743 unsigned long offset;
744 unsigned long entry_size = 0;
745 unsigned char buf[26];
746 bfd_sym_data_struct *sdata = NULL;
749 BFD_ASSERT (bfd_sym_valid (abfd));
750 sdata = abfd->tdata.sym_data;
755 switch (sdata->version)
757 case BFD_SYM_VERSION_3_3:
758 case BFD_SYM_VERSION_3_2:
760 parser = bfd_sym_parse_contained_variables_table_entry_v32;
763 case BFD_SYM_VERSION_3_5:
764 case BFD_SYM_VERSION_3_4:
765 case BFD_SYM_VERSION_3_1:
773 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
774 sdata->header.dshb_page_size,
775 entry_size, sym_index);
777 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
779 if (bfd_bread (buf, entry_size, abfd) != entry_size)
782 (*parser) (buf, entry_size, entry);
788 bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
789 bfd_sym_contained_statements_table_entry *entry,
790 unsigned long sym_index)
792 void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *);
793 unsigned long offset;
794 unsigned long entry_size = 0;
795 unsigned char buf[8];
796 bfd_sym_data_struct *sdata = NULL;
799 BFD_ASSERT (bfd_sym_valid (abfd));
800 sdata = abfd->tdata.sym_data;
805 switch (sdata->version)
807 case BFD_SYM_VERSION_3_3:
808 case BFD_SYM_VERSION_3_2:
810 parser = bfd_sym_parse_contained_statements_table_entry_v32;
813 case BFD_SYM_VERSION_3_5:
814 case BFD_SYM_VERSION_3_4:
815 case BFD_SYM_VERSION_3_1:
823 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
824 sdata->header.dshb_page_size,
825 entry_size, sym_index);
827 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
829 if (bfd_bread (buf, entry_size, abfd) != entry_size)
832 (*parser) (buf, entry_size, entry);
838 bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
839 bfd_sym_contained_labels_table_entry *entry,
840 unsigned long sym_index)
842 void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *);
843 unsigned long offset;
844 unsigned long entry_size = 0;
845 unsigned char buf[12];
846 bfd_sym_data_struct *sdata = NULL;
849 BFD_ASSERT (bfd_sym_valid (abfd));
850 sdata = abfd->tdata.sym_data;
855 switch (sdata->version)
857 case BFD_SYM_VERSION_3_3:
858 case BFD_SYM_VERSION_3_2:
860 parser = bfd_sym_parse_contained_labels_table_entry_v32;
863 case BFD_SYM_VERSION_3_5:
864 case BFD_SYM_VERSION_3_4:
865 case BFD_SYM_VERSION_3_1:
873 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
874 sdata->header.dshb_page_size,
875 entry_size, sym_index);
877 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
879 if (bfd_bread (buf, entry_size, abfd) != entry_size)
882 (*parser) (buf, entry_size, entry);
888 bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
889 bfd_sym_contained_types_table_entry *entry,
890 unsigned long sym_index)
892 void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *);
893 unsigned long offset;
894 unsigned long entry_size = 0;
895 unsigned char buf[0];
896 bfd_sym_data_struct *sdata = NULL;
899 BFD_ASSERT (bfd_sym_valid (abfd));
900 sdata = abfd->tdata.sym_data;
905 switch (sdata->version)
907 case BFD_SYM_VERSION_3_3:
908 case BFD_SYM_VERSION_3_2:
913 case BFD_SYM_VERSION_3_5:
914 case BFD_SYM_VERSION_3_4:
915 case BFD_SYM_VERSION_3_1:
923 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
924 sdata->header.dshb_page_size,
925 entry_size, sym_index);
927 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
929 if (bfd_bread (buf, entry_size, abfd) != entry_size)
932 (*parser) (buf, entry_size, entry);
938 bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
939 bfd_sym_file_references_index_table_entry *entry,
940 unsigned long sym_index)
942 void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *);
943 unsigned long offset;
944 unsigned long entry_size = 0;
945 unsigned char buf[0];
946 bfd_sym_data_struct *sdata = NULL;
949 BFD_ASSERT (bfd_sym_valid (abfd));
950 sdata = abfd->tdata.sym_data;
955 switch (sdata->version)
957 case BFD_SYM_VERSION_3_3:
958 case BFD_SYM_VERSION_3_2:
963 case BFD_SYM_VERSION_3_5:
964 case BFD_SYM_VERSION_3_4:
965 case BFD_SYM_VERSION_3_1:
973 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
974 sdata->header.dshb_page_size,
975 entry_size, sym_index);
977 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
979 if (bfd_bread (buf, entry_size, abfd) != entry_size)
982 (*parser) (buf, entry_size, entry);
988 bfd_sym_fetch_constant_pool_entry (bfd *abfd,
989 bfd_sym_constant_pool_entry *entry,
990 unsigned long sym_index)
992 void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *);
993 unsigned long offset;
994 unsigned long entry_size = 0;
995 unsigned char buf[0];
996 bfd_sym_data_struct *sdata = NULL;
999 BFD_ASSERT (bfd_sym_valid (abfd));
1000 sdata = abfd->tdata.sym_data;
1005 switch (sdata->version)
1007 case BFD_SYM_VERSION_3_3:
1008 case BFD_SYM_VERSION_3_2:
1013 case BFD_SYM_VERSION_3_5:
1014 case BFD_SYM_VERSION_3_4:
1015 case BFD_SYM_VERSION_3_1:
1023 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1024 sdata->header.dshb_page_size,
1025 entry_size, sym_index);
1027 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1029 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1032 (*parser) (buf, entry_size, entry);
1038 bfd_sym_fetch_type_table_entry (bfd *abfd,
1039 bfd_sym_type_table_entry *entry,
1040 unsigned long sym_index)
1042 void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *);
1043 unsigned long offset;
1044 unsigned long entry_size = 0;
1045 unsigned char buf[4];
1046 bfd_sym_data_struct *sdata = NULL;
1049 BFD_ASSERT (bfd_sym_valid (abfd));
1050 sdata = abfd->tdata.sym_data;
1052 switch (sdata->version)
1054 case BFD_SYM_VERSION_3_3:
1055 case BFD_SYM_VERSION_3_2:
1057 parser = bfd_sym_parse_type_table_entry_v32;
1060 case BFD_SYM_VERSION_3_5:
1061 case BFD_SYM_VERSION_3_4:
1062 case BFD_SYM_VERSION_3_1:
1070 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1071 sdata->header.dshb_page_size,
1072 entry_size, sym_index);
1074 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1076 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1079 (*parser) (buf, entry_size, entry);
1085 bfd_sym_fetch_type_information_table_entry (bfd *abfd,
1086 bfd_sym_type_information_table_entry *entry,
1087 unsigned long offset)
1089 unsigned char buf[4];
1091 BFD_ASSERT (bfd_sym_valid (abfd));
1096 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1099 if (bfd_bread (buf, 4, abfd) != 4)
1101 entry->nte_index = bfd_getb32 (buf);
1103 if (bfd_bread (buf, 2, abfd) != 2)
1105 entry->physical_size = bfd_getb16 (buf);
1107 if (entry->physical_size & 0x8000)
1109 if (bfd_bread (buf, 4, abfd) != 4)
1111 entry->physical_size &= 0x7fff;
1112 entry->logical_size = bfd_getb32 (buf);
1113 entry->offset = offset + 10;
1117 if (bfd_bread (buf, 2, abfd) != 2)
1119 entry->physical_size &= 0x7fff;
1120 entry->logical_size = bfd_getb16 (buf);
1121 entry->offset = offset + 8;
1128 bfd_sym_fetch_type_table_information (bfd *abfd,
1129 bfd_sym_type_information_table_entry *entry,
1130 unsigned long sym_index)
1132 bfd_sym_type_table_entry tindex;
1133 bfd_sym_data_struct *sdata = NULL;
1135 BFD_ASSERT (bfd_sym_valid (abfd));
1136 sdata = abfd->tdata.sym_data;
1138 if (sdata->header.dshb_tte.dti_object_count <= 99)
1140 if (sym_index < 100)
1143 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, sym_index - 100) < 0)
1145 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1151 const unsigned char *
1152 bfd_sym_symbol_name (bfd *abfd, unsigned long sym_index)
1154 bfd_sym_data_struct *sdata = NULL;
1156 BFD_ASSERT (bfd_sym_valid (abfd));
1157 sdata = abfd->tdata.sym_data;
1160 return (const unsigned char *) "";
1163 if ((sym_index / sdata->header.dshb_page_size)
1164 > sdata->header.dshb_nte.dti_page_count)
1165 return (const unsigned char *) "\09[INVALID]";
1167 return (const unsigned char *) sdata->name_table + sym_index;
1170 const unsigned char *
1171 bfd_sym_module_name (bfd *abfd, unsigned long sym_index)
1173 bfd_sym_modules_table_entry entry;
1175 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, sym_index) < 0)
1176 return (const unsigned char *) "\09[INVALID]";
1178 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1182 bfd_sym_unparse_storage_kind (enum bfd_sym_storage_kind kind)
1186 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1187 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1188 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1189 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1190 default: return "[UNKNOWN]";
1195 bfd_sym_unparse_storage_class (enum bfd_sym_storage_class kind)
1199 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1200 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1201 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1202 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1203 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1204 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1205 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1206 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1207 default: return "[UNKNOWN]";
1212 bfd_sym_unparse_module_kind (enum bfd_sym_module_kind kind)
1216 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1217 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1218 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1219 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1220 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1221 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1222 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1223 default: return "[UNKNOWN]";
1228 bfd_sym_unparse_symbol_scope (enum bfd_sym_symbol_scope scope)
1232 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1233 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1240 bfd_sym_print_file_reference (bfd *abfd,
1242 bfd_sym_file_reference *entry)
1244 bfd_sym_file_references_table_entry frtentry;
1247 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1248 entry->fref_frte_index);
1249 fprintf (f, "FILE ");
1251 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1252 fprintf (f, "[INVALID]");
1254 fprintf (f, "\"%.*s\"",
1255 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1256 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1258 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1262 bfd_sym_print_resources_table_entry (bfd *abfd,
1264 bfd_sym_resources_table_entry *entry)
1266 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1267 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1268 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1269 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1270 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1274 bfd_sym_print_modules_table_entry (bfd *abfd,
1276 bfd_sym_modules_table_entry *entry)
1278 fprintf (f, "\"%.*s\" (NTE %lu)",
1279 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1280 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1281 entry->mte_nte_index);
1285 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1286 fprintf (f, " range %lu -- %lu",
1287 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1291 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1292 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1294 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1295 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1299 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1300 entry->mte_cmte_index, entry->mte_cvte_index,
1301 entry->mte_clte_index, entry->mte_ctte_index,
1302 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1304 if (entry->mte_parent != 0)
1305 fprintf (f, ", parent %lu", entry->mte_parent);
1307 fprintf (f, ", no parent");
1309 if (entry->mte_cmte_index != 0)
1310 fprintf (f, ", child %lu", entry->mte_cmte_index);
1312 fprintf (f, ", no child");
1316 bfd_sym_print_file_references_table_entry (bfd *abfd,
1318 bfd_sym_file_references_table_entry *entry)
1320 switch (entry->generic.type)
1322 case BFD_SYM_FILE_NAME_INDEX:
1323 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1324 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1325 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1326 entry->filename.nte_index);
1328 fprintf (f, "[UNIMPLEMENTED]");
1329 /* printModDate (entry->filename.mod_date); */
1330 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1333 case BFD_SYM_END_OF_LIST:
1338 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1339 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1340 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1341 entry->entry.mte_index,
1342 entry->entry.file_offset);
1348 bfd_sym_print_contained_modules_table_entry (bfd *abfd,
1350 bfd_sym_contained_modules_table_entry *entry)
1352 switch (entry->generic.type)
1354 case BFD_SYM_END_OF_LIST:
1359 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
1360 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1361 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1362 entry->entry.mte_index,
1363 entry->entry.nte_index);
1369 bfd_sym_print_contained_variables_table_entry (bfd *abfd,
1371 bfd_sym_contained_variables_table_entry *entry)
1373 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1379 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1381 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1382 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1386 fprintf (f, "\"%.*s\" (NTE %lu)",
1387 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1388 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1389 entry->entry.nte_index);
1391 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1392 fprintf (f, ", offset %lu", entry->entry.file_delta);
1393 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1395 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1396 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1397 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1398 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1399 entry->entry.address.scstruct.sca_offset);
1400 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1404 fprintf (f, ", la [");
1405 for (i = 0; i < entry->entry.la_size; i++)
1406 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1409 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1410 fprintf (f, ", bigla %lu, biglakind %u",
1411 entry->entry.address.biglastruct.big_la,
1412 entry->entry.address.biglastruct.big_la_kind);
1415 fprintf (f, ", la [INVALID]");
1419 bfd_sym_print_contained_statements_table_entry (bfd *abfd,
1421 bfd_sym_contained_statements_table_entry *entry)
1423 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1429 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1431 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1432 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1436 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1437 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1438 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1439 entry->entry.mte_index,
1440 entry->entry.mte_offset,
1441 entry->entry.file_delta);
1445 bfd_sym_print_contained_labels_table_entry (bfd *abfd,
1447 bfd_sym_contained_labels_table_entry *entry)
1449 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1455 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1457 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1458 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1462 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1463 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1464 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1465 entry->entry.mte_index,
1466 entry->entry.mte_offset,
1467 entry->entry.file_delta,
1468 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1472 bfd_sym_print_contained_types_table_entry (bfd *abfd ATTRIBUTE_UNUSED,
1474 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED)
1476 fprintf (f, "[UNIMPLEMENTED]");
1480 bfd_sym_type_operator_name (unsigned char num)
1484 case 1: return "TTE";
1485 case 2: return "PointerTo";
1486 case 3: return "ScalarOf";
1487 case 4: return "ConstantOf";
1488 case 5: return "EnumerationOf";
1489 case 6: return "VectorOf";
1490 case 7: return "RecordOf";
1491 case 8: return "UnionOf";
1492 case 9: return "SubRangeOf";
1493 case 10: return "SetOf";
1494 case 11: return "NamedTypeOf";
1495 case 12: return "ProcOf";
1496 case 13: return "ValueOf";
1497 case 14: return "ArrayOf";
1498 default: return "[UNKNOWN OPERATOR]";
1503 bfd_sym_type_basic_name (unsigned char num)
1507 case 0: return "void";
1508 case 1: return "pascal string";
1509 case 2: return "unsigned long";
1510 case 3: return "signed long";
1511 case 4: return "extended (10 bytes)";
1512 case 5: return "pascal boolean (1 byte)";
1513 case 6: return "unsigned byte";
1514 case 7: return "signed byte";
1515 case 8: return "character (1 byte)";
1516 case 9: return "wide character (2 bytes)";
1517 case 10: return "unsigned short";
1518 case 11: return "signed short";
1519 case 12: return "singled";
1520 case 13: return "double";
1521 case 14: return "extended (12 bytes)";
1522 case 15: return "computational (8 bytes)";
1523 case 16: return "c string";
1524 case 17: return "as-is string";
1525 default: return "[UNKNOWN BASIC TYPE]";
1530 bfd_sym_fetch_long (unsigned char *buf,
1532 unsigned long offset,
1533 unsigned long *offsetptr,
1544 else if (! (buf[offset] & 0x80))
1546 *value = buf[offset];
1550 else if (buf[offset] == 0xc0)
1552 if ((offset + 5) > len)
1560 *value = bfd_getb32 (buf + offset + 1);
1565 else if ((buf[offset] & 0xc0) == 0xc0)
1567 *value = -(buf[offset] & 0x3f);
1571 else if ((buf[offset] & 0xc0) == 0x80)
1573 if ((offset + 2) > len)
1581 *value = bfd_getb16 (buf + offset) & 0x3fff;
1589 if (offsetptr != NULL)
1590 *offsetptr = offset;
1596 bfd_sym_print_type_information (bfd *abfd,
1600 unsigned long offset,
1601 unsigned long *offsetptr)
1607 fprintf (f, "[NULL]");
1609 if (offsetptr != NULL)
1610 *offsetptr = offset;
1617 if (! (type & 0x80))
1619 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1621 if (offsetptr != NULL)
1622 *offsetptr = offset;
1627 fprintf (f, "[packed ");
1631 switch (type & 0x3f)
1636 bfd_sym_type_information_table_entry tinfo;
1638 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1640 fprintf (f, "[INVALID]");
1643 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1644 fprintf (f, "[INVALID]");
1646 fprintf (f, "\"%.*s\"",
1647 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1648 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1650 fprintf (f, " (TTE %lu)", (unsigned long) value);
1655 fprintf (f, "pointer (0x%x) to ", type);
1656 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1663 fprintf (f, "scalar (0x%x) of ", type);
1664 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1665 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1666 fprintf (f, " (%lu)", (unsigned long) value);
1672 long lower, upper, nelem;
1675 fprintf (f, "enumeration (0x%x) of ", type);
1676 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1677 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1678 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1679 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1680 fprintf (f, " from %lu to %lu with %lu elements: ",
1681 (unsigned long) lower, (unsigned long) upper,
1682 (unsigned long) nelem);
1684 for (i = 0; i < nelem; i++)
1687 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1693 fprintf (f, "vector (0x%x)", type);
1694 fprintf (f, "\n index ");
1695 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1696 fprintf (f, "\n target ");
1697 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1703 long nrec, eloff, i;
1705 if ((type & 0x3f) == 7)
1706 fprintf (f, "record (0x%x) of ", type);
1708 fprintf (f, "union (0x%x) of ", type);
1710 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1711 fprintf (f, "%lu elements: ", (unsigned long) nrec);
1713 for (i = 0; i < nrec; i++)
1715 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1717 fprintf (f, "offset %lu: ", (unsigned long) eloff);
1718 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1724 fprintf (f, "subrange (0x%x) of ", type);
1725 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1726 fprintf (f, " lower ");
1727 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1728 fprintf (f, " upper ");
1729 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1736 fprintf (f, "named type (0x%x) ", type);
1737 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1739 fprintf (f, "[INVALID]");
1741 fprintf (f, "\"%.*s\"",
1742 bfd_sym_symbol_name (abfd, value)[0],
1743 &bfd_sym_symbol_name (abfd, value)[1]);
1745 fprintf (f, " (NTE %lu) with type ", (unsigned long) value);
1746 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1751 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1755 if (type == (0x40 | 0x6))
1762 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1763 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1764 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1765 /* fprintf (f, "\n "); */
1766 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1767 for (i = 0; i < m; i++)
1769 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1772 fprintf (f, "%ld", l);
1775 else if (type & 0x40)
1777 /* Other packed type. */
1780 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1781 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1782 /* fprintf (f, "\n "); */
1783 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1788 if (offsetptr != NULL)
1789 *offsetptr = offset;
1793 bfd_sym_print_type_information_table_entry (bfd *abfd,
1795 bfd_sym_type_information_table_entry *entry)
1798 unsigned long offset;
1801 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1802 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1803 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1805 entry->physical_size, entry->offset, entry->logical_size);
1809 buf = malloc (entry->physical_size);
1812 fprintf (f, "[ERROR]\n");
1815 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1817 fprintf (f, "[ERROR]\n");
1821 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1823 fprintf (f, "[ERROR]\n");
1829 for (i = 0; i < entry->physical_size; i++)
1832 fprintf (f, "0x%02x", buf[i]);
1834 fprintf (f, " 0x%02x", buf[i]);
1840 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1842 if (offset != entry->physical_size)
1843 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size);
1848 bfd_sym_print_file_references_index_table_entry (bfd *abfd ATTRIBUTE_UNUSED,
1850 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED)
1852 fprintf (f, "[UNIMPLEMENTED]");
1856 bfd_sym_print_constant_pool_entry (bfd *abfd ATTRIBUTE_UNUSED,
1858 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED)
1860 fprintf (f, "[UNIMPLEMENTED]");
1864 bfd_sym_display_name_table_entry (bfd *abfd,
1866 unsigned char *entry)
1868 unsigned long sym_index;
1869 unsigned long offset;
1870 bfd_sym_data_struct *sdata = NULL;
1872 BFD_ASSERT (bfd_sym_valid (abfd));
1873 sdata = abfd->tdata.sym_data;
1874 sym_index = (entry - sdata->name_table) / 2;
1876 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1878 unsigned short length = bfd_getb16 (entry + 2);
1879 fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, length, entry + 4);
1880 offset = 2 + length + 1;
1884 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1885 fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, entry[0], entry + 1);
1887 if (sdata->version >= BFD_SYM_VERSION_3_4)
1888 offset = entry[0] + 2;
1890 offset = entry[0] + 1;
1893 return (entry + offset + (offset % 2));
1897 bfd_sym_display_name_table (bfd *abfd, FILE *f)
1899 unsigned long name_table_len;
1900 unsigned char *name_table, *name_table_end, *cur;
1901 bfd_sym_data_struct *sdata = NULL;
1903 BFD_ASSERT (bfd_sym_valid (abfd));
1904 sdata = abfd->tdata.sym_data;
1906 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1907 name_table = sdata->name_table;
1908 name_table_end = name_table + name_table_len;
1910 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1915 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1916 if (cur >= name_table_end)
1922 bfd_sym_display_resources_table (bfd *abfd, FILE *f)
1925 bfd_sym_resources_table_entry entry;
1926 bfd_sym_data_struct *sdata = NULL;
1928 BFD_ASSERT (bfd_sym_valid (abfd));
1929 sdata = abfd->tdata.sym_data;
1931 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
1932 sdata->header.dshb_rte.dti_object_count);
1934 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
1936 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
1937 fprintf (f, " [%8lu] [INVALID]\n", i);
1940 fprintf (f, " [%8lu] ", i);
1941 bfd_sym_print_resources_table_entry (abfd, f, &entry);
1948 bfd_sym_display_modules_table (bfd *abfd, FILE *f)
1951 bfd_sym_modules_table_entry entry;
1952 bfd_sym_data_struct *sdata = NULL;
1954 BFD_ASSERT (bfd_sym_valid (abfd));
1955 sdata = abfd->tdata.sym_data;
1957 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
1958 sdata->header.dshb_mte.dti_object_count);
1960 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
1962 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
1963 fprintf (f, " [%8lu] [INVALID]\n", i);
1966 fprintf (f, " [%8lu] ", i);
1967 bfd_sym_print_modules_table_entry (abfd, f, &entry);
1974 bfd_sym_display_file_references_table (bfd *abfd, FILE *f)
1977 bfd_sym_file_references_table_entry entry;
1978 bfd_sym_data_struct *sdata = NULL;
1980 BFD_ASSERT (bfd_sym_valid (abfd));
1981 sdata = abfd->tdata.sym_data;
1983 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
1984 sdata->header.dshb_frte.dti_object_count);
1986 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
1988 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
1989 fprintf (f, " [%8lu] [INVALID]\n", i);
1992 fprintf (f, " [%8lu] ", i);
1993 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
2000 bfd_sym_display_contained_modules_table (bfd *abfd, FILE *f)
2003 bfd_sym_contained_modules_table_entry entry;
2004 bfd_sym_data_struct *sdata = NULL;
2006 BFD_ASSERT (bfd_sym_valid (abfd));
2007 sdata = abfd->tdata.sym_data;
2009 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
2010 sdata->header.dshb_cmte.dti_object_count);
2012 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2014 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
2015 fprintf (f, " [%8lu] [INVALID]\n", i);
2018 fprintf (f, " [%8lu] ", i);
2019 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
2026 bfd_sym_display_contained_variables_table (bfd *abfd, FILE *f)
2029 bfd_sym_contained_variables_table_entry entry;
2030 bfd_sym_data_struct *sdata = NULL;
2032 BFD_ASSERT (bfd_sym_valid (abfd));
2033 sdata = abfd->tdata.sym_data;
2035 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2036 sdata->header.dshb_cvte.dti_object_count);
2038 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2040 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2041 fprintf (f, " [%8lu] [INVALID]\n", i);
2044 fprintf (f, " [%8lu] ", i);
2045 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2054 bfd_sym_display_contained_statements_table (bfd *abfd, FILE *f)
2057 bfd_sym_contained_statements_table_entry entry;
2058 bfd_sym_data_struct *sdata = NULL;
2060 BFD_ASSERT (bfd_sym_valid (abfd));
2061 sdata = abfd->tdata.sym_data;
2063 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
2064 sdata->header.dshb_csnte.dti_object_count);
2066 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2068 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
2069 fprintf (f, " [%8lu] [INVALID]\n", i);
2072 fprintf (f, " [%8lu] ", i);
2073 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
2080 bfd_sym_display_contained_labels_table (bfd *abfd, FILE *f)
2083 bfd_sym_contained_labels_table_entry entry;
2084 bfd_sym_data_struct *sdata = NULL;
2086 BFD_ASSERT (bfd_sym_valid (abfd));
2087 sdata = abfd->tdata.sym_data;
2089 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
2090 sdata->header.dshb_clte.dti_object_count);
2092 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2094 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
2095 fprintf (f, " [%8lu] [INVALID]\n", i);
2098 fprintf (f, " [%8lu] ", i);
2099 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
2106 bfd_sym_display_contained_types_table (bfd *abfd, FILE *f)
2109 bfd_sym_contained_types_table_entry entry;
2110 bfd_sym_data_struct *sdata = NULL;
2112 BFD_ASSERT (bfd_sym_valid (abfd));
2113 sdata = abfd->tdata.sym_data;
2115 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
2116 sdata->header.dshb_ctte.dti_object_count);
2118 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2120 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2121 fprintf (f, " [%8lu] [INVALID]\n", i);
2124 fprintf (f, " [%8lu] ", i);
2125 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2132 bfd_sym_display_file_references_index_table (bfd *abfd, FILE *f)
2135 bfd_sym_file_references_index_table_entry entry;
2136 bfd_sym_data_struct *sdata = NULL;
2138 BFD_ASSERT (bfd_sym_valid (abfd));
2139 sdata = abfd->tdata.sym_data;
2141 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
2142 sdata->header.dshb_fite.dti_object_count);
2144 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2146 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2147 fprintf (f, " [%8lu] [INVALID]\n", i);
2150 fprintf (f, " [%8lu] ", i);
2151 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2158 bfd_sym_display_constant_pool (bfd *abfd, FILE *f)
2161 bfd_sym_constant_pool_entry entry;
2162 bfd_sym_data_struct *sdata = NULL;
2164 BFD_ASSERT (bfd_sym_valid (abfd));
2165 sdata = abfd->tdata.sym_data;
2167 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2168 sdata->header.dshb_const.dti_object_count);
2170 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2172 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2173 fprintf (f, " [%8lu] [INVALID]\n", i);
2176 fprintf (f, " [%8lu] ", i);
2177 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2184 bfd_sym_display_type_information_table (bfd *abfd, FILE *f)
2187 bfd_sym_type_table_entry sym_index;
2188 bfd_sym_type_information_table_entry entry;
2189 bfd_sym_data_struct *sdata = NULL;
2191 BFD_ASSERT (bfd_sym_valid (abfd));
2192 sdata = abfd->tdata.sym_data;
2194 if (sdata->header.dshb_tte.dti_object_count > 99)
2195 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2196 sdata->header.dshb_tte.dti_object_count - 99);
2199 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2203 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2205 if (bfd_sym_fetch_type_table_entry (abfd, &sym_index, i - 100) < 0)
2206 fprintf (f, " [%8lu] [INVALID]\n", i);
2209 fprintf (f, " [%8lu] (TINFO %lu) ", i, sym_index);
2211 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, sym_index) < 0)
2212 fprintf (f, "[INVALID]");
2214 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2222 bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
2225 const char *name = "symbols";
2227 mdata->name_table = 0;
2229 mdata->version = version;
2231 bfd_seek (abfd, 0, SEEK_SET);
2232 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2235 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2236 if (mdata->name_table == NULL)
2239 bfdsec = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
2246 bfdsec->filepos = 0;
2247 bfdsec->alignment_power = 0;
2249 abfd->tdata.sym_data = mdata;
2255 bfd_sym_object_p (bfd *abfd)
2257 bfd_sym_version version = -1;
2258 bfd_sym_data_struct *mdata;
2260 bfd_seek (abfd, 0, SEEK_SET);
2261 if (bfd_sym_read_version (abfd, &version) != 0)
2264 mdata = (bfd_sym_data_struct *) bfd_alloc (abfd, sizeof (*mdata));
2268 if (bfd_sym_scan (abfd, version, mdata) != 0)
2274 bfd_set_error (bfd_error_wrong_format);
2280 #define bfd_sym_make_empty_symbol _bfd_generic_make_empty_symbol
2283 bfd_sym_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED, asymbol *symbol, symbol_info *ret)
2285 bfd_symbol_info (symbol, ret);
2289 bfd_sym_get_symtab_upper_bound (bfd *abfd ATTRIBUTE_UNUSED)
2295 bfd_sym_canonicalize_symtab (bfd *abfd ATTRIBUTE_UNUSED, asymbol **sym ATTRIBUTE_UNUSED)
2301 bfd_sym_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
2302 struct bfd_link_info *info ATTRIBUTE_UNUSED)
2307 const bfd_target sym_vec =
2310 bfd_target_sym_flavour, /* Flavour. */
2311 BFD_ENDIAN_BIG, /* Byteorder. */
2312 BFD_ENDIAN_BIG, /* Header byteorder. */
2313 (HAS_RELOC | EXEC_P | /* Object flags. */
2314 HAS_LINENO | HAS_DEBUG |
2315 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2316 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2317 | SEC_ROM | SEC_HAS_CONTENTS), /* Section_flags. */
2318 0, /* Symbol_leading_char. */
2319 ' ', /* AR_pad_char. */
2320 16, /* AR_max_namelen. */
2321 0, /* match priority. */
2322 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2323 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2324 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
2325 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2326 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2327 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Hdrs. */
2328 { /* bfd_check_format. */
2330 bfd_sym_object_p, /* bfd_check_format. */
2334 { /* bfd_set_format. */
2340 { /* bfd_write_contents. */
2347 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2348 BFD_JUMP_TABLE_COPY (_bfd_generic),
2349 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2350 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2351 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2352 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
2353 BFD_JUMP_TABLE_WRITE (bfd_sym),
2354 BFD_JUMP_TABLE_LINK (bfd_sym),
2355 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),