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