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