Home | History | Annotate | Line # | Download | only in bfd
xsym.c revision 1.1.1.6
      1      1.1  christos /* xSYM symbol-file support for BFD.
      2  1.1.1.6  christos    Copyright (C) 1999-2020 Free Software Foundation, Inc.
      3      1.1  christos 
      4      1.1  christos    This file is part of BFD, the Binary File Descriptor library.
      5      1.1  christos 
      6      1.1  christos    This program is free software; you can redistribute it and/or modify
      7      1.1  christos    it under the terms of the GNU General Public License as published by
      8      1.1  christos    the Free Software Foundation; either version 3 of the License, or
      9      1.1  christos    (at your option) any later version.
     10      1.1  christos 
     11      1.1  christos    This program is distributed in the hope that it will be useful,
     12      1.1  christos    but WITHOUT ANY WARRANTY; without even the implied warranty of
     13      1.1  christos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14      1.1  christos    GNU General Public License for more details.
     15      1.1  christos 
     16      1.1  christos    You should have received a copy of the GNU General Public License
     17      1.1  christos    along with this program; if not, write to the Free Software
     18      1.1  christos    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     19      1.1  christos    MA 02110-1301, USA.  */
     20      1.1  christos 
     21      1.1  christos /* xSYM is the debugging format used by CodeWarrior on Mac OS classic.  */
     22      1.1  christos 
     23      1.1  christos #include "sysdep.h"
     24      1.1  christos #include "alloca-conf.h"
     25      1.1  christos #include "xsym.h"
     26      1.1  christos #include "bfd.h"
     27      1.1  christos #include "libbfd.h"
     28      1.1  christos 
     29  1.1.1.5  christos #define bfd_sym_close_and_cleanup		    _bfd_generic_close_and_cleanup
     30  1.1.1.5  christos #define bfd_sym_bfd_free_cached_info		    _bfd_generic_bfd_free_cached_info
     31  1.1.1.5  christos #define bfd_sym_new_section_hook		    _bfd_generic_new_section_hook
     32  1.1.1.5  christos #define bfd_sym_bfd_is_local_label_name		    bfd_generic_is_local_label_name
     33  1.1.1.5  christos #define bfd_sym_bfd_is_target_special_symbol	    _bfd_bool_bfd_asymbol_false
     34  1.1.1.5  christos #define bfd_sym_get_lineno			    _bfd_nosymbols_get_lineno
     35  1.1.1.5  christos #define bfd_sym_find_nearest_line		    _bfd_nosymbols_find_nearest_line
     36  1.1.1.5  christos #define bfd_sym_find_line			    _bfd_nosymbols_find_line
     37  1.1.1.5  christos #define bfd_sym_find_inliner_info		    _bfd_nosymbols_find_inliner_info
     38  1.1.1.2  christos #define bfd_sym_get_symbol_version_string	    _bfd_nosymbols_get_symbol_version_string
     39  1.1.1.5  christos #define bfd_sym_bfd_make_debug_symbol		    _bfd_nosymbols_bfd_make_debug_symbol
     40  1.1.1.5  christos #define bfd_sym_read_minisymbols		    _bfd_generic_read_minisymbols
     41  1.1.1.5  christos #define bfd_sym_minisymbol_to_symbol		    _bfd_generic_minisymbol_to_symbol
     42  1.1.1.5  christos #define bfd_sym_set_arch_mach			    _bfd_generic_set_arch_mach
     43  1.1.1.5  christos #define bfd_sym_get_section_contents		    _bfd_generic_get_section_contents
     44  1.1.1.5  christos #define bfd_sym_set_section_contents		    _bfd_generic_set_section_contents
     45      1.1  christos #define bfd_sym_bfd_get_relocated_section_contents  bfd_generic_get_relocated_section_contents
     46  1.1.1.5  christos #define bfd_sym_bfd_relax_section		    bfd_generic_relax_section
     47  1.1.1.5  christos #define bfd_sym_bfd_gc_sections			    bfd_generic_gc_sections
     48  1.1.1.5  christos #define bfd_sym_bfd_lookup_section_flags	    bfd_generic_lookup_section_flags
     49  1.1.1.5  christos #define bfd_sym_bfd_merge_sections		    bfd_generic_merge_sections
     50  1.1.1.5  christos #define bfd_sym_bfd_is_group_section		    bfd_generic_is_group_section
     51  1.1.1.6  christos #define bfd_sym_bfd_group_name			    bfd_generic_group_name
     52  1.1.1.5  christos #define bfd_sym_bfd_discard_group		    bfd_generic_discard_group
     53  1.1.1.5  christos #define bfd_sym_section_already_linked		    _bfd_generic_section_already_linked
     54  1.1.1.5  christos #define bfd_sym_bfd_define_common_symbol	    bfd_generic_define_common_symbol
     55  1.1.1.5  christos #define bfd_sym_bfd_link_hide_symbol		    _bfd_generic_link_hide_symbol
     56  1.1.1.5  christos #define bfd_sym_bfd_define_start_stop		    bfd_generic_define_start_stop
     57  1.1.1.5  christos #define bfd_sym_bfd_link_hash_table_create	    _bfd_generic_link_hash_table_create
     58  1.1.1.5  christos #define bfd_sym_bfd_link_add_symbols		    _bfd_generic_link_add_symbols
     59  1.1.1.5  christos #define bfd_sym_bfd_link_just_syms		    _bfd_generic_link_just_syms
     60      1.1  christos #define bfd_sym_bfd_copy_link_hash_symbol_type \
     61      1.1  christos   _bfd_generic_copy_link_hash_symbol_type
     62  1.1.1.5  christos #define bfd_sym_bfd_final_link			    _bfd_generic_final_link
     63  1.1.1.5  christos #define bfd_sym_bfd_link_split_section		    _bfd_generic_link_split_section
     64  1.1.1.5  christos #define bfd_sym_get_section_contents_in_window	    _bfd_generic_get_section_contents_in_window
     65  1.1.1.5  christos #define bfd_sym_bfd_link_check_relocs		    _bfd_generic_link_check_relocs
     66      1.1  christos 
     67      1.1  christos extern const bfd_target sym_vec;
     68      1.1  christos 
     69      1.1  christos static int
     70      1.1  christos pstrcmp (const char *as, const char *bs)
     71      1.1  christos {
     72      1.1  christos   const unsigned char *a = (const unsigned char *) as;
     73      1.1  christos   const unsigned char *b = (const unsigned char *) bs;
     74      1.1  christos   unsigned char clen;
     75      1.1  christos   int ret;
     76      1.1  christos 
     77      1.1  christos   clen = (a[0] > b[0]) ? b[0] : a[0];
     78      1.1  christos   ret = memcmp (a + 1, b + 1, clen);
     79      1.1  christos   if (ret != 0)
     80      1.1  christos     return ret;
     81      1.1  christos 
     82      1.1  christos   if (a[0] == b[0])
     83      1.1  christos     return 0;
     84      1.1  christos   else if (a[0] < b[0])
     85      1.1  christos     return -1;
     86      1.1  christos   else
     87      1.1  christos     return 1;
     88      1.1  christos }
     89      1.1  christos 
     90      1.1  christos static unsigned long
     91      1.1  christos compute_offset (unsigned long first_page,
     92      1.1  christos 		unsigned long page_size,
     93      1.1  christos 		unsigned long entry_size,
     94      1.1  christos 		unsigned long sym_index)
     95      1.1  christos {
     96      1.1  christos   unsigned long entries_per_page = page_size / entry_size;
     97      1.1  christos   unsigned long page_number = first_page + (sym_index / entries_per_page);
     98      1.1  christos   unsigned long page_offset = (sym_index % entries_per_page) * entry_size;
     99      1.1  christos 
    100      1.1  christos   return (page_number * page_size) + page_offset;
    101      1.1  christos }
    102      1.1  christos 
    103      1.1  christos bfd_boolean
    104      1.1  christos bfd_sym_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
    105      1.1  christos {
    106      1.1  christos   return 1;
    107      1.1  christos }
    108      1.1  christos 
    109      1.1  christos void
    110      1.1  christos bfd_sym_print_symbol (bfd *abfd ATTRIBUTE_UNUSED,
    111      1.1  christos 		      void * afile ATTRIBUTE_UNUSED,
    112      1.1  christos 		      asymbol *symbol ATTRIBUTE_UNUSED,
    113      1.1  christos 		      bfd_print_symbol_type how ATTRIBUTE_UNUSED)
    114      1.1  christos {
    115      1.1  christos   return;
    116      1.1  christos }
    117      1.1  christos 
    118      1.1  christos bfd_boolean
    119      1.1  christos bfd_sym_valid (bfd *abfd)
    120      1.1  christos {
    121      1.1  christos   if (abfd == NULL || abfd->xvec == NULL)
    122      1.1  christos     return 0;
    123      1.1  christos 
    124      1.1  christos   return abfd->xvec == &sym_vec;
    125      1.1  christos }
    126      1.1  christos 
    127      1.1  christos unsigned char *
    128      1.1  christos bfd_sym_read_name_table (bfd *abfd, bfd_sym_header_block *dshb)
    129      1.1  christos {
    130      1.1  christos   size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
    131      1.1  christos   size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
    132      1.1  christos 
    133  1.1.1.6  christos   if (bfd_seek (abfd, table_offset, SEEK_SET) != 0)
    134  1.1.1.6  christos     return FALSE;
    135  1.1.1.6  christos   return _bfd_alloc_and_read (abfd, table_size, table_size);
    136      1.1  christos }
    137      1.1  christos 
    138      1.1  christos void
    139      1.1  christos bfd_sym_parse_file_reference_v32 (unsigned char *buf,
    140      1.1  christos 				  size_t len,
    141      1.1  christos 				  bfd_sym_file_reference *entry)
    142      1.1  christos {
    143      1.1  christos   BFD_ASSERT (len == 6);
    144      1.1  christos 
    145      1.1  christos   entry->fref_frte_index = bfd_getb16 (buf);
    146      1.1  christos   entry->fref_offset = bfd_getb32 (buf + 2);
    147      1.1  christos }
    148      1.1  christos 
    149      1.1  christos void
    150      1.1  christos bfd_sym_parse_disk_table_v32 (unsigned char *buf,
    151      1.1  christos 			      size_t len,
    152      1.1  christos 			      bfd_sym_table_info *table)
    153      1.1  christos {
    154      1.1  christos   BFD_ASSERT (len == 8);
    155      1.1  christos 
    156      1.1  christos   table->dti_first_page = bfd_getb16 (buf);
    157      1.1  christos   table->dti_page_count = bfd_getb16 (buf + 2);
    158      1.1  christos   table->dti_object_count = bfd_getb32 (buf + 4);
    159      1.1  christos }
    160      1.1  christos 
    161      1.1  christos void
    162      1.1  christos bfd_sym_parse_header_v32 (unsigned char *buf,
    163      1.1  christos 			  size_t len,
    164      1.1  christos 			  bfd_sym_header_block *header)
    165      1.1  christos {
    166      1.1  christos   BFD_ASSERT (len == 154);
    167      1.1  christos 
    168      1.1  christos   memcpy (header->dshb_id, buf, 32);
    169      1.1  christos   header->dshb_page_size = bfd_getb16 (buf + 32);
    170      1.1  christos   header->dshb_hash_page = bfd_getb16 (buf + 34);
    171      1.1  christos   header->dshb_root_mte = bfd_getb16 (buf + 36);
    172      1.1  christos   header->dshb_mod_date = bfd_getb32 (buf + 38);
    173      1.1  christos 
    174      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
    175      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
    176      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
    177      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
    178      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
    179      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
    180      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
    181      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
    182      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
    183      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
    184      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
    185      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
    186      1.1  christos   bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
    187      1.1  christos 
    188      1.1  christos   memcpy (&header->dshb_file_creator, buf + 146, 4);
    189      1.1  christos   memcpy (&header->dshb_file_type, buf + 150, 4);
    190      1.1  christos }
    191      1.1  christos 
    192      1.1  christos int
    193      1.1  christos bfd_sym_read_header_v32 (bfd *abfd, bfd_sym_header_block *header)
    194      1.1  christos {
    195      1.1  christos   unsigned char buf[154];
    196      1.1  christos   long ret;
    197      1.1  christos 
    198      1.1  christos   ret = bfd_bread (buf, 154, abfd);
    199      1.1  christos   if (ret != 154)
    200      1.1  christos     return -1;
    201      1.1  christos 
    202      1.1  christos   bfd_sym_parse_header_v32 (buf, 154, header);
    203      1.1  christos 
    204      1.1  christos   return 0;
    205      1.1  christos }
    206      1.1  christos 
    207      1.1  christos int
    208      1.1  christos bfd_sym_read_header_v34 (bfd *abfd ATTRIBUTE_UNUSED,
    209      1.1  christos 			 bfd_sym_header_block *header ATTRIBUTE_UNUSED)
    210      1.1  christos {
    211      1.1  christos   abort ();
    212      1.1  christos }
    213      1.1  christos 
    214      1.1  christos int
    215      1.1  christos bfd_sym_read_header (bfd *abfd,
    216      1.1  christos 		     bfd_sym_header_block *header,
    217      1.1  christos 		     bfd_sym_version version)
    218      1.1  christos {
    219      1.1  christos   switch (version)
    220      1.1  christos     {
    221      1.1  christos     case BFD_SYM_VERSION_3_5:
    222      1.1  christos     case BFD_SYM_VERSION_3_4:
    223      1.1  christos       return bfd_sym_read_header_v34 (abfd, header);
    224      1.1  christos     case BFD_SYM_VERSION_3_3:
    225      1.1  christos     case BFD_SYM_VERSION_3_2:
    226      1.1  christos       return bfd_sym_read_header_v32 (abfd, header);
    227      1.1  christos     case BFD_SYM_VERSION_3_1:
    228      1.1  christos     default:
    229      1.1  christos       return 0;
    230      1.1  christos     }
    231      1.1  christos }
    232      1.1  christos 
    233      1.1  christos int
    234      1.1  christos bfd_sym_read_version (bfd *abfd, bfd_sym_version *version)
    235      1.1  christos {
    236      1.1  christos   char version_string[32];
    237      1.1  christos   long ret;
    238      1.1  christos 
    239      1.1  christos   ret = bfd_bread (version_string, sizeof (version_string), abfd);
    240      1.1  christos   if (ret != sizeof (version_string))
    241      1.1  christos     return -1;
    242      1.1  christos 
    243      1.1  christos   if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
    244      1.1  christos     *version = BFD_SYM_VERSION_3_1;
    245      1.1  christos   else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
    246      1.1  christos     *version = BFD_SYM_VERSION_3_2;
    247      1.1  christos   else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
    248      1.1  christos     *version = BFD_SYM_VERSION_3_3;
    249      1.1  christos   else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
    250      1.1  christos     *version = BFD_SYM_VERSION_3_4;
    251      1.1  christos   else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
    252      1.1  christos     *version = BFD_SYM_VERSION_3_5;
    253      1.1  christos   else
    254      1.1  christos     return -1;
    255      1.1  christos 
    256      1.1  christos   return 0;
    257      1.1  christos }
    258      1.1  christos 
    259      1.1  christos void
    260      1.1  christos bfd_sym_display_table_summary (FILE *f,
    261      1.1  christos 			       bfd_sym_table_info *dti,
    262      1.1  christos 			       const char *name)
    263      1.1  christos {
    264      1.1  christos   fprintf (f, "%-6s %13ld %13ld %13ld\n",
    265      1.1  christos 	   name,
    266      1.1  christos 	   dti->dti_first_page,
    267      1.1  christos 	   dti->dti_page_count,
    268      1.1  christos 	   dti->dti_object_count);
    269      1.1  christos }
    270      1.1  christos 
    271      1.1  christos void
    272      1.1  christos bfd_sym_display_header (FILE *f, bfd_sym_header_block *dshb)
    273      1.1  christos {
    274      1.1  christos   fprintf (f, "            Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
    275      1.1  christos   fprintf (f, "          Page Size: 0x%x\n", dshb->dshb_page_size);
    276      1.1  christos   fprintf (f, "          Hash Page: %lu\n", dshb->dshb_hash_page);
    277      1.1  christos   fprintf (f, "           Root MTE: %lu\n", dshb->dshb_root_mte);
    278      1.1  christos   fprintf (f, "  Modification Date: ");
    279      1.1  christos   fprintf (f, "[unimplemented]");
    280      1.1  christos   fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
    281      1.1  christos 
    282      1.1  christos   fprintf (f, "       File Creator:  %.4s  Type: %.4s\n\n",
    283      1.1  christos 	   dshb->dshb_file_creator, dshb->dshb_file_type);
    284      1.1  christos 
    285      1.1  christos   fprintf (f, "Table Name   First Page    Page Count   Object Count\n");
    286      1.1  christos   fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
    287      1.1  christos 
    288      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
    289      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
    290      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
    291      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
    292      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
    293      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
    294      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
    295      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
    296      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
    297      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
    298      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
    299      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
    300      1.1  christos   bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
    301      1.1  christos 
    302      1.1  christos   fprintf (f, "\n");
    303      1.1  christos }
    304      1.1  christos 
    305      1.1  christos void
    306      1.1  christos bfd_sym_parse_resources_table_entry_v32 (unsigned char *buf,
    307      1.1  christos 					 size_t len,
    308      1.1  christos 					 bfd_sym_resources_table_entry *entry)
    309      1.1  christos {
    310      1.1  christos   BFD_ASSERT (len == 18);
    311      1.1  christos 
    312      1.1  christos   memcpy (&entry->rte_res_type, buf, 4);
    313      1.1  christos   entry->rte_res_number = bfd_getb16 (buf + 4);
    314      1.1  christos   entry->rte_nte_index = bfd_getb32 (buf + 6);
    315      1.1  christos   entry->rte_mte_first = bfd_getb16 (buf + 10);
    316      1.1  christos   entry->rte_mte_last = bfd_getb16 (buf + 12);
    317      1.1  christos   entry->rte_res_size = bfd_getb32 (buf + 14);
    318      1.1  christos }
    319      1.1  christos 
    320      1.1  christos void
    321      1.1  christos bfd_sym_parse_modules_table_entry_v33 (unsigned char *buf,
    322      1.1  christos 				       size_t len,
    323      1.1  christos 				       bfd_sym_modules_table_entry *entry)
    324      1.1  christos {
    325      1.1  christos   BFD_ASSERT (len == 46);
    326      1.1  christos 
    327      1.1  christos   entry->mte_rte_index = bfd_getb16 (buf);
    328      1.1  christos   entry->mte_res_offset = bfd_getb32 (buf + 2);
    329      1.1  christos   entry->mte_size = bfd_getb32 (buf + 6);
    330      1.1  christos   entry->mte_kind = buf[10];
    331      1.1  christos   entry->mte_scope = buf[11];
    332      1.1  christos   entry->mte_parent = bfd_getb16 (buf + 12);
    333      1.1  christos   bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
    334      1.1  christos   entry->mte_imp_end = bfd_getb32 (buf + 20);
    335      1.1  christos   entry->mte_nte_index = bfd_getb32 (buf + 24);
    336      1.1  christos   entry->mte_cmte_index = bfd_getb16 (buf + 28);
    337      1.1  christos   entry->mte_cvte_index = bfd_getb32 (buf + 30);
    338      1.1  christos   entry->mte_clte_index = bfd_getb16 (buf + 34);
    339      1.1  christos   entry->mte_ctte_index = bfd_getb16 (buf + 36);
    340      1.1  christos   entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
    341      1.1  christos   entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
    342      1.1  christos }
    343      1.1  christos 
    344      1.1  christos void
    345      1.1  christos bfd_sym_parse_file_references_table_entry_v32 (unsigned char *buf,
    346      1.1  christos 					       size_t len,
    347      1.1  christos 					       bfd_sym_file_references_table_entry *entry)
    348      1.1  christos {
    349      1.1  christos   unsigned int type;
    350      1.1  christos 
    351      1.1  christos   BFD_ASSERT (len == 10);
    352      1.1  christos 
    353      1.1  christos   memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
    354      1.1  christos   type = bfd_getb16 (buf);
    355      1.1  christos 
    356      1.1  christos   switch (type)
    357      1.1  christos     {
    358      1.1  christos     case BFD_SYM_END_OF_LIST_3_2:
    359      1.1  christos       entry->generic.type = BFD_SYM_END_OF_LIST;
    360      1.1  christos       break;
    361      1.1  christos 
    362      1.1  christos     case BFD_SYM_FILE_NAME_INDEX_3_2:
    363      1.1  christos       entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
    364      1.1  christos       entry->filename.nte_index = bfd_getb32 (buf + 2);
    365      1.1  christos       entry->filename.mod_date = bfd_getb32 (buf + 6);
    366      1.1  christos       break;
    367      1.1  christos 
    368      1.1  christos     default:
    369      1.1  christos       entry->entry.mte_index = type;
    370      1.1  christos       entry->entry.file_offset = bfd_getb32 (buf + 2);
    371      1.1  christos     }
    372      1.1  christos }
    373      1.1  christos 
    374      1.1  christos void
    375      1.1  christos bfd_sym_parse_contained_modules_table_entry_v32 (unsigned char *buf,
    376      1.1  christos 						 size_t len,
    377      1.1  christos 						 bfd_sym_contained_modules_table_entry *entry)
    378      1.1  christos {
    379      1.1  christos   unsigned int type;
    380      1.1  christos 
    381      1.1  christos   BFD_ASSERT (len == 6);
    382      1.1  christos 
    383      1.1  christos   memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
    384      1.1  christos   type = bfd_getb16 (buf);
    385      1.1  christos 
    386      1.1  christos   switch (type)
    387      1.1  christos     {
    388      1.1  christos     case BFD_SYM_END_OF_LIST_3_2:
    389      1.1  christos       entry->generic.type = BFD_SYM_END_OF_LIST;
    390      1.1  christos       break;
    391      1.1  christos 
    392      1.1  christos     default:
    393      1.1  christos       entry->entry.mte_index = type;
    394      1.1  christos       entry->entry.nte_index = bfd_getb32 (buf + 2);
    395      1.1  christos       break;
    396      1.1  christos     }
    397      1.1  christos }
    398      1.1  christos 
    399      1.1  christos void
    400      1.1  christos bfd_sym_parse_contained_variables_table_entry_v32 (unsigned char *buf,
    401      1.1  christos 						   size_t len,
    402      1.1  christos 						   bfd_sym_contained_variables_table_entry *entry)
    403      1.1  christos {
    404      1.1  christos   unsigned int type;
    405      1.1  christos 
    406      1.1  christos   BFD_ASSERT (len == 26);
    407      1.1  christos 
    408      1.1  christos   memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
    409      1.1  christos   type = bfd_getb16 (buf);
    410      1.1  christos 
    411      1.1  christos   switch (type)
    412      1.1  christos     {
    413      1.1  christos     case BFD_SYM_END_OF_LIST_3_2:
    414      1.1  christos       entry->generic.type = BFD_SYM_END_OF_LIST;
    415      1.1  christos       break;
    416      1.1  christos 
    417      1.1  christos     case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
    418      1.1  christos       entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
    419      1.1  christos       bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
    420      1.1  christos       break;
    421      1.1  christos 
    422      1.1  christos     default:
    423      1.1  christos       entry->entry.tte_index = type;
    424      1.1  christos       entry->entry.nte_index = bfd_getb32 (buf + 2);
    425      1.1  christos       entry->entry.file_delta = bfd_getb16 (buf + 6);
    426      1.1  christos       entry->entry.scope = buf[8];
    427      1.1  christos       entry->entry.la_size = buf[9];
    428      1.1  christos 
    429      1.1  christos       if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
    430      1.1  christos 	{
    431      1.1  christos 	  entry->entry.address.scstruct.sca_kind = buf[10];
    432      1.1  christos 	  entry->entry.address.scstruct.sca_class = buf[11];
    433      1.1  christos 	  entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
    434      1.1  christos 	}
    435      1.1  christos       else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
    436      1.1  christos 	{
    437      1.1  christos #if BFD_SYM_CVTE_SCA > 0
    438      1.1  christos 	  memcpy (&entry->entry.address.lastruct.la, buf + 10,
    439      1.1  christos 		  BFD_SYM_CVTE_SCA);
    440      1.1  christos #endif
    441      1.1  christos 	  entry->entry.address.lastruct.la_kind = buf[23];
    442      1.1  christos 	}
    443      1.1  christos       else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
    444      1.1  christos 	{
    445      1.1  christos 	  entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
    446      1.1  christos 	  entry->entry.address.biglastruct.big_la_kind = buf[12];
    447      1.1  christos 	}
    448      1.1  christos     }
    449      1.1  christos }
    450      1.1  christos 
    451      1.1  christos void
    452      1.1  christos bfd_sym_parse_contained_statements_table_entry_v32 (unsigned char *buf,
    453      1.1  christos 						    size_t len,
    454      1.1  christos 						    bfd_sym_contained_statements_table_entry *entry)
    455      1.1  christos {
    456      1.1  christos   unsigned int type;
    457      1.1  christos 
    458      1.1  christos   BFD_ASSERT (len == 8);
    459      1.1  christos 
    460      1.1  christos   memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
    461      1.1  christos   type = bfd_getb16 (buf);
    462      1.1  christos 
    463      1.1  christos   switch (type)
    464      1.1  christos     {
    465      1.1  christos     case BFD_SYM_END_OF_LIST_3_2:
    466      1.1  christos       entry->generic.type = BFD_SYM_END_OF_LIST;
    467      1.1  christos       break;
    468      1.1  christos 
    469      1.1  christos     case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
    470      1.1  christos       entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
    471      1.1  christos       bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
    472      1.1  christos       break;
    473      1.1  christos 
    474      1.1  christos     default:
    475      1.1  christos       entry->entry.mte_index = type;
    476      1.1  christos       entry->entry.mte_offset = bfd_getb16 (buf + 2);
    477      1.1  christos       entry->entry.file_delta = bfd_getb32 (buf + 4);
    478      1.1  christos       break;
    479      1.1  christos     }
    480      1.1  christos }
    481      1.1  christos 
    482      1.1  christos void
    483      1.1  christos bfd_sym_parse_contained_labels_table_entry_v32 (unsigned char *buf,
    484      1.1  christos 						size_t len,
    485      1.1  christos 						bfd_sym_contained_labels_table_entry *entry)
    486      1.1  christos {
    487      1.1  christos   unsigned int type;
    488      1.1  christos 
    489      1.1  christos   BFD_ASSERT (len == 12);
    490      1.1  christos 
    491      1.1  christos   memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
    492      1.1  christos   type = bfd_getb16 (buf);
    493      1.1  christos 
    494      1.1  christos   switch (type)
    495      1.1  christos     {
    496      1.1  christos     case BFD_SYM_END_OF_LIST_3_2:
    497      1.1  christos       entry->generic.type = BFD_SYM_END_OF_LIST;
    498      1.1  christos       break;
    499      1.1  christos 
    500      1.1  christos     case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
    501      1.1  christos       entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
    502      1.1  christos       bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
    503      1.1  christos       break;
    504      1.1  christos 
    505      1.1  christos     default:
    506      1.1  christos       entry->entry.mte_index = type;
    507      1.1  christos       entry->entry.mte_offset = bfd_getb16 (buf + 2);
    508      1.1  christos       entry->entry.nte_index = bfd_getb32 (buf + 4);
    509      1.1  christos       entry->entry.file_delta = bfd_getb16 (buf + 8);
    510      1.1  christos       entry->entry.scope = bfd_getb16 (buf + 10);
    511      1.1  christos       break;
    512      1.1  christos     }
    513      1.1  christos }
    514      1.1  christos 
    515      1.1  christos void
    516      1.1  christos bfd_sym_parse_type_table_entry_v32 (unsigned char *buf,
    517      1.1  christos 				    size_t len,
    518      1.1  christos 				    bfd_sym_type_table_entry *entry)
    519      1.1  christos {
    520      1.1  christos   BFD_ASSERT (len == 4);
    521      1.1  christos 
    522      1.1  christos   *entry = bfd_getb32 (buf);
    523      1.1  christos }
    524      1.1  christos 
    525      1.1  christos int
    526      1.1  christos bfd_sym_fetch_resources_table_entry (bfd *abfd,
    527      1.1  christos 				     bfd_sym_resources_table_entry *entry,
    528      1.1  christos 				     unsigned long sym_index)
    529      1.1  christos {
    530      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *);
    531      1.1  christos   unsigned long offset;
    532      1.1  christos   unsigned long entry_size;
    533      1.1  christos   unsigned char buf[18];
    534      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    535      1.1  christos 
    536      1.1  christos   parser = NULL;
    537      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    538      1.1  christos   sdata = abfd->tdata.sym_data;
    539      1.1  christos 
    540      1.1  christos   if (sym_index == 0)
    541      1.1  christos     return -1;
    542      1.1  christos 
    543      1.1  christos   switch (sdata->version)
    544      1.1  christos     {
    545      1.1  christos     case BFD_SYM_VERSION_3_5:
    546      1.1  christos     case BFD_SYM_VERSION_3_4:
    547      1.1  christos       return -1;
    548      1.1  christos 
    549      1.1  christos     case BFD_SYM_VERSION_3_3:
    550      1.1  christos     case BFD_SYM_VERSION_3_2:
    551      1.1  christos       entry_size = 18;
    552      1.1  christos       parser = bfd_sym_parse_resources_table_entry_v32;
    553      1.1  christos       break;
    554      1.1  christos 
    555      1.1  christos     case BFD_SYM_VERSION_3_1:
    556      1.1  christos     default:
    557      1.1  christos       return -1;
    558      1.1  christos     }
    559      1.1  christos   if (parser == NULL)
    560      1.1  christos     return -1;
    561      1.1  christos 
    562      1.1  christos   offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
    563      1.1  christos 			   sdata->header.dshb_page_size,
    564      1.1  christos 			   entry_size, sym_index);
    565      1.1  christos 
    566      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
    567      1.1  christos     return -1;
    568      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
    569      1.1  christos     return -1;
    570      1.1  christos 
    571      1.1  christos   (*parser) (buf, entry_size, entry);
    572      1.1  christos 
    573      1.1  christos   return 0;
    574      1.1  christos }
    575      1.1  christos 
    576      1.1  christos int
    577      1.1  christos bfd_sym_fetch_modules_table_entry (bfd *abfd,
    578      1.1  christos 				   bfd_sym_modules_table_entry *entry,
    579      1.1  christos 				   unsigned long sym_index)
    580      1.1  christos {
    581      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *);
    582      1.1  christos   unsigned long offset;
    583      1.1  christos   unsigned long entry_size;
    584      1.1  christos   unsigned char buf[46];
    585      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    586      1.1  christos 
    587      1.1  christos   parser = NULL;
    588      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    589      1.1  christos   sdata = abfd->tdata.sym_data;
    590      1.1  christos 
    591      1.1  christos   if (sym_index == 0)
    592      1.1  christos     return -1;
    593      1.1  christos 
    594      1.1  christos   switch (sdata->version)
    595      1.1  christos     {
    596      1.1  christos     case BFD_SYM_VERSION_3_5:
    597      1.1  christos     case BFD_SYM_VERSION_3_4:
    598      1.1  christos       return -1;
    599      1.1  christos 
    600      1.1  christos     case BFD_SYM_VERSION_3_3:
    601      1.1  christos       entry_size = 46;
    602      1.1  christos       parser = bfd_sym_parse_modules_table_entry_v33;
    603      1.1  christos       break;
    604      1.1  christos 
    605      1.1  christos     case BFD_SYM_VERSION_3_2:
    606      1.1  christos     case BFD_SYM_VERSION_3_1:
    607      1.1  christos     default:
    608      1.1  christos       return -1;
    609      1.1  christos     }
    610      1.1  christos   if (parser == NULL)
    611      1.1  christos     return -1;
    612      1.1  christos 
    613      1.1  christos   offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
    614      1.1  christos 			   sdata->header.dshb_page_size,
    615      1.1  christos 			   entry_size, sym_index);
    616      1.1  christos 
    617      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
    618      1.1  christos     return -1;
    619      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
    620      1.1  christos     return -1;
    621      1.1  christos 
    622      1.1  christos   (*parser) (buf, entry_size, entry);
    623      1.1  christos 
    624      1.1  christos   return 0;
    625      1.1  christos }
    626      1.1  christos 
    627      1.1  christos int
    628      1.1  christos bfd_sym_fetch_file_references_table_entry (bfd *abfd,
    629      1.1  christos 					   bfd_sym_file_references_table_entry *entry,
    630      1.1  christos 					   unsigned long sym_index)
    631      1.1  christos {
    632      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *);
    633      1.1  christos   unsigned long offset;
    634      1.1  christos   unsigned long entry_size = 0;
    635      1.1  christos   unsigned char buf[8];
    636      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    637      1.1  christos 
    638      1.1  christos   parser = NULL;
    639      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    640      1.1  christos   sdata = abfd->tdata.sym_data;
    641      1.1  christos 
    642      1.1  christos   if (sym_index == 0)
    643      1.1  christos     return -1;
    644      1.1  christos 
    645      1.1  christos   switch (sdata->version)
    646      1.1  christos     {
    647      1.1  christos     case BFD_SYM_VERSION_3_3:
    648      1.1  christos     case BFD_SYM_VERSION_3_2:
    649      1.1  christos       entry_size = 10;
    650      1.1  christos       parser = bfd_sym_parse_file_references_table_entry_v32;
    651      1.1  christos       break;
    652      1.1  christos 
    653      1.1  christos     case BFD_SYM_VERSION_3_5:
    654      1.1  christos     case BFD_SYM_VERSION_3_4:
    655      1.1  christos     case BFD_SYM_VERSION_3_1:
    656      1.1  christos     default:
    657      1.1  christos       break;
    658      1.1  christos     }
    659      1.1  christos 
    660      1.1  christos   if (parser == NULL)
    661      1.1  christos     return -1;
    662      1.1  christos 
    663      1.1  christos   offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
    664      1.1  christos 			   sdata->header.dshb_page_size,
    665      1.1  christos 			   entry_size, sym_index);
    666      1.1  christos 
    667      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
    668      1.1  christos     return -1;
    669      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
    670      1.1  christos     return -1;
    671      1.1  christos 
    672      1.1  christos   (*parser) (buf, entry_size, entry);
    673      1.1  christos 
    674      1.1  christos   return 0;
    675      1.1  christos }
    676      1.1  christos 
    677      1.1  christos int
    678      1.1  christos bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
    679      1.1  christos 					     bfd_sym_contained_modules_table_entry *entry,
    680      1.1  christos 					     unsigned long sym_index)
    681      1.1  christos {
    682      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *);
    683      1.1  christos   unsigned long offset;
    684      1.1  christos   unsigned long entry_size = 0;
    685      1.1  christos   unsigned char buf[6];
    686      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    687      1.1  christos 
    688      1.1  christos   parser = NULL;
    689      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    690      1.1  christos   sdata = abfd->tdata.sym_data;
    691      1.1  christos 
    692      1.1  christos   if (sym_index == 0)
    693      1.1  christos     return -1;
    694      1.1  christos 
    695      1.1  christos   switch (sdata->version)
    696      1.1  christos     {
    697      1.1  christos     case BFD_SYM_VERSION_3_3:
    698      1.1  christos     case BFD_SYM_VERSION_3_2:
    699      1.1  christos       entry_size = 6;
    700      1.1  christos       parser = bfd_sym_parse_contained_modules_table_entry_v32;
    701      1.1  christos       break;
    702      1.1  christos 
    703      1.1  christos     case BFD_SYM_VERSION_3_5:
    704      1.1  christos     case BFD_SYM_VERSION_3_4:
    705      1.1  christos     case BFD_SYM_VERSION_3_1:
    706      1.1  christos     default:
    707      1.1  christos       break;
    708      1.1  christos     }
    709      1.1  christos 
    710      1.1  christos   if (parser == NULL)
    711      1.1  christos     return -1;
    712      1.1  christos 
    713      1.1  christos   offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
    714      1.1  christos 			   sdata->header.dshb_page_size,
    715      1.1  christos 			   entry_size, sym_index);
    716      1.1  christos 
    717      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
    718      1.1  christos     return -1;
    719      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
    720      1.1  christos     return -1;
    721      1.1  christos 
    722      1.1  christos   (*parser) (buf, entry_size, entry);
    723      1.1  christos 
    724      1.1  christos   return 0;
    725      1.1  christos }
    726      1.1  christos 
    727      1.1  christos int
    728      1.1  christos bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
    729      1.1  christos 					       bfd_sym_contained_variables_table_entry *entry,
    730      1.1  christos 					       unsigned long sym_index)
    731      1.1  christos {
    732      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *);
    733      1.1  christos   unsigned long offset;
    734      1.1  christos   unsigned long entry_size = 0;
    735      1.1  christos   unsigned char buf[26];
    736      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    737      1.1  christos 
    738      1.1  christos   parser = NULL;
    739      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    740      1.1  christos   sdata = abfd->tdata.sym_data;
    741      1.1  christos 
    742      1.1  christos   if (sym_index == 0)
    743      1.1  christos     return -1;
    744      1.1  christos 
    745      1.1  christos   switch (sdata->version)
    746      1.1  christos     {
    747      1.1  christos     case BFD_SYM_VERSION_3_3:
    748      1.1  christos     case BFD_SYM_VERSION_3_2:
    749      1.1  christos       entry_size = 26;
    750      1.1  christos       parser = bfd_sym_parse_contained_variables_table_entry_v32;
    751      1.1  christos       break;
    752      1.1  christos 
    753      1.1  christos     case BFD_SYM_VERSION_3_5:
    754      1.1  christos     case BFD_SYM_VERSION_3_4:
    755      1.1  christos     case BFD_SYM_VERSION_3_1:
    756      1.1  christos     default:
    757      1.1  christos       break;
    758      1.1  christos     }
    759      1.1  christos 
    760      1.1  christos   if (parser == NULL)
    761      1.1  christos     return -1;
    762      1.1  christos 
    763      1.1  christos   offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
    764      1.1  christos 			   sdata->header.dshb_page_size,
    765      1.1  christos 			   entry_size, sym_index);
    766      1.1  christos 
    767      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
    768      1.1  christos     return -1;
    769      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
    770      1.1  christos     return -1;
    771      1.1  christos 
    772      1.1  christos   (*parser) (buf, entry_size, entry);
    773      1.1  christos 
    774      1.1  christos   return 0;
    775      1.1  christos }
    776      1.1  christos 
    777      1.1  christos int
    778      1.1  christos bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
    779      1.1  christos 						bfd_sym_contained_statements_table_entry *entry,
    780      1.1  christos 						unsigned long sym_index)
    781      1.1  christos {
    782      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *);
    783      1.1  christos   unsigned long offset;
    784      1.1  christos   unsigned long entry_size = 0;
    785      1.1  christos   unsigned char buf[8];
    786      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    787      1.1  christos 
    788      1.1  christos   parser = NULL;
    789      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    790      1.1  christos   sdata = abfd->tdata.sym_data;
    791      1.1  christos 
    792      1.1  christos   if (sym_index == 0)
    793      1.1  christos     return -1;
    794      1.1  christos 
    795      1.1  christos   switch (sdata->version)
    796      1.1  christos     {
    797      1.1  christos     case BFD_SYM_VERSION_3_3:
    798      1.1  christos     case BFD_SYM_VERSION_3_2:
    799      1.1  christos       entry_size = 8;
    800      1.1  christos       parser = bfd_sym_parse_contained_statements_table_entry_v32;
    801      1.1  christos       break;
    802      1.1  christos 
    803      1.1  christos     case BFD_SYM_VERSION_3_5:
    804      1.1  christos     case BFD_SYM_VERSION_3_4:
    805      1.1  christos     case BFD_SYM_VERSION_3_1:
    806      1.1  christos     default:
    807      1.1  christos       break;
    808      1.1  christos     }
    809      1.1  christos 
    810      1.1  christos   if (parser == NULL)
    811      1.1  christos     return -1;
    812      1.1  christos 
    813      1.1  christos   offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
    814      1.1  christos 			   sdata->header.dshb_page_size,
    815      1.1  christos 			   entry_size, sym_index);
    816      1.1  christos 
    817      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
    818      1.1  christos     return -1;
    819      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
    820      1.1  christos     return -1;
    821      1.1  christos 
    822      1.1  christos   (*parser) (buf, entry_size, entry);
    823      1.1  christos 
    824      1.1  christos   return 0;
    825      1.1  christos }
    826      1.1  christos 
    827      1.1  christos int
    828      1.1  christos bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
    829      1.1  christos 					    bfd_sym_contained_labels_table_entry *entry,
    830      1.1  christos 					    unsigned long sym_index)
    831      1.1  christos {
    832      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *);
    833      1.1  christos   unsigned long offset;
    834      1.1  christos   unsigned long entry_size = 0;
    835      1.1  christos   unsigned char buf[12];
    836      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    837      1.1  christos 
    838      1.1  christos   parser = NULL;
    839      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    840      1.1  christos   sdata = abfd->tdata.sym_data;
    841      1.1  christos 
    842      1.1  christos   if (sym_index == 0)
    843      1.1  christos     return -1;
    844      1.1  christos 
    845      1.1  christos   switch (sdata->version)
    846      1.1  christos     {
    847      1.1  christos     case BFD_SYM_VERSION_3_3:
    848      1.1  christos     case BFD_SYM_VERSION_3_2:
    849      1.1  christos       entry_size = 12;
    850      1.1  christos       parser = bfd_sym_parse_contained_labels_table_entry_v32;
    851      1.1  christos       break;
    852      1.1  christos 
    853      1.1  christos     case BFD_SYM_VERSION_3_5:
    854      1.1  christos     case BFD_SYM_VERSION_3_4:
    855      1.1  christos     case BFD_SYM_VERSION_3_1:
    856      1.1  christos     default:
    857      1.1  christos       break;
    858      1.1  christos     }
    859      1.1  christos 
    860      1.1  christos   if (parser == NULL)
    861      1.1  christos     return -1;
    862      1.1  christos 
    863      1.1  christos   offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
    864      1.1  christos 			   sdata->header.dshb_page_size,
    865      1.1  christos 			   entry_size, sym_index);
    866      1.1  christos 
    867      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
    868      1.1  christos     return -1;
    869      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
    870      1.1  christos     return -1;
    871      1.1  christos 
    872      1.1  christos   (*parser) (buf, entry_size, entry);
    873      1.1  christos 
    874      1.1  christos   return 0;
    875      1.1  christos }
    876      1.1  christos 
    877      1.1  christos int
    878      1.1  christos bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
    879      1.1  christos 					   bfd_sym_contained_types_table_entry *entry,
    880      1.1  christos 					   unsigned long sym_index)
    881      1.1  christos {
    882      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *);
    883      1.1  christos   unsigned long offset;
    884      1.1  christos   unsigned long entry_size = 0;
    885      1.1  christos   unsigned char buf[0];
    886      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    887      1.1  christos 
    888      1.1  christos   parser = NULL;
    889      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    890      1.1  christos   sdata = abfd->tdata.sym_data;
    891      1.1  christos 
    892      1.1  christos   if (sym_index == 0)
    893      1.1  christos     return -1;
    894      1.1  christos 
    895      1.1  christos   switch (sdata->version)
    896      1.1  christos     {
    897      1.1  christos     case BFD_SYM_VERSION_3_3:
    898      1.1  christos     case BFD_SYM_VERSION_3_2:
    899      1.1  christos       entry_size = 0;
    900      1.1  christos       parser = NULL;
    901      1.1  christos       break;
    902      1.1  christos 
    903      1.1  christos     case BFD_SYM_VERSION_3_5:
    904      1.1  christos     case BFD_SYM_VERSION_3_4:
    905      1.1  christos     case BFD_SYM_VERSION_3_1:
    906      1.1  christos     default:
    907      1.1  christos       break;
    908      1.1  christos     }
    909      1.1  christos 
    910      1.1  christos   if (parser == NULL)
    911      1.1  christos     return -1;
    912      1.1  christos 
    913      1.1  christos   offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
    914      1.1  christos 			   sdata->header.dshb_page_size,
    915      1.1  christos 			   entry_size, sym_index);
    916      1.1  christos 
    917      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
    918      1.1  christos     return -1;
    919      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
    920      1.1  christos     return -1;
    921      1.1  christos 
    922      1.1  christos   (*parser) (buf, entry_size, entry);
    923      1.1  christos 
    924      1.1  christos   return 0;
    925      1.1  christos }
    926      1.1  christos 
    927      1.1  christos int
    928      1.1  christos bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
    929      1.1  christos 						 bfd_sym_file_references_index_table_entry *entry,
    930      1.1  christos 						 unsigned long sym_index)
    931      1.1  christos {
    932      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *);
    933      1.1  christos   unsigned long offset;
    934      1.1  christos   unsigned long entry_size = 0;
    935      1.1  christos   unsigned char buf[0];
    936      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    937      1.1  christos 
    938      1.1  christos   parser = NULL;
    939      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    940      1.1  christos   sdata = abfd->tdata.sym_data;
    941      1.1  christos 
    942      1.1  christos   if (sym_index == 0)
    943      1.1  christos     return -1;
    944      1.1  christos 
    945      1.1  christos   switch (sdata->version)
    946      1.1  christos     {
    947      1.1  christos     case BFD_SYM_VERSION_3_3:
    948      1.1  christos     case BFD_SYM_VERSION_3_2:
    949      1.1  christos       entry_size = 0;
    950      1.1  christos       parser = NULL;
    951      1.1  christos       break;
    952      1.1  christos 
    953      1.1  christos     case BFD_SYM_VERSION_3_5:
    954      1.1  christos     case BFD_SYM_VERSION_3_4:
    955      1.1  christos     case BFD_SYM_VERSION_3_1:
    956      1.1  christos     default:
    957      1.1  christos       break;
    958      1.1  christos     }
    959      1.1  christos 
    960      1.1  christos   if (parser == NULL)
    961      1.1  christos     return -1;
    962      1.1  christos 
    963      1.1  christos   offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
    964      1.1  christos 			   sdata->header.dshb_page_size,
    965      1.1  christos 			   entry_size, sym_index);
    966      1.1  christos 
    967      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
    968      1.1  christos     return -1;
    969      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
    970      1.1  christos     return -1;
    971      1.1  christos 
    972      1.1  christos   (*parser) (buf, entry_size, entry);
    973      1.1  christos 
    974      1.1  christos   return 0;
    975      1.1  christos }
    976      1.1  christos 
    977      1.1  christos int
    978      1.1  christos bfd_sym_fetch_constant_pool_entry (bfd *abfd,
    979      1.1  christos 				   bfd_sym_constant_pool_entry *entry,
    980      1.1  christos 				   unsigned long sym_index)
    981      1.1  christos {
    982      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *);
    983      1.1  christos   unsigned long offset;
    984      1.1  christos   unsigned long entry_size = 0;
    985      1.1  christos   unsigned char buf[0];
    986      1.1  christos   bfd_sym_data_struct *sdata = NULL;
    987      1.1  christos 
    988      1.1  christos   parser = NULL;
    989      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
    990      1.1  christos   sdata = abfd->tdata.sym_data;
    991      1.1  christos 
    992      1.1  christos   if (sym_index == 0)
    993      1.1  christos     return -1;
    994      1.1  christos 
    995      1.1  christos   switch (sdata->version)
    996      1.1  christos     {
    997      1.1  christos     case BFD_SYM_VERSION_3_3:
    998      1.1  christos     case BFD_SYM_VERSION_3_2:
    999      1.1  christos       entry_size = 0;
   1000      1.1  christos       parser = NULL;
   1001      1.1  christos       break;
   1002      1.1  christos 
   1003      1.1  christos     case BFD_SYM_VERSION_3_5:
   1004      1.1  christos     case BFD_SYM_VERSION_3_4:
   1005      1.1  christos     case BFD_SYM_VERSION_3_1:
   1006      1.1  christos     default:
   1007      1.1  christos       break;
   1008      1.1  christos     }
   1009      1.1  christos 
   1010      1.1  christos   if (parser == NULL)
   1011      1.1  christos     return -1;
   1012      1.1  christos 
   1013      1.1  christos   offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
   1014      1.1  christos 			   sdata->header.dshb_page_size,
   1015      1.1  christos 			   entry_size, sym_index);
   1016      1.1  christos 
   1017      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
   1018      1.1  christos     return -1;
   1019      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
   1020      1.1  christos     return -1;
   1021      1.1  christos 
   1022      1.1  christos   (*parser) (buf, entry_size, entry);
   1023      1.1  christos 
   1024      1.1  christos   return 0;
   1025      1.1  christos }
   1026      1.1  christos 
   1027      1.1  christos int
   1028      1.1  christos bfd_sym_fetch_type_table_entry (bfd *abfd,
   1029      1.1  christos 				bfd_sym_type_table_entry *entry,
   1030      1.1  christos 				unsigned long sym_index)
   1031      1.1  christos {
   1032      1.1  christos   void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *);
   1033      1.1  christos   unsigned long offset;
   1034      1.1  christos   unsigned long entry_size = 0;
   1035      1.1  christos   unsigned char buf[4];
   1036      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   1037      1.1  christos 
   1038      1.1  christos   parser = NULL;
   1039      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1040      1.1  christos   sdata = abfd->tdata.sym_data;
   1041      1.1  christos 
   1042      1.1  christos   switch (sdata->version)
   1043      1.1  christos     {
   1044      1.1  christos     case BFD_SYM_VERSION_3_3:
   1045      1.1  christos     case BFD_SYM_VERSION_3_2:
   1046      1.1  christos       entry_size = 4;
   1047      1.1  christos       parser = bfd_sym_parse_type_table_entry_v32;
   1048      1.1  christos       break;
   1049      1.1  christos 
   1050      1.1  christos     case BFD_SYM_VERSION_3_5:
   1051      1.1  christos     case BFD_SYM_VERSION_3_4:
   1052      1.1  christos     case BFD_SYM_VERSION_3_1:
   1053      1.1  christos     default:
   1054      1.1  christos       break;
   1055      1.1  christos     }
   1056      1.1  christos 
   1057      1.1  christos   if (parser == NULL)
   1058      1.1  christos     return -1;
   1059      1.1  christos 
   1060      1.1  christos   offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
   1061      1.1  christos 			   sdata->header.dshb_page_size,
   1062      1.1  christos 			   entry_size, sym_index);
   1063      1.1  christos 
   1064      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
   1065      1.1  christos     return -1;
   1066      1.1  christos   if (bfd_bread (buf, entry_size, abfd) != entry_size)
   1067      1.1  christos     return -1;
   1068      1.1  christos 
   1069      1.1  christos   (*parser) (buf, entry_size, entry);
   1070      1.1  christos 
   1071      1.1  christos   return 0;
   1072      1.1  christos }
   1073      1.1  christos 
   1074      1.1  christos int
   1075      1.1  christos bfd_sym_fetch_type_information_table_entry (bfd *abfd,
   1076      1.1  christos 					    bfd_sym_type_information_table_entry *entry,
   1077      1.1  christos 					    unsigned long offset)
   1078      1.1  christos {
   1079      1.1  christos   unsigned char buf[4];
   1080      1.1  christos 
   1081      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1082      1.1  christos 
   1083      1.1  christos   if (offset == 0)
   1084      1.1  christos     return -1;
   1085      1.1  christos 
   1086      1.1  christos   if (bfd_seek (abfd, offset, SEEK_SET) < 0)
   1087      1.1  christos     return -1;
   1088      1.1  christos 
   1089      1.1  christos   if (bfd_bread (buf, 4, abfd) != 4)
   1090      1.1  christos     return -1;
   1091      1.1  christos   entry->nte_index = bfd_getb32 (buf);
   1092      1.1  christos 
   1093      1.1  christos   if (bfd_bread (buf, 2, abfd) != 2)
   1094      1.1  christos     return -1;
   1095      1.1  christos   entry->physical_size = bfd_getb16 (buf);
   1096      1.1  christos 
   1097      1.1  christos   if (entry->physical_size & 0x8000)
   1098      1.1  christos     {
   1099      1.1  christos       if (bfd_bread (buf, 4, abfd) != 4)
   1100      1.1  christos 	return -1;
   1101      1.1  christos       entry->physical_size &= 0x7fff;
   1102      1.1  christos       entry->logical_size = bfd_getb32 (buf);
   1103      1.1  christos       entry->offset = offset + 10;
   1104      1.1  christos     }
   1105      1.1  christos   else
   1106      1.1  christos     {
   1107      1.1  christos       if (bfd_bread (buf, 2, abfd) != 2)
   1108      1.1  christos 	return -1;
   1109      1.1  christos       entry->physical_size &= 0x7fff;
   1110      1.1  christos       entry->logical_size = bfd_getb16 (buf);
   1111      1.1  christos       entry->offset = offset + 8;
   1112      1.1  christos     }
   1113      1.1  christos 
   1114      1.1  christos   return 0;
   1115      1.1  christos }
   1116      1.1  christos 
   1117      1.1  christos int
   1118      1.1  christos bfd_sym_fetch_type_table_information (bfd *abfd,
   1119      1.1  christos 				      bfd_sym_type_information_table_entry *entry,
   1120      1.1  christos 				      unsigned long sym_index)
   1121      1.1  christos {
   1122      1.1  christos   bfd_sym_type_table_entry tindex;
   1123      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   1124      1.1  christos 
   1125      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1126      1.1  christos   sdata = abfd->tdata.sym_data;
   1127      1.1  christos 
   1128      1.1  christos   if (sdata->header.dshb_tte.dti_object_count <= 99)
   1129      1.1  christos     return -1;
   1130      1.1  christos   if (sym_index < 100)
   1131      1.1  christos     return -1;
   1132      1.1  christos 
   1133      1.1  christos   if (bfd_sym_fetch_type_table_entry (abfd, &tindex, sym_index - 100) < 0)
   1134      1.1  christos     return -1;
   1135      1.1  christos   if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
   1136      1.1  christos     return -1;
   1137      1.1  christos 
   1138      1.1  christos   return 0;
   1139      1.1  christos }
   1140      1.1  christos 
   1141      1.1  christos const unsigned char *
   1142      1.1  christos bfd_sym_symbol_name (bfd *abfd, unsigned long sym_index)
   1143      1.1  christos {
   1144      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   1145      1.1  christos 
   1146      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1147      1.1  christos   sdata = abfd->tdata.sym_data;
   1148      1.1  christos 
   1149      1.1  christos   if (sym_index == 0)
   1150      1.1  christos     return (const unsigned char *) "";
   1151      1.1  christos 
   1152      1.1  christos   sym_index *= 2;
   1153      1.1  christos   if ((sym_index / sdata->header.dshb_page_size)
   1154      1.1  christos       > sdata->header.dshb_nte.dti_page_count)
   1155      1.1  christos     return (const unsigned char *) "\09[INVALID]";
   1156      1.1  christos 
   1157      1.1  christos   return (const unsigned char *) sdata->name_table + sym_index;
   1158      1.1  christos }
   1159      1.1  christos 
   1160      1.1  christos const unsigned char *
   1161      1.1  christos bfd_sym_module_name (bfd *abfd, unsigned long sym_index)
   1162      1.1  christos {
   1163      1.1  christos   bfd_sym_modules_table_entry entry;
   1164      1.1  christos 
   1165      1.1  christos   if (bfd_sym_fetch_modules_table_entry (abfd, &entry, sym_index) < 0)
   1166      1.1  christos     return (const unsigned char *) "\09[INVALID]";
   1167      1.1  christos 
   1168      1.1  christos   return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
   1169      1.1  christos }
   1170      1.1  christos 
   1171      1.1  christos const char *
   1172      1.1  christos bfd_sym_unparse_storage_kind (enum bfd_sym_storage_kind kind)
   1173      1.1  christos {
   1174      1.1  christos   switch (kind)
   1175      1.1  christos     {
   1176      1.1  christos     case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
   1177      1.1  christos     case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
   1178      1.1  christos     case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
   1179      1.1  christos     case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
   1180      1.1  christos     default: return "[UNKNOWN]";
   1181      1.1  christos     }
   1182      1.1  christos }
   1183      1.1  christos 
   1184      1.1  christos const char *
   1185      1.1  christos bfd_sym_unparse_storage_class (enum bfd_sym_storage_class kind)
   1186      1.1  christos {
   1187      1.1  christos   switch (kind)
   1188      1.1  christos     {
   1189      1.1  christos     case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
   1190      1.1  christos     case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
   1191      1.1  christos     case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
   1192      1.1  christos     case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
   1193      1.1  christos     case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
   1194      1.1  christos     case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
   1195      1.1  christos     case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
   1196      1.1  christos     case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
   1197      1.1  christos     default: return "[UNKNOWN]";
   1198      1.1  christos     }
   1199      1.1  christos }
   1200      1.1  christos 
   1201      1.1  christos const char *
   1202      1.1  christos bfd_sym_unparse_module_kind (enum bfd_sym_module_kind kind)
   1203      1.1  christos {
   1204      1.1  christos   switch (kind)
   1205      1.1  christos     {
   1206      1.1  christos     case BFD_SYM_MODULE_KIND_NONE: return "NONE";
   1207      1.1  christos     case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
   1208      1.1  christos     case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
   1209      1.1  christos     case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
   1210      1.1  christos     case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
   1211      1.1  christos     case BFD_SYM_MODULE_KIND_DATA: return "DATA";
   1212      1.1  christos     case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
   1213      1.1  christos     default: return "[UNKNOWN]";
   1214      1.1  christos     }
   1215      1.1  christos }
   1216      1.1  christos 
   1217      1.1  christos const char *
   1218      1.1  christos bfd_sym_unparse_symbol_scope (enum bfd_sym_symbol_scope scope)
   1219      1.1  christos {
   1220      1.1  christos   switch (scope)
   1221      1.1  christos     {
   1222      1.1  christos     case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
   1223      1.1  christos     case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
   1224      1.1  christos     default:
   1225      1.1  christos       return "[UNKNOWN]";
   1226      1.1  christos     }
   1227      1.1  christos }
   1228      1.1  christos 
   1229      1.1  christos void
   1230      1.1  christos bfd_sym_print_file_reference (bfd *abfd,
   1231      1.1  christos 			      FILE *f,
   1232      1.1  christos 			      bfd_sym_file_reference *entry)
   1233      1.1  christos {
   1234      1.1  christos   bfd_sym_file_references_table_entry frtentry;
   1235      1.1  christos   int ret;
   1236      1.1  christos 
   1237      1.1  christos   ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
   1238      1.1  christos 						   entry->fref_frte_index);
   1239      1.1  christos   fprintf (f, "FILE ");
   1240      1.1  christos 
   1241      1.1  christos   if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
   1242      1.1  christos     fprintf (f, "[INVALID]");
   1243      1.1  christos   else
   1244      1.1  christos     fprintf (f, "\"%.*s\"",
   1245      1.1  christos 	     bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
   1246      1.1  christos 	     &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
   1247      1.1  christos 
   1248      1.1  christos   fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
   1249      1.1  christos }
   1250      1.1  christos 
   1251      1.1  christos void
   1252      1.1  christos bfd_sym_print_resources_table_entry (bfd *abfd,
   1253      1.1  christos 				     FILE *f,
   1254      1.1  christos 				     bfd_sym_resources_table_entry *entry)
   1255      1.1  christos {
   1256      1.1  christos   fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
   1257      1.1  christos 	   bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
   1258      1.1  christos 	   &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
   1259      1.1  christos 	   entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
   1260      1.1  christos 	   entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
   1261      1.1  christos }
   1262      1.1  christos 
   1263      1.1  christos void
   1264      1.1  christos bfd_sym_print_modules_table_entry (bfd *abfd,
   1265      1.1  christos 				   FILE *f,
   1266      1.1  christos 				   bfd_sym_modules_table_entry *entry)
   1267      1.1  christos {
   1268      1.1  christos   fprintf (f, "\"%.*s\" (NTE %lu)",
   1269      1.1  christos 	   bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
   1270      1.1  christos 	   &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
   1271      1.1  christos 	   entry->mte_nte_index);
   1272      1.1  christos 
   1273      1.1  christos   fprintf (f, "\n            ");
   1274      1.1  christos 
   1275      1.1  christos   bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
   1276      1.1  christos   fprintf (f, " range %lu -- %lu",
   1277      1.1  christos 	   entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
   1278      1.1  christos 
   1279      1.1  christos   fprintf (f, "\n            ");
   1280      1.1  christos 
   1281      1.1  christos   fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
   1282      1.1  christos   fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
   1283      1.1  christos 
   1284      1.1  christos   fprintf (f, ", RTE %lu, offset %lu, size %lu",
   1285      1.1  christos 	   entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
   1286      1.1  christos 
   1287      1.1  christos   fprintf (f, "\n            ");
   1288      1.1  christos 
   1289      1.1  christos   fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
   1290      1.1  christos 	   entry->mte_cmte_index, entry->mte_cvte_index,
   1291      1.1  christos 	   entry->mte_clte_index, entry->mte_ctte_index,
   1292      1.1  christos 	   entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
   1293      1.1  christos 
   1294      1.1  christos   if (entry->mte_parent != 0)
   1295      1.1  christos     fprintf (f, ", parent %lu", entry->mte_parent);
   1296      1.1  christos   else
   1297      1.1  christos     fprintf (f, ", no parent");
   1298      1.1  christos 
   1299      1.1  christos   if (entry->mte_cmte_index != 0)
   1300      1.1  christos     fprintf (f, ", child %lu", entry->mte_cmte_index);
   1301      1.1  christos   else
   1302      1.1  christos     fprintf (f, ", no child");
   1303      1.1  christos }
   1304      1.1  christos 
   1305      1.1  christos void
   1306      1.1  christos bfd_sym_print_file_references_table_entry (bfd *abfd,
   1307      1.1  christos 					   FILE *f,
   1308      1.1  christos 					   bfd_sym_file_references_table_entry *entry)
   1309      1.1  christos {
   1310      1.1  christos   switch (entry->generic.type)
   1311      1.1  christos     {
   1312      1.1  christos     case BFD_SYM_FILE_NAME_INDEX:
   1313      1.1  christos       fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
   1314      1.1  christos 	       bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
   1315      1.1  christos 	       &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
   1316      1.1  christos 	       entry->filename.nte_index);
   1317      1.1  christos 
   1318      1.1  christos       fprintf (f, "[UNIMPLEMENTED]");
   1319      1.1  christos       /* printModDate (entry->filename.mod_date); */
   1320      1.1  christos       fprintf (f, " (0x%lx)", entry->filename.mod_date);
   1321      1.1  christos       break;
   1322      1.1  christos 
   1323      1.1  christos     case BFD_SYM_END_OF_LIST:
   1324      1.1  christos       fprintf (f, "END");
   1325      1.1  christos       break;
   1326      1.1  christos 
   1327      1.1  christos     default:
   1328      1.1  christos       fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
   1329      1.1  christos 	       bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
   1330      1.1  christos 	       &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
   1331      1.1  christos 	       entry->entry.mte_index,
   1332      1.1  christos 	       entry->entry.file_offset);
   1333      1.1  christos       break;
   1334      1.1  christos     }
   1335      1.1  christos }
   1336      1.1  christos 
   1337      1.1  christos void
   1338      1.1  christos bfd_sym_print_contained_modules_table_entry (bfd *abfd,
   1339      1.1  christos 					     FILE *f,
   1340      1.1  christos 					     bfd_sym_contained_modules_table_entry *entry)
   1341      1.1  christos {
   1342      1.1  christos   switch (entry->generic.type)
   1343      1.1  christos     {
   1344      1.1  christos     case BFD_SYM_END_OF_LIST:
   1345      1.1  christos       fprintf (f, "END");
   1346      1.1  christos       break;
   1347      1.1  christos 
   1348      1.1  christos     default:
   1349      1.1  christos       fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
   1350      1.1  christos 	       bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
   1351      1.1  christos 	       &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
   1352      1.1  christos 	       entry->entry.mte_index,
   1353      1.1  christos 	       entry->entry.nte_index);
   1354      1.1  christos       break;
   1355      1.1  christos     }
   1356      1.1  christos }
   1357      1.1  christos 
   1358      1.1  christos void
   1359      1.1  christos bfd_sym_print_contained_variables_table_entry (bfd *abfd,
   1360      1.1  christos 					       FILE *f,
   1361      1.1  christos 					       bfd_sym_contained_variables_table_entry *entry)
   1362      1.1  christos {
   1363      1.1  christos   if (entry->generic.type == BFD_SYM_END_OF_LIST)
   1364      1.1  christos     {
   1365      1.1  christos       fprintf (f, "END");
   1366      1.1  christos       return;
   1367      1.1  christos     }
   1368      1.1  christos 
   1369      1.1  christos   if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
   1370      1.1  christos     {
   1371      1.1  christos       bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
   1372      1.1  christos       fprintf (f, " offset %lu", entry->file.fref.fref_offset);
   1373      1.1  christos       return;
   1374      1.1  christos     }
   1375      1.1  christos 
   1376      1.1  christos   fprintf (f, "\"%.*s\" (NTE %lu)",
   1377      1.1  christos 	   bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
   1378      1.1  christos 	   &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
   1379      1.1  christos 	   entry->entry.nte_index);
   1380      1.1  christos 
   1381      1.1  christos   fprintf (f, ", TTE %lu", entry->entry.tte_index);
   1382      1.1  christos   fprintf (f, ", offset %lu", entry->entry.file_delta);
   1383      1.1  christos   fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
   1384      1.1  christos 
   1385      1.1  christos   if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
   1386      1.1  christos     fprintf (f, ", latype %s, laclass %s, laoffset %lu",
   1387      1.1  christos 	     bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
   1388      1.1  christos 	     bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
   1389      1.1  christos 	     entry->entry.address.scstruct.sca_offset);
   1390      1.1  christos   else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
   1391      1.1  christos     {
   1392      1.1  christos       unsigned long i;
   1393      1.1  christos 
   1394      1.1  christos       fprintf (f, ", la [");
   1395      1.1  christos       for (i = 0; i < entry->entry.la_size; i++)
   1396      1.1  christos 	fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
   1397      1.1  christos       fprintf (f, "]");
   1398      1.1  christos     }
   1399      1.1  christos   else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
   1400      1.1  christos     fprintf (f, ", bigla %lu, biglakind %u",
   1401      1.1  christos 	     entry->entry.address.biglastruct.big_la,
   1402      1.1  christos 	     entry->entry.address.biglastruct.big_la_kind);
   1403      1.1  christos 
   1404      1.1  christos   else
   1405      1.1  christos     fprintf (f, ", la [INVALID]");
   1406      1.1  christos }
   1407      1.1  christos 
   1408      1.1  christos void
   1409      1.1  christos bfd_sym_print_contained_statements_table_entry (bfd *abfd,
   1410      1.1  christos 						FILE *f,
   1411      1.1  christos 						bfd_sym_contained_statements_table_entry *entry)
   1412      1.1  christos {
   1413      1.1  christos   if (entry->generic.type == BFD_SYM_END_OF_LIST)
   1414      1.1  christos     {
   1415      1.1  christos       fprintf (f, "END");
   1416      1.1  christos       return;
   1417      1.1  christos     }
   1418      1.1  christos 
   1419      1.1  christos   if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
   1420      1.1  christos     {
   1421      1.1  christos       bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
   1422      1.1  christos       fprintf (f, " offset %lu", entry->file.fref.fref_offset);
   1423      1.1  christos       return;
   1424      1.1  christos     }
   1425      1.1  christos 
   1426      1.1  christos   fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
   1427      1.1  christos 	   bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
   1428      1.1  christos 	   &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
   1429      1.1  christos 	   entry->entry.mte_index,
   1430      1.1  christos 	   entry->entry.mte_offset,
   1431      1.1  christos 	   entry->entry.file_delta);
   1432      1.1  christos }
   1433      1.1  christos 
   1434      1.1  christos void
   1435      1.1  christos bfd_sym_print_contained_labels_table_entry (bfd *abfd,
   1436      1.1  christos 					    FILE *f,
   1437      1.1  christos 					    bfd_sym_contained_labels_table_entry *entry)
   1438      1.1  christos {
   1439      1.1  christos   if (entry->generic.type == BFD_SYM_END_OF_LIST)
   1440      1.1  christos     {
   1441      1.1  christos       fprintf (f, "END");
   1442      1.1  christos       return;
   1443      1.1  christos     }
   1444      1.1  christos 
   1445      1.1  christos   if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
   1446      1.1  christos     {
   1447      1.1  christos       bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
   1448      1.1  christos       fprintf (f, " offset %lu", entry->file.fref.fref_offset);
   1449      1.1  christos       return;
   1450      1.1  christos     }
   1451      1.1  christos 
   1452      1.1  christos   fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
   1453      1.1  christos 	   bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
   1454      1.1  christos 	   &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
   1455      1.1  christos 	   entry->entry.mte_index,
   1456      1.1  christos 	   entry->entry.mte_offset,
   1457      1.1  christos 	   entry->entry.file_delta,
   1458      1.1  christos 	   bfd_sym_unparse_symbol_scope (entry->entry.scope));
   1459      1.1  christos }
   1460      1.1  christos 
   1461      1.1  christos void
   1462      1.1  christos bfd_sym_print_contained_types_table_entry (bfd *abfd ATTRIBUTE_UNUSED,
   1463      1.1  christos 					   FILE *f,
   1464      1.1  christos 					   bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED)
   1465      1.1  christos {
   1466      1.1  christos   fprintf (f, "[UNIMPLEMENTED]");
   1467      1.1  christos }
   1468      1.1  christos 
   1469      1.1  christos const char *
   1470      1.1  christos bfd_sym_type_operator_name (unsigned char num)
   1471      1.1  christos {
   1472      1.1  christos   switch (num)
   1473      1.1  christos     {
   1474      1.1  christos     case 1: return "TTE";
   1475      1.1  christos     case 2: return "PointerTo";
   1476      1.1  christos     case 3: return "ScalarOf";
   1477      1.1  christos     case 4: return "ConstantOf";
   1478      1.1  christos     case 5: return "EnumerationOf";
   1479      1.1  christos     case 6: return "VectorOf";
   1480      1.1  christos     case 7: return "RecordOf";
   1481      1.1  christos     case 8: return "UnionOf";
   1482      1.1  christos     case 9: return "SubRangeOf";
   1483      1.1  christos     case 10: return "SetOf";
   1484      1.1  christos     case 11: return "NamedTypeOf";
   1485      1.1  christos     case 12: return "ProcOf";
   1486      1.1  christos     case 13: return "ValueOf";
   1487      1.1  christos     case 14: return "ArrayOf";
   1488      1.1  christos     default: return "[UNKNOWN OPERATOR]";
   1489      1.1  christos     }
   1490      1.1  christos }
   1491      1.1  christos 
   1492      1.1  christos const char *
   1493      1.1  christos bfd_sym_type_basic_name (unsigned char num)
   1494      1.1  christos {
   1495      1.1  christos   switch (num)
   1496      1.1  christos     {
   1497      1.1  christos     case 0: return "void";
   1498      1.1  christos     case 1: return "pascal string";
   1499      1.1  christos     case 2: return "unsigned long";
   1500      1.1  christos     case 3: return "signed long";
   1501      1.1  christos     case 4: return "extended (10 bytes)";
   1502      1.1  christos     case 5: return "pascal boolean (1 byte)";
   1503      1.1  christos     case 6: return "unsigned byte";
   1504      1.1  christos     case 7: return "signed byte";
   1505      1.1  christos     case 8: return "character (1 byte)";
   1506      1.1  christos     case 9: return "wide character (2 bytes)";
   1507      1.1  christos     case 10: return "unsigned short";
   1508      1.1  christos     case 11: return "signed short";
   1509      1.1  christos     case 12: return "singled";
   1510      1.1  christos     case 13: return "double";
   1511      1.1  christos     case 14: return "extended (12 bytes)";
   1512      1.1  christos     case 15: return "computational (8 bytes)";
   1513      1.1  christos     case 16: return "c string";
   1514      1.1  christos     case 17: return "as-is string";
   1515      1.1  christos     default: return "[UNKNOWN BASIC TYPE]";
   1516      1.1  christos     }
   1517      1.1  christos }
   1518      1.1  christos 
   1519      1.1  christos int
   1520      1.1  christos bfd_sym_fetch_long (unsigned char *buf,
   1521      1.1  christos 		    unsigned long len,
   1522      1.1  christos 		    unsigned long offset,
   1523      1.1  christos 		    unsigned long *offsetptr,
   1524      1.1  christos 		    long *value)
   1525      1.1  christos {
   1526      1.1  christos   int ret;
   1527      1.1  christos 
   1528      1.1  christos   if (offset >= len)
   1529      1.1  christos     {
   1530      1.1  christos       *value = 0;
   1531      1.1  christos       offset += 0;
   1532      1.1  christos       ret = -1;
   1533      1.1  christos     }
   1534      1.1  christos   else if (! (buf[offset] & 0x80))
   1535      1.1  christos     {
   1536      1.1  christos       *value = buf[offset];
   1537      1.1  christos       offset += 1;
   1538      1.1  christos       ret = 0;
   1539      1.1  christos     }
   1540      1.1  christos   else if (buf[offset] == 0xc0)
   1541      1.1  christos     {
   1542      1.1  christos       if ((offset + 5) > len)
   1543      1.1  christos 	{
   1544      1.1  christos 	  *value = 0;
   1545      1.1  christos 	  offset = len;
   1546      1.1  christos 	  ret = -1;
   1547      1.1  christos 	}
   1548      1.1  christos       else
   1549      1.1  christos 	{
   1550      1.1  christos 	  *value = bfd_getb32 (buf + offset + 1);
   1551      1.1  christos 	  offset += 5;
   1552      1.1  christos 	  ret = 0;
   1553      1.1  christos 	}
   1554      1.1  christos     }
   1555      1.1  christos   else if ((buf[offset] & 0xc0) == 0xc0)
   1556      1.1  christos     {
   1557      1.1  christos       *value =  -(buf[offset] & 0x3f);
   1558      1.1  christos       offset += 1;
   1559      1.1  christos       ret = 0;
   1560      1.1  christos     }
   1561      1.1  christos   else if ((buf[offset] & 0xc0) == 0x80)
   1562      1.1  christos     {
   1563      1.1  christos       if ((offset + 2) > len)
   1564      1.1  christos 	{
   1565      1.1  christos 	  *value = 0;
   1566      1.1  christos 	  offset = len;
   1567      1.1  christos 	  ret = -1;
   1568      1.1  christos 	}
   1569      1.1  christos       else
   1570      1.1  christos 	{
   1571      1.1  christos 	  *value = bfd_getb16 (buf + offset) & 0x3fff;
   1572      1.1  christos 	  offset += 2;
   1573      1.1  christos 	  ret = 0;
   1574      1.1  christos 	}
   1575      1.1  christos     }
   1576      1.1  christos   else
   1577      1.1  christos     abort ();
   1578      1.1  christos 
   1579      1.1  christos   if (offsetptr != NULL)
   1580      1.1  christos     *offsetptr = offset;
   1581      1.1  christos 
   1582      1.1  christos   return ret;
   1583      1.1  christos }
   1584      1.1  christos 
   1585      1.1  christos void
   1586      1.1  christos bfd_sym_print_type_information (bfd *abfd,
   1587      1.1  christos 				FILE *f,
   1588      1.1  christos 				unsigned char *buf,
   1589      1.1  christos 				unsigned long len,
   1590      1.1  christos 				unsigned long offset,
   1591      1.1  christos 				unsigned long *offsetptr)
   1592      1.1  christos {
   1593      1.1  christos   unsigned int type;
   1594      1.1  christos 
   1595      1.1  christos   if (offset >= len)
   1596      1.1  christos     {
   1597      1.1  christos       fprintf (f, "[NULL]");
   1598      1.1  christos 
   1599      1.1  christos       if (offsetptr != NULL)
   1600      1.1  christos 	*offsetptr = offset;
   1601      1.1  christos       return;
   1602      1.1  christos   }
   1603      1.1  christos 
   1604      1.1  christos   type = buf[offset];
   1605      1.1  christos   offset++;
   1606      1.1  christos 
   1607      1.1  christos   if (! (type & 0x80))
   1608      1.1  christos     {
   1609      1.1  christos       fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
   1610      1.1  christos 
   1611      1.1  christos       if (offsetptr != NULL)
   1612      1.1  christos 	*offsetptr = offset;
   1613      1.1  christos       return;
   1614      1.1  christos     }
   1615      1.1  christos 
   1616      1.1  christos   if (type & 0x40)
   1617      1.1  christos     fprintf (f, "[packed ");
   1618      1.1  christos   else
   1619      1.1  christos     fprintf (f, "[");
   1620      1.1  christos 
   1621      1.1  christos   switch (type & 0x3f)
   1622      1.1  christos     {
   1623      1.1  christos     case 1:
   1624      1.1  christos       {
   1625      1.1  christos 	long value;
   1626      1.1  christos 	bfd_sym_type_information_table_entry tinfo;
   1627      1.1  christos 
   1628      1.1  christos 	bfd_sym_fetch_long (buf, len, offset, &offset, &value);
   1629      1.1  christos 	if (value <= 0)
   1630      1.1  christos 	  fprintf (f, "[INVALID]");
   1631      1.1  christos 	else
   1632      1.1  christos 	  {
   1633      1.1  christos 	    if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
   1634      1.1  christos 	      fprintf (f, "[INVALID]");
   1635      1.1  christos 	    else
   1636      1.1  christos 	      fprintf (f, "\"%.*s\"",
   1637      1.1  christos 		       bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
   1638      1.1  christos 		       &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
   1639      1.1  christos 	  }
   1640      1.1  christos 	fprintf (f, " (TTE %lu)", (unsigned long) value);
   1641      1.1  christos 	break;
   1642      1.1  christos       }
   1643      1.1  christos 
   1644      1.1  christos     case 2:
   1645      1.1  christos       fprintf (f, "pointer (0x%x) to ", type);
   1646      1.1  christos       bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1647      1.1  christos       break;
   1648      1.1  christos 
   1649      1.1  christos     case 3:
   1650      1.1  christos       {
   1651      1.1  christos 	long value;
   1652      1.1  christos 
   1653      1.1  christos 	fprintf (f, "scalar (0x%x) of ", type);
   1654      1.1  christos 	bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1655      1.1  christos 	bfd_sym_fetch_long (buf, len, offset, &offset, &value);
   1656      1.1  christos 	fprintf (f, " (%lu)", (unsigned long) value);
   1657      1.1  christos 	break;
   1658      1.1  christos       }
   1659      1.1  christos 
   1660      1.1  christos     case 5:
   1661      1.1  christos       {
   1662      1.1  christos 	long lower, upper, nelem;
   1663      1.1  christos 	int i;
   1664      1.1  christos 
   1665      1.1  christos 	fprintf (f, "enumeration (0x%x) of ", type);
   1666      1.1  christos 	bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1667      1.1  christos 	bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
   1668      1.1  christos 	bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
   1669      1.1  christos 	bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
   1670      1.1  christos 	fprintf (f, " from %lu to %lu with %lu elements: ",
   1671      1.1  christos 		 (unsigned long) lower, (unsigned long) upper,
   1672      1.1  christos 		 (unsigned long) nelem);
   1673      1.1  christos 
   1674      1.1  christos 	for (i = 0; i < nelem; i++)
   1675      1.1  christos 	  {
   1676      1.1  christos 	    fprintf (f, "\n                    ");
   1677      1.1  christos 	    bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1678      1.1  christos 	  }
   1679      1.1  christos 	break;
   1680      1.1  christos       }
   1681      1.1  christos 
   1682      1.1  christos     case 6:
   1683      1.1  christos       fprintf (f, "vector (0x%x)", type);
   1684      1.1  christos       fprintf (f, "\n                index ");
   1685      1.1  christos       bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1686      1.1  christos       fprintf (f, "\n                target ");
   1687      1.1  christos       bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1688      1.1  christos       break;
   1689      1.1  christos 
   1690      1.1  christos     case 7:
   1691      1.1  christos     case 8:
   1692      1.1  christos       {
   1693      1.1  christos 	long nrec, eloff, i;
   1694      1.1  christos 
   1695      1.1  christos 	if ((type & 0x3f) == 7)
   1696      1.1  christos 	  fprintf (f, "record (0x%x) of ", type);
   1697      1.1  christos 	else
   1698      1.1  christos 	  fprintf (f, "union (0x%x) of ", type);
   1699      1.1  christos 
   1700      1.1  christos 	bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
   1701      1.1  christos 	fprintf (f, "%lu elements: ", (unsigned long) nrec);
   1702      1.1  christos 
   1703      1.1  christos 	for (i = 0; i < nrec; i++)
   1704      1.1  christos 	  {
   1705      1.1  christos 	    bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
   1706      1.1  christos 	    fprintf (f, "\n                ");
   1707      1.1  christos 	    fprintf (f, "offset %lu: ", (unsigned long) eloff);
   1708      1.1  christos 	    bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1709      1.1  christos 	  }
   1710      1.1  christos 	break;
   1711      1.1  christos       }
   1712      1.1  christos 
   1713      1.1  christos     case 9:
   1714      1.1  christos       fprintf (f, "subrange (0x%x) of ", type);
   1715      1.1  christos       bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1716      1.1  christos       fprintf (f, " lower ");
   1717      1.1  christos       bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1718      1.1  christos       fprintf (f, " upper ");
   1719      1.1  christos       bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1720      1.1  christos       break;
   1721      1.1  christos 
   1722      1.1  christos   case 11:
   1723      1.1  christos     {
   1724      1.1  christos       long value;
   1725      1.1  christos 
   1726      1.1  christos       fprintf (f, "named type (0x%x) ", type);
   1727      1.1  christos       bfd_sym_fetch_long (buf, len, offset, &offset, &value);
   1728      1.1  christos       if (value <= 0)
   1729      1.1  christos 	fprintf (f, "[INVALID]");
   1730      1.1  christos       else
   1731      1.1  christos 	fprintf (f, "\"%.*s\"",
   1732      1.1  christos 		 bfd_sym_symbol_name (abfd, value)[0],
   1733      1.1  christos 		 &bfd_sym_symbol_name (abfd, value)[1]);
   1734      1.1  christos 
   1735      1.1  christos       fprintf (f, " (NTE %lu) with type ", (unsigned long) value);
   1736      1.1  christos       bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
   1737      1.1  christos       break;
   1738      1.1  christos     }
   1739      1.1  christos 
   1740      1.1  christos   default:
   1741      1.1  christos     fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
   1742      1.1  christos     break;
   1743      1.1  christos     }
   1744      1.1  christos 
   1745      1.1  christos   if (type == (0x40 | 0x6))
   1746      1.1  christos     {
   1747      1.1  christos       /* Vector.  */
   1748      1.1  christos       long n, width, m;
   1749      1.1  christos       long l;
   1750      1.1  christos       long i;
   1751      1.1  christos 
   1752      1.1  christos       bfd_sym_fetch_long (buf, len, offset, &offset, &n);
   1753      1.1  christos       bfd_sym_fetch_long (buf, len, offset, &offset, &width);
   1754      1.1  christos       bfd_sym_fetch_long (buf, len, offset, &offset, &m);
   1755      1.1  christos       /* fprintf (f, "\n                "); */
   1756      1.1  christos       fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
   1757      1.1  christos       for (i = 0; i < m; i++)
   1758      1.1  christos 	{
   1759      1.1  christos 	  bfd_sym_fetch_long (buf, len, offset, &offset, &l);
   1760      1.1  christos 	  if (i != 0)
   1761      1.1  christos 	    fprintf (f, " ");
   1762      1.1  christos 	  fprintf (f, "%ld", l);
   1763      1.1  christos 	}
   1764      1.1  christos     }
   1765      1.1  christos   else  if (type & 0x40)
   1766      1.1  christos     {
   1767      1.1  christos       /* Other packed type.  */
   1768      1.1  christos       long msb, lsb;
   1769      1.1  christos 
   1770      1.1  christos       bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
   1771      1.1  christos       bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
   1772      1.1  christos       /* fprintf (f, "\n                "); */
   1773      1.1  christos       fprintf (f, " msb %ld, lsb %ld", msb, lsb);
   1774      1.1  christos     }
   1775      1.1  christos 
   1776      1.1  christos   fprintf (f, "]");
   1777      1.1  christos 
   1778      1.1  christos   if (offsetptr != NULL)
   1779      1.1  christos     *offsetptr = offset;
   1780      1.1  christos }
   1781      1.1  christos 
   1782      1.1  christos void
   1783      1.1  christos bfd_sym_print_type_information_table_entry (bfd *abfd,
   1784      1.1  christos 					    FILE *f,
   1785      1.1  christos 					    bfd_sym_type_information_table_entry *entry)
   1786      1.1  christos {
   1787      1.1  christos   unsigned char *buf;
   1788      1.1  christos   unsigned long offset;
   1789      1.1  christos   unsigned int i;
   1790      1.1  christos 
   1791      1.1  christos   fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
   1792      1.1  christos 	   bfd_sym_symbol_name (abfd, entry->nte_index)[0],
   1793      1.1  christos 	   &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
   1794      1.1  christos 	   entry->nte_index,
   1795      1.1  christos 	   entry->physical_size, entry->offset, entry->logical_size);
   1796      1.1  christos 
   1797      1.1  christos   fprintf (f, "\n            ");
   1798      1.1  christos 
   1799  1.1.1.6  christos   if (bfd_seek (abfd, entry->offset, SEEK_SET) != 0
   1800  1.1.1.6  christos       || (buf = _bfd_malloc_and_read (abfd, entry->physical_size,
   1801  1.1.1.6  christos 				      entry->physical_size)) == NULL)
   1802      1.1  christos     {
   1803      1.1  christos       fprintf (f, "[ERROR]\n");
   1804      1.1  christos       return;
   1805      1.1  christos     }
   1806      1.1  christos 
   1807      1.1  christos   fprintf (f, "[");
   1808      1.1  christos   for (i = 0; i < entry->physical_size; i++)
   1809      1.1  christos     {
   1810      1.1  christos       if (i == 0)
   1811      1.1  christos 	fprintf (f, "0x%02x", buf[i]);
   1812      1.1  christos       else
   1813      1.1  christos 	fprintf (f, " 0x%02x", buf[i]);
   1814      1.1  christos     }
   1815      1.1  christos 
   1816      1.1  christos   fprintf (f, "]");
   1817      1.1  christos   fprintf (f, "\n            ");
   1818      1.1  christos 
   1819      1.1  christos   bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
   1820      1.1  christos 
   1821      1.1  christos   if (offset != entry->physical_size)
   1822      1.1  christos     fprintf (f, "\n            [parser used %lu bytes instead of %lu]", offset, entry->physical_size);
   1823  1.1.1.3  christos   free (buf);
   1824      1.1  christos }
   1825      1.1  christos 
   1826      1.1  christos void
   1827      1.1  christos bfd_sym_print_file_references_index_table_entry (bfd *abfd ATTRIBUTE_UNUSED,
   1828      1.1  christos 						 FILE *f,
   1829      1.1  christos 						 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED)
   1830      1.1  christos {
   1831      1.1  christos   fprintf (f, "[UNIMPLEMENTED]");
   1832      1.1  christos }
   1833      1.1  christos 
   1834      1.1  christos void
   1835      1.1  christos bfd_sym_print_constant_pool_entry (bfd *abfd ATTRIBUTE_UNUSED,
   1836      1.1  christos 				   FILE *f,
   1837      1.1  christos 				   bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED)
   1838      1.1  christos {
   1839      1.1  christos   fprintf (f, "[UNIMPLEMENTED]");
   1840      1.1  christos }
   1841      1.1  christos 
   1842      1.1  christos unsigned char *
   1843      1.1  christos bfd_sym_display_name_table_entry (bfd *abfd,
   1844      1.1  christos 				  FILE *f,
   1845      1.1  christos 				  unsigned char *entry)
   1846      1.1  christos {
   1847      1.1  christos   unsigned long sym_index;
   1848      1.1  christos   unsigned long offset;
   1849      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   1850      1.1  christos 
   1851      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1852      1.1  christos   sdata = abfd->tdata.sym_data;
   1853      1.1  christos   sym_index = (entry - sdata->name_table) / 2;
   1854      1.1  christos 
   1855      1.1  christos   if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
   1856      1.1  christos     {
   1857      1.1  christos       unsigned short length = bfd_getb16 (entry + 2);
   1858      1.1  christos       fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, length, entry + 4);
   1859      1.1  christos       offset = 2 + length + 1;
   1860      1.1  christos     }
   1861      1.1  christos   else
   1862      1.1  christos     {
   1863      1.1  christos       if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
   1864      1.1  christos 	fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, entry[0], entry + 1);
   1865      1.1  christos 
   1866      1.1  christos       if (sdata->version >= BFD_SYM_VERSION_3_4)
   1867      1.1  christos 	offset = entry[0] + 2;
   1868      1.1  christos       else
   1869      1.1  christos 	offset = entry[0] + 1;
   1870      1.1  christos     }
   1871      1.1  christos 
   1872      1.1  christos   return (entry + offset + (offset % 2));
   1873      1.1  christos }
   1874      1.1  christos 
   1875      1.1  christos void
   1876      1.1  christos bfd_sym_display_name_table (bfd *abfd, FILE *f)
   1877      1.1  christos {
   1878      1.1  christos   unsigned long name_table_len;
   1879      1.1  christos   unsigned char *name_table, *name_table_end, *cur;
   1880      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   1881      1.1  christos 
   1882      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1883      1.1  christos   sdata = abfd->tdata.sym_data;
   1884      1.1  christos 
   1885      1.1  christos   name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
   1886      1.1  christos   name_table = sdata->name_table;
   1887      1.1  christos   name_table_end = name_table + name_table_len;
   1888      1.1  christos 
   1889      1.1  christos   fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
   1890      1.1  christos 
   1891      1.1  christos   cur = name_table;
   1892      1.1  christos   for (;;)
   1893      1.1  christos     {
   1894      1.1  christos       cur = bfd_sym_display_name_table_entry (abfd, f, cur);
   1895      1.1  christos       if (cur >= name_table_end)
   1896      1.1  christos 	break;
   1897      1.1  christos     }
   1898      1.1  christos }
   1899      1.1  christos 
   1900      1.1  christos void
   1901      1.1  christos bfd_sym_display_resources_table (bfd *abfd, FILE *f)
   1902      1.1  christos {
   1903      1.1  christos   unsigned long i;
   1904      1.1  christos   bfd_sym_resources_table_entry entry;
   1905      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   1906      1.1  christos 
   1907      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1908      1.1  christos   sdata = abfd->tdata.sym_data;
   1909      1.1  christos 
   1910      1.1  christos   fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
   1911      1.1  christos 	   sdata->header.dshb_rte.dti_object_count);
   1912      1.1  christos 
   1913      1.1  christos   for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
   1914      1.1  christos     {
   1915      1.1  christos       if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
   1916      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   1917      1.1  christos       else
   1918      1.1  christos 	{
   1919      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   1920      1.1  christos 	  bfd_sym_print_resources_table_entry (abfd, f, &entry);
   1921      1.1  christos 	  fprintf (f, "\n");
   1922      1.1  christos 	}
   1923      1.1  christos     }
   1924      1.1  christos }
   1925      1.1  christos 
   1926      1.1  christos void
   1927      1.1  christos bfd_sym_display_modules_table (bfd *abfd, FILE *f)
   1928      1.1  christos {
   1929      1.1  christos   unsigned long i;
   1930      1.1  christos   bfd_sym_modules_table_entry entry;
   1931      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   1932      1.1  christos 
   1933      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1934      1.1  christos   sdata = abfd->tdata.sym_data;
   1935      1.1  christos 
   1936      1.1  christos   fprintf (f, "module table (MTE) contains %lu objects:\n\n",
   1937      1.1  christos 	   sdata->header.dshb_mte.dti_object_count);
   1938      1.1  christos 
   1939      1.1  christos   for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
   1940      1.1  christos     {
   1941      1.1  christos       if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
   1942      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   1943      1.1  christos       else
   1944      1.1  christos 	{
   1945      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   1946      1.1  christos 	  bfd_sym_print_modules_table_entry (abfd, f, &entry);
   1947      1.1  christos 	  fprintf (f, "\n");
   1948      1.1  christos 	}
   1949      1.1  christos     }
   1950      1.1  christos }
   1951      1.1  christos 
   1952      1.1  christos void
   1953      1.1  christos bfd_sym_display_file_references_table (bfd *abfd, FILE *f)
   1954      1.1  christos {
   1955      1.1  christos   unsigned long i;
   1956      1.1  christos   bfd_sym_file_references_table_entry entry;
   1957      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   1958      1.1  christos 
   1959      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1960      1.1  christos   sdata = abfd->tdata.sym_data;
   1961      1.1  christos 
   1962      1.1  christos   fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
   1963      1.1  christos 	   sdata->header.dshb_frte.dti_object_count);
   1964      1.1  christos 
   1965      1.1  christos   for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
   1966      1.1  christos     {
   1967      1.1  christos       if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
   1968      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   1969      1.1  christos       else
   1970      1.1  christos 	{
   1971      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   1972      1.1  christos 	  bfd_sym_print_file_references_table_entry (abfd, f, &entry);
   1973      1.1  christos 	  fprintf (f, "\n");
   1974      1.1  christos 	}
   1975      1.1  christos     }
   1976      1.1  christos }
   1977      1.1  christos 
   1978      1.1  christos void
   1979      1.1  christos bfd_sym_display_contained_modules_table (bfd *abfd, FILE *f)
   1980      1.1  christos {
   1981      1.1  christos   unsigned long i;
   1982      1.1  christos   bfd_sym_contained_modules_table_entry entry;
   1983      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   1984      1.1  christos 
   1985      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   1986      1.1  christos   sdata = abfd->tdata.sym_data;
   1987      1.1  christos 
   1988      1.1  christos   fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
   1989      1.1  christos 	   sdata->header.dshb_cmte.dti_object_count);
   1990      1.1  christos 
   1991      1.1  christos   for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
   1992      1.1  christos     {
   1993      1.1  christos       if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
   1994      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   1995      1.1  christos       else
   1996      1.1  christos 	{
   1997      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   1998      1.1  christos 	  bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
   1999      1.1  christos 	  fprintf (f, "\n");
   2000      1.1  christos 	}
   2001      1.1  christos     }
   2002      1.1  christos }
   2003      1.1  christos 
   2004      1.1  christos void
   2005      1.1  christos bfd_sym_display_contained_variables_table (bfd *abfd, FILE *f)
   2006      1.1  christos {
   2007      1.1  christos   unsigned long i;
   2008      1.1  christos   bfd_sym_contained_variables_table_entry entry;
   2009      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   2010      1.1  christos 
   2011      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   2012      1.1  christos   sdata = abfd->tdata.sym_data;
   2013      1.1  christos 
   2014      1.1  christos   fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
   2015      1.1  christos 	   sdata->header.dshb_cvte.dti_object_count);
   2016      1.1  christos 
   2017      1.1  christos   for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
   2018      1.1  christos     {
   2019      1.1  christos       if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
   2020      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   2021      1.1  christos       else
   2022      1.1  christos 	{
   2023      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   2024      1.1  christos 	  bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
   2025      1.1  christos 	  fprintf (f, "\n");
   2026      1.1  christos 	}
   2027      1.1  christos     }
   2028      1.1  christos 
   2029      1.1  christos   fprintf (f, "\n");
   2030      1.1  christos }
   2031      1.1  christos 
   2032      1.1  christos void
   2033      1.1  christos bfd_sym_display_contained_statements_table (bfd *abfd, FILE *f)
   2034      1.1  christos {
   2035      1.1  christos   unsigned long i;
   2036      1.1  christos   bfd_sym_contained_statements_table_entry entry;
   2037      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   2038      1.1  christos 
   2039      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   2040      1.1  christos   sdata = abfd->tdata.sym_data;
   2041      1.1  christos 
   2042      1.1  christos   fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
   2043      1.1  christos 	   sdata->header.dshb_csnte.dti_object_count);
   2044      1.1  christos 
   2045      1.1  christos   for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
   2046      1.1  christos     {
   2047      1.1  christos       if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
   2048      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   2049      1.1  christos       else
   2050      1.1  christos 	{
   2051      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   2052      1.1  christos 	  bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
   2053      1.1  christos 	  fprintf (f, "\n");
   2054      1.1  christos 	}
   2055      1.1  christos     }
   2056      1.1  christos }
   2057      1.1  christos 
   2058      1.1  christos void
   2059      1.1  christos bfd_sym_display_contained_labels_table (bfd *abfd, FILE *f)
   2060      1.1  christos {
   2061      1.1  christos   unsigned long i;
   2062      1.1  christos   bfd_sym_contained_labels_table_entry entry;
   2063      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   2064      1.1  christos 
   2065      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   2066      1.1  christos   sdata = abfd->tdata.sym_data;
   2067      1.1  christos 
   2068      1.1  christos   fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
   2069      1.1  christos 	   sdata->header.dshb_clte.dti_object_count);
   2070      1.1  christos 
   2071      1.1  christos   for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
   2072      1.1  christos     {
   2073      1.1  christos       if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
   2074      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   2075      1.1  christos       else
   2076      1.1  christos 	{
   2077      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   2078      1.1  christos 	  bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
   2079      1.1  christos 	  fprintf (f, "\n");
   2080      1.1  christos 	}
   2081      1.1  christos     }
   2082      1.1  christos }
   2083      1.1  christos 
   2084      1.1  christos void
   2085      1.1  christos bfd_sym_display_contained_types_table (bfd *abfd, FILE *f)
   2086      1.1  christos {
   2087      1.1  christos   unsigned long i;
   2088      1.1  christos   bfd_sym_contained_types_table_entry entry;
   2089      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   2090      1.1  christos 
   2091      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   2092      1.1  christos   sdata = abfd->tdata.sym_data;
   2093      1.1  christos 
   2094      1.1  christos   fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
   2095      1.1  christos 	   sdata->header.dshb_ctte.dti_object_count);
   2096      1.1  christos 
   2097      1.1  christos   for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
   2098      1.1  christos     {
   2099      1.1  christos       if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
   2100      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   2101      1.1  christos       else
   2102      1.1  christos 	{
   2103      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   2104      1.1  christos 	  bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
   2105      1.1  christos 	  fprintf (f, "\n");
   2106      1.1  christos 	}
   2107      1.1  christos     }
   2108      1.1  christos }
   2109      1.1  christos 
   2110      1.1  christos void
   2111      1.1  christos bfd_sym_display_file_references_index_table (bfd *abfd, FILE *f)
   2112      1.1  christos {
   2113      1.1  christos   unsigned long i;
   2114      1.1  christos   bfd_sym_file_references_index_table_entry entry;
   2115      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   2116      1.1  christos 
   2117      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   2118      1.1  christos   sdata = abfd->tdata.sym_data;
   2119      1.1  christos 
   2120      1.1  christos   fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
   2121      1.1  christos 	   sdata->header.dshb_fite.dti_object_count);
   2122      1.1  christos 
   2123      1.1  christos   for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
   2124      1.1  christos     {
   2125      1.1  christos       if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
   2126      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   2127      1.1  christos       else
   2128      1.1  christos 	{
   2129      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   2130      1.1  christos 	  bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
   2131      1.1  christos 	  fprintf (f, "\n");
   2132      1.1  christos 	}
   2133      1.1  christos     }
   2134      1.1  christos }
   2135      1.1  christos 
   2136      1.1  christos void
   2137      1.1  christos bfd_sym_display_constant_pool (bfd *abfd, FILE *f)
   2138      1.1  christos {
   2139      1.1  christos   unsigned long i;
   2140      1.1  christos   bfd_sym_constant_pool_entry entry;
   2141      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   2142      1.1  christos 
   2143      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   2144      1.1  christos   sdata = abfd->tdata.sym_data;
   2145      1.1  christos 
   2146      1.1  christos   fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
   2147      1.1  christos 	   sdata->header.dshb_const.dti_object_count);
   2148      1.1  christos 
   2149      1.1  christos   for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
   2150      1.1  christos     {
   2151      1.1  christos       if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
   2152      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   2153      1.1  christos       else
   2154      1.1  christos 	{
   2155      1.1  christos 	  fprintf (f, " [%8lu] ", i);
   2156      1.1  christos 	  bfd_sym_print_constant_pool_entry (abfd, f, &entry);
   2157      1.1  christos 	  fprintf (f, "\n");
   2158      1.1  christos 	}
   2159      1.1  christos     }
   2160      1.1  christos }
   2161      1.1  christos 
   2162      1.1  christos void
   2163      1.1  christos bfd_sym_display_type_information_table (bfd *abfd, FILE *f)
   2164      1.1  christos {
   2165      1.1  christos   unsigned long i;
   2166      1.1  christos   bfd_sym_type_table_entry sym_index;
   2167      1.1  christos   bfd_sym_type_information_table_entry entry;
   2168      1.1  christos   bfd_sym_data_struct *sdata = NULL;
   2169      1.1  christos 
   2170      1.1  christos   BFD_ASSERT (bfd_sym_valid (abfd));
   2171      1.1  christos   sdata = abfd->tdata.sym_data;
   2172      1.1  christos 
   2173      1.1  christos   if (sdata->header.dshb_tte.dti_object_count > 99)
   2174      1.1  christos     fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
   2175      1.1  christos 	     sdata->header.dshb_tte.dti_object_count - 99);
   2176      1.1  christos   else
   2177      1.1  christos     {
   2178      1.1  christos       fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
   2179      1.1  christos       return;
   2180      1.1  christos     }
   2181      1.1  christos 
   2182      1.1  christos   for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
   2183      1.1  christos     {
   2184      1.1  christos       if (bfd_sym_fetch_type_table_entry (abfd, &sym_index, i - 100) < 0)
   2185      1.1  christos 	fprintf (f, " [%8lu] [INVALID]\n", i);
   2186      1.1  christos       else
   2187      1.1  christos 	{
   2188      1.1  christos 	  fprintf (f, " [%8lu] (TINFO %lu) ", i, sym_index);
   2189      1.1  christos 
   2190      1.1  christos 	  if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, sym_index) < 0)
   2191      1.1  christos 	    fprintf (f, "[INVALID]");
   2192      1.1  christos 	  else
   2193      1.1  christos 	    bfd_sym_print_type_information_table_entry (abfd, f, &entry);
   2194      1.1  christos 
   2195      1.1  christos 	  fprintf (f, "\n");
   2196      1.1  christos 	}
   2197      1.1  christos     }
   2198      1.1  christos }
   2199      1.1  christos 
   2200      1.1  christos int
   2201      1.1  christos bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
   2202      1.1  christos {
   2203      1.1  christos   asection *bfdsec;
   2204      1.1  christos   const char *name = "symbols";
   2205      1.1  christos 
   2206      1.1  christos   mdata->name_table = 0;
   2207      1.1  christos   mdata->sbfd = abfd;
   2208      1.1  christos   mdata->version = version;
   2209      1.1  christos 
   2210      1.1  christos   bfd_seek (abfd, 0, SEEK_SET);
   2211      1.1  christos   if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
   2212      1.1  christos     return -1;
   2213      1.1  christos 
   2214      1.1  christos   mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
   2215      1.1  christos   if (mdata->name_table == NULL)
   2216      1.1  christos     return -1;
   2217      1.1  christos 
   2218      1.1  christos   bfdsec = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
   2219      1.1  christos   if (bfdsec == NULL)
   2220      1.1  christos     return -1;
   2221      1.1  christos 
   2222      1.1  christos   bfdsec->vma = 0;
   2223      1.1  christos   bfdsec->lma = 0;
   2224      1.1  christos   bfdsec->size = 0;
   2225      1.1  christos   bfdsec->filepos = 0;
   2226      1.1  christos   bfdsec->alignment_power = 0;
   2227      1.1  christos 
   2228      1.1  christos   abfd->tdata.sym_data = mdata;
   2229      1.1  christos 
   2230      1.1  christos   return 0;
   2231      1.1  christos }
   2232      1.1  christos 
   2233  1.1.1.6  christos bfd_cleanup
   2234      1.1  christos bfd_sym_object_p (bfd *abfd)
   2235      1.1  christos {
   2236      1.1  christos   bfd_sym_version version = -1;
   2237      1.1  christos   bfd_sym_data_struct *mdata;
   2238      1.1  christos 
   2239      1.1  christos   bfd_seek (abfd, 0, SEEK_SET);
   2240      1.1  christos   if (bfd_sym_read_version (abfd, &version) != 0)
   2241      1.1  christos     goto wrong;
   2242      1.1  christos 
   2243      1.1  christos   mdata = (bfd_sym_data_struct *) bfd_alloc (abfd, sizeof (*mdata));
   2244      1.1  christos   if (mdata == NULL)
   2245      1.1  christos     goto fail;
   2246      1.1  christos 
   2247      1.1  christos   if (bfd_sym_scan (abfd, version, mdata) != 0)
   2248      1.1  christos     goto wrong;
   2249      1.1  christos 
   2250  1.1.1.6  christos   return _bfd_no_cleanup;
   2251      1.1  christos 
   2252      1.1  christos  wrong:
   2253      1.1  christos   bfd_set_error (bfd_error_wrong_format);
   2254      1.1  christos 
   2255      1.1  christos  fail:
   2256      1.1  christos   return NULL;
   2257      1.1  christos }
   2258      1.1  christos 
   2259      1.1  christos #define bfd_sym_make_empty_symbol _bfd_generic_make_empty_symbol
   2260      1.1  christos 
   2261      1.1  christos void
   2262      1.1  christos bfd_sym_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED, asymbol *symbol, symbol_info *ret)
   2263      1.1  christos {
   2264      1.1  christos   bfd_symbol_info (symbol, ret);
   2265      1.1  christos }
   2266      1.1  christos 
   2267      1.1  christos long
   2268      1.1  christos bfd_sym_get_symtab_upper_bound (bfd *abfd ATTRIBUTE_UNUSED)
   2269      1.1  christos {
   2270      1.1  christos   return 0;
   2271      1.1  christos }
   2272      1.1  christos 
   2273      1.1  christos long
   2274      1.1  christos bfd_sym_canonicalize_symtab (bfd *abfd ATTRIBUTE_UNUSED, asymbol **sym ATTRIBUTE_UNUSED)
   2275      1.1  christos {
   2276      1.1  christos   return 0;
   2277      1.1  christos }
   2278      1.1  christos 
   2279      1.1  christos int
   2280      1.1  christos bfd_sym_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
   2281      1.1  christos 			struct bfd_link_info *info ATTRIBUTE_UNUSED)
   2282      1.1  christos {
   2283      1.1  christos   return 0;
   2284      1.1  christos }
   2285      1.1  christos 
   2286      1.1  christos const bfd_target sym_vec =
   2287      1.1  christos {
   2288      1.1  christos   "sym",			/* Name.  */
   2289      1.1  christos   bfd_target_sym_flavour,	/* Flavour.  */
   2290      1.1  christos   BFD_ENDIAN_BIG,		/* Byteorder.  */
   2291      1.1  christos   BFD_ENDIAN_BIG,		/* Header byteorder.  */
   2292      1.1  christos   (HAS_RELOC | EXEC_P |		/* Object flags.  */
   2293      1.1  christos    HAS_LINENO | HAS_DEBUG |
   2294      1.1  christos    HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
   2295      1.1  christos   (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
   2296      1.1  christos    | SEC_ROM | SEC_HAS_CONTENTS), /* Section_flags.  */
   2297      1.1  christos   0,				/* Symbol_leading_char.  */
   2298      1.1  christos   ' ',				/* AR_pad_char.  */
   2299      1.1  christos   16,				/* AR_max_namelen.  */
   2300      1.1  christos   0,				/* match priority.  */
   2301      1.1  christos   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
   2302      1.1  christos   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   2303      1.1  christos   bfd_getb16, bfd_getb_signed_16, bfd_putb16,	/* Data.  */
   2304      1.1  christos   bfd_getb64, bfd_getb_signed_64, bfd_putb64,
   2305      1.1  christos   bfd_getb32, bfd_getb_signed_32, bfd_putb32,
   2306      1.1  christos   bfd_getb16, bfd_getb_signed_16, bfd_putb16,	/* Hdrs.  */
   2307      1.1  christos   {				/* bfd_check_format.  */
   2308      1.1  christos     _bfd_dummy_target,
   2309      1.1  christos     bfd_sym_object_p,		/* bfd_check_format.  */
   2310      1.1  christos     _bfd_dummy_target,
   2311      1.1  christos     _bfd_dummy_target,
   2312      1.1  christos   },
   2313      1.1  christos   {				/* bfd_set_format.  */
   2314  1.1.1.5  christos     _bfd_bool_bfd_false_error,
   2315      1.1  christos     bfd_sym_mkobject,
   2316  1.1.1.5  christos     _bfd_bool_bfd_false_error,
   2317  1.1.1.5  christos     _bfd_bool_bfd_false_error,
   2318      1.1  christos   },
   2319      1.1  christos   {				/* bfd_write_contents.  */
   2320  1.1.1.5  christos     _bfd_bool_bfd_false_error,
   2321  1.1.1.5  christos     _bfd_bool_bfd_true,
   2322  1.1.1.5  christos     _bfd_bool_bfd_false_error,
   2323  1.1.1.5  christos     _bfd_bool_bfd_false_error,
   2324      1.1  christos   },
   2325      1.1  christos 
   2326      1.1  christos   BFD_JUMP_TABLE_GENERIC (bfd_sym),
   2327      1.1  christos   BFD_JUMP_TABLE_COPY (_bfd_generic),
   2328      1.1  christos   BFD_JUMP_TABLE_CORE (_bfd_nocore),
   2329      1.1  christos   BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
   2330      1.1  christos   BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
   2331      1.1  christos   BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
   2332      1.1  christos   BFD_JUMP_TABLE_WRITE (bfd_sym),
   2333      1.1  christos   BFD_JUMP_TABLE_LINK (bfd_sym),
   2334      1.1  christos   BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
   2335      1.1  christos 
   2336      1.1  christos   NULL,
   2337      1.1  christos 
   2338      1.1  christos   NULL
   2339      1.1  christos };
   2340