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