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