[PATCH 46/57][Arm][OBJDUMP] Add support for MVE instructions: vmovl, vmull, vqdmull...
[binutils-gdb.git] / bfd / xsym.c
blob67d91cb077d572c195c34997bf7b6d9ed9d7910f
1 /* xSYM symbol-file support for BFD.
2 Copyright (C) 1999-2019 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
21 /* xSYM is the debugging format used by CodeWarrior on Mac OS classic. */
23 #include "sysdep.h"
24 #include "alloca-conf.h"
25 #include "xsym.h"
26 #include "bfd.h"
27 #include "libbfd.h"
29 #define bfd_sym_close_and_cleanup _bfd_generic_close_and_cleanup
30 #define bfd_sym_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
31 #define bfd_sym_new_section_hook _bfd_generic_new_section_hook
32 #define bfd_sym_bfd_is_local_label_name bfd_generic_is_local_label_name
33 #define bfd_sym_bfd_is_target_special_symbol _bfd_bool_bfd_asymbol_false
34 #define bfd_sym_get_lineno _bfd_nosymbols_get_lineno
35 #define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line
36 #define bfd_sym_find_line _bfd_nosymbols_find_line
37 #define bfd_sym_find_inliner_info _bfd_nosymbols_find_inliner_info
38 #define bfd_sym_get_symbol_version_string _bfd_nosymbols_get_symbol_version_string
39 #define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
40 #define bfd_sym_read_minisymbols _bfd_generic_read_minisymbols
41 #define bfd_sym_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
42 #define bfd_sym_set_arch_mach _bfd_generic_set_arch_mach
43 #define bfd_sym_get_section_contents _bfd_generic_get_section_contents
44 #define bfd_sym_set_section_contents _bfd_generic_set_section_contents
45 #define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
46 #define bfd_sym_bfd_relax_section bfd_generic_relax_section
47 #define bfd_sym_bfd_gc_sections bfd_generic_gc_sections
48 #define bfd_sym_bfd_lookup_section_flags bfd_generic_lookup_section_flags
49 #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections
50 #define bfd_sym_bfd_is_group_section bfd_generic_is_group_section
51 #define bfd_sym_bfd_discard_group bfd_generic_discard_group
52 #define bfd_sym_section_already_linked _bfd_generic_section_already_linked
53 #define bfd_sym_bfd_define_common_symbol bfd_generic_define_common_symbol
54 #define bfd_sym_bfd_link_hide_symbol _bfd_generic_link_hide_symbol
55 #define bfd_sym_bfd_define_start_stop bfd_generic_define_start_stop
56 #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
57 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
58 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
59 #define bfd_sym_bfd_copy_link_hash_symbol_type \
60 _bfd_generic_copy_link_hash_symbol_type
61 #define bfd_sym_bfd_final_link _bfd_generic_final_link
62 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
63 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
64 #define bfd_sym_bfd_link_check_relocs _bfd_generic_link_check_relocs
66 extern const bfd_target sym_vec;
68 static int
69 pstrcmp (const char *as, const char *bs)
71 const unsigned char *a = (const unsigned char *) as;
72 const unsigned char *b = (const unsigned char *) bs;
73 unsigned char clen;
74 int ret;
76 clen = (a[0] > b[0]) ? b[0] : a[0];
77 ret = memcmp (a + 1, b + 1, clen);
78 if (ret != 0)
79 return ret;
81 if (a[0] == b[0])
82 return 0;
83 else if (a[0] < b[0])
84 return -1;
85 else
86 return 1;
89 static unsigned long
90 compute_offset (unsigned long first_page,
91 unsigned long page_size,
92 unsigned long entry_size,
93 unsigned long sym_index)
95 unsigned long entries_per_page = page_size / entry_size;
96 unsigned long page_number = first_page + (sym_index / entries_per_page);
97 unsigned long page_offset = (sym_index % entries_per_page) * entry_size;
99 return (page_number * page_size) + page_offset;
102 bfd_boolean
103 bfd_sym_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
105 return 1;
108 void
109 bfd_sym_print_symbol (bfd *abfd ATTRIBUTE_UNUSED,
110 void * afile ATTRIBUTE_UNUSED,
111 asymbol *symbol ATTRIBUTE_UNUSED,
112 bfd_print_symbol_type how ATTRIBUTE_UNUSED)
114 return;
117 bfd_boolean
118 bfd_sym_valid (bfd *abfd)
120 if (abfd == NULL || abfd->xvec == NULL)
121 return 0;
123 return abfd->xvec == &sym_vec;
126 unsigned char *
127 bfd_sym_read_name_table (bfd *abfd, bfd_sym_header_block *dshb)
129 unsigned char *rstr;
130 long ret;
131 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
132 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
134 rstr = bfd_alloc (abfd, table_size);
135 if (rstr == NULL)
136 return rstr;
138 bfd_seek (abfd, table_offset, SEEK_SET);
139 ret = bfd_bread (rstr, table_size, abfd);
140 if (ret < 0 || (unsigned long) ret != table_size)
142 bfd_release (abfd, rstr);
143 return NULL;
146 return rstr;
149 void
150 bfd_sym_parse_file_reference_v32 (unsigned char *buf,
151 size_t len,
152 bfd_sym_file_reference *entry)
154 BFD_ASSERT (len == 6);
156 entry->fref_frte_index = bfd_getb16 (buf);
157 entry->fref_offset = bfd_getb32 (buf + 2);
160 void
161 bfd_sym_parse_disk_table_v32 (unsigned char *buf,
162 size_t len,
163 bfd_sym_table_info *table)
165 BFD_ASSERT (len == 8);
167 table->dti_first_page = bfd_getb16 (buf);
168 table->dti_page_count = bfd_getb16 (buf + 2);
169 table->dti_object_count = bfd_getb32 (buf + 4);
172 void
173 bfd_sym_parse_header_v32 (unsigned char *buf,
174 size_t len,
175 bfd_sym_header_block *header)
177 BFD_ASSERT (len == 154);
179 memcpy (header->dshb_id, buf, 32);
180 header->dshb_page_size = bfd_getb16 (buf + 32);
181 header->dshb_hash_page = bfd_getb16 (buf + 34);
182 header->dshb_root_mte = bfd_getb16 (buf + 36);
183 header->dshb_mod_date = bfd_getb32 (buf + 38);
185 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
186 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
187 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
188 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
189 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
190 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
191 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
192 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
193 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
194 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
195 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
196 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
197 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
199 memcpy (&header->dshb_file_creator, buf + 146, 4);
200 memcpy (&header->dshb_file_type, buf + 150, 4);
204 bfd_sym_read_header_v32 (bfd *abfd, bfd_sym_header_block *header)
206 unsigned char buf[154];
207 long ret;
209 ret = bfd_bread (buf, 154, abfd);
210 if (ret != 154)
211 return -1;
213 bfd_sym_parse_header_v32 (buf, 154, header);
215 return 0;
219 bfd_sym_read_header_v34 (bfd *abfd ATTRIBUTE_UNUSED,
220 bfd_sym_header_block *header ATTRIBUTE_UNUSED)
222 abort ();
226 bfd_sym_read_header (bfd *abfd,
227 bfd_sym_header_block *header,
228 bfd_sym_version version)
230 switch (version)
232 case BFD_SYM_VERSION_3_5:
233 case BFD_SYM_VERSION_3_4:
234 return bfd_sym_read_header_v34 (abfd, header);
235 case BFD_SYM_VERSION_3_3:
236 case BFD_SYM_VERSION_3_2:
237 return bfd_sym_read_header_v32 (abfd, header);
238 case BFD_SYM_VERSION_3_1:
239 default:
240 return 0;
245 bfd_sym_read_version (bfd *abfd, bfd_sym_version *version)
247 char version_string[32];
248 long ret;
250 ret = bfd_bread (version_string, sizeof (version_string), abfd);
251 if (ret != sizeof (version_string))
252 return -1;
254 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
255 *version = BFD_SYM_VERSION_3_1;
256 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
257 *version = BFD_SYM_VERSION_3_2;
258 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
259 *version = BFD_SYM_VERSION_3_3;
260 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
261 *version = BFD_SYM_VERSION_3_4;
262 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
263 *version = BFD_SYM_VERSION_3_5;
264 else
265 return -1;
267 return 0;
270 void
271 bfd_sym_display_table_summary (FILE *f,
272 bfd_sym_table_info *dti,
273 const char *name)
275 fprintf (f, "%-6s %13ld %13ld %13ld\n",
276 name,
277 dti->dti_first_page,
278 dti->dti_page_count,
279 dti->dti_object_count);
282 void
283 bfd_sym_display_header (FILE *f, bfd_sym_header_block *dshb)
285 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
286 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
287 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
288 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
289 fprintf (f, " Modification Date: ");
290 fprintf (f, "[unimplemented]");
291 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
293 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
294 dshb->dshb_file_creator, dshb->dshb_file_type);
296 fprintf (f, "Table Name First Page Page Count Object Count\n");
297 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
299 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
300 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
301 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
302 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
303 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
304 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
305 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
306 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
307 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
308 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
309 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
310 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
311 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
313 fprintf (f, "\n");
316 void
317 bfd_sym_parse_resources_table_entry_v32 (unsigned char *buf,
318 size_t len,
319 bfd_sym_resources_table_entry *entry)
321 BFD_ASSERT (len == 18);
323 memcpy (&entry->rte_res_type, buf, 4);
324 entry->rte_res_number = bfd_getb16 (buf + 4);
325 entry->rte_nte_index = bfd_getb32 (buf + 6);
326 entry->rte_mte_first = bfd_getb16 (buf + 10);
327 entry->rte_mte_last = bfd_getb16 (buf + 12);
328 entry->rte_res_size = bfd_getb32 (buf + 14);
331 void
332 bfd_sym_parse_modules_table_entry_v33 (unsigned char *buf,
333 size_t len,
334 bfd_sym_modules_table_entry *entry)
336 BFD_ASSERT (len == 46);
338 entry->mte_rte_index = bfd_getb16 (buf);
339 entry->mte_res_offset = bfd_getb32 (buf + 2);
340 entry->mte_size = bfd_getb32 (buf + 6);
341 entry->mte_kind = buf[10];
342 entry->mte_scope = buf[11];
343 entry->mte_parent = bfd_getb16 (buf + 12);
344 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
345 entry->mte_imp_end = bfd_getb32 (buf + 20);
346 entry->mte_nte_index = bfd_getb32 (buf + 24);
347 entry->mte_cmte_index = bfd_getb16 (buf + 28);
348 entry->mte_cvte_index = bfd_getb32 (buf + 30);
349 entry->mte_clte_index = bfd_getb16 (buf + 34);
350 entry->mte_ctte_index = bfd_getb16 (buf + 36);
351 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
352 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
355 void
356 bfd_sym_parse_file_references_table_entry_v32 (unsigned char *buf,
357 size_t len,
358 bfd_sym_file_references_table_entry *entry)
360 unsigned int type;
362 BFD_ASSERT (len == 10);
364 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
365 type = bfd_getb16 (buf);
367 switch (type)
369 case BFD_SYM_END_OF_LIST_3_2:
370 entry->generic.type = BFD_SYM_END_OF_LIST;
371 break;
373 case BFD_SYM_FILE_NAME_INDEX_3_2:
374 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
375 entry->filename.nte_index = bfd_getb32 (buf + 2);
376 entry->filename.mod_date = bfd_getb32 (buf + 6);
377 break;
379 default:
380 entry->entry.mte_index = type;
381 entry->entry.file_offset = bfd_getb32 (buf + 2);
385 void
386 bfd_sym_parse_contained_modules_table_entry_v32 (unsigned char *buf,
387 size_t len,
388 bfd_sym_contained_modules_table_entry *entry)
390 unsigned int type;
392 BFD_ASSERT (len == 6);
394 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
395 type = bfd_getb16 (buf);
397 switch (type)
399 case BFD_SYM_END_OF_LIST_3_2:
400 entry->generic.type = BFD_SYM_END_OF_LIST;
401 break;
403 default:
404 entry->entry.mte_index = type;
405 entry->entry.nte_index = bfd_getb32 (buf + 2);
406 break;
410 void
411 bfd_sym_parse_contained_variables_table_entry_v32 (unsigned char *buf,
412 size_t len,
413 bfd_sym_contained_variables_table_entry *entry)
415 unsigned int type;
417 BFD_ASSERT (len == 26);
419 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
420 type = bfd_getb16 (buf);
422 switch (type)
424 case BFD_SYM_END_OF_LIST_3_2:
425 entry->generic.type = BFD_SYM_END_OF_LIST;
426 break;
428 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
429 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
430 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
431 break;
433 default:
434 entry->entry.tte_index = type;
435 entry->entry.nte_index = bfd_getb32 (buf + 2);
436 entry->entry.file_delta = bfd_getb16 (buf + 6);
437 entry->entry.scope = buf[8];
438 entry->entry.la_size = buf[9];
440 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
442 entry->entry.address.scstruct.sca_kind = buf[10];
443 entry->entry.address.scstruct.sca_class = buf[11];
444 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
446 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
448 #if BFD_SYM_CVTE_SCA > 0
449 memcpy (&entry->entry.address.lastruct.la, buf + 10,
450 BFD_SYM_CVTE_SCA);
451 #endif
452 entry->entry.address.lastruct.la_kind = buf[23];
454 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
456 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
457 entry->entry.address.biglastruct.big_la_kind = buf[12];
462 void
463 bfd_sym_parse_contained_statements_table_entry_v32 (unsigned char *buf,
464 size_t len,
465 bfd_sym_contained_statements_table_entry *entry)
467 unsigned int type;
469 BFD_ASSERT (len == 8);
471 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
472 type = bfd_getb16 (buf);
474 switch (type)
476 case BFD_SYM_END_OF_LIST_3_2:
477 entry->generic.type = BFD_SYM_END_OF_LIST;
478 break;
480 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
481 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
482 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
483 break;
485 default:
486 entry->entry.mte_index = type;
487 entry->entry.mte_offset = bfd_getb16 (buf + 2);
488 entry->entry.file_delta = bfd_getb32 (buf + 4);
489 break;
493 void
494 bfd_sym_parse_contained_labels_table_entry_v32 (unsigned char *buf,
495 size_t len,
496 bfd_sym_contained_labels_table_entry *entry)
498 unsigned int type;
500 BFD_ASSERT (len == 12);
502 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
503 type = bfd_getb16 (buf);
505 switch (type)
507 case BFD_SYM_END_OF_LIST_3_2:
508 entry->generic.type = BFD_SYM_END_OF_LIST;
509 break;
511 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
512 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
513 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
514 break;
516 default:
517 entry->entry.mte_index = type;
518 entry->entry.mte_offset = bfd_getb16 (buf + 2);
519 entry->entry.nte_index = bfd_getb32 (buf + 4);
520 entry->entry.file_delta = bfd_getb16 (buf + 8);
521 entry->entry.scope = bfd_getb16 (buf + 10);
522 break;
526 void
527 bfd_sym_parse_type_table_entry_v32 (unsigned char *buf,
528 size_t len,
529 bfd_sym_type_table_entry *entry)
531 BFD_ASSERT (len == 4);
533 *entry = bfd_getb32 (buf);
537 bfd_sym_fetch_resources_table_entry (bfd *abfd,
538 bfd_sym_resources_table_entry *entry,
539 unsigned long sym_index)
541 void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *);
542 unsigned long offset;
543 unsigned long entry_size;
544 unsigned char buf[18];
545 bfd_sym_data_struct *sdata = NULL;
547 parser = NULL;
548 BFD_ASSERT (bfd_sym_valid (abfd));
549 sdata = abfd->tdata.sym_data;
551 if (sym_index == 0)
552 return -1;
554 switch (sdata->version)
556 case BFD_SYM_VERSION_3_5:
557 case BFD_SYM_VERSION_3_4:
558 return -1;
560 case BFD_SYM_VERSION_3_3:
561 case BFD_SYM_VERSION_3_2:
562 entry_size = 18;
563 parser = bfd_sym_parse_resources_table_entry_v32;
564 break;
566 case BFD_SYM_VERSION_3_1:
567 default:
568 return -1;
570 if (parser == NULL)
571 return -1;
573 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
574 sdata->header.dshb_page_size,
575 entry_size, sym_index);
577 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
578 return -1;
579 if (bfd_bread (buf, entry_size, abfd) != entry_size)
580 return -1;
582 (*parser) (buf, entry_size, entry);
584 return 0;
588 bfd_sym_fetch_modules_table_entry (bfd *abfd,
589 bfd_sym_modules_table_entry *entry,
590 unsigned long sym_index)
592 void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *);
593 unsigned long offset;
594 unsigned long entry_size;
595 unsigned char buf[46];
596 bfd_sym_data_struct *sdata = NULL;
598 parser = NULL;
599 BFD_ASSERT (bfd_sym_valid (abfd));
600 sdata = abfd->tdata.sym_data;
602 if (sym_index == 0)
603 return -1;
605 switch (sdata->version)
607 case BFD_SYM_VERSION_3_5:
608 case BFD_SYM_VERSION_3_4:
609 return -1;
611 case BFD_SYM_VERSION_3_3:
612 entry_size = 46;
613 parser = bfd_sym_parse_modules_table_entry_v33;
614 break;
616 case BFD_SYM_VERSION_3_2:
617 case BFD_SYM_VERSION_3_1:
618 default:
619 return -1;
621 if (parser == NULL)
622 return -1;
624 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
625 sdata->header.dshb_page_size,
626 entry_size, sym_index);
628 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
629 return -1;
630 if (bfd_bread (buf, entry_size, abfd) != entry_size)
631 return -1;
633 (*parser) (buf, entry_size, entry);
635 return 0;
639 bfd_sym_fetch_file_references_table_entry (bfd *abfd,
640 bfd_sym_file_references_table_entry *entry,
641 unsigned long sym_index)
643 void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *);
644 unsigned long offset;
645 unsigned long entry_size = 0;
646 unsigned char buf[8];
647 bfd_sym_data_struct *sdata = NULL;
649 parser = NULL;
650 BFD_ASSERT (bfd_sym_valid (abfd));
651 sdata = abfd->tdata.sym_data;
653 if (sym_index == 0)
654 return -1;
656 switch (sdata->version)
658 case BFD_SYM_VERSION_3_3:
659 case BFD_SYM_VERSION_3_2:
660 entry_size = 10;
661 parser = bfd_sym_parse_file_references_table_entry_v32;
662 break;
664 case BFD_SYM_VERSION_3_5:
665 case BFD_SYM_VERSION_3_4:
666 case BFD_SYM_VERSION_3_1:
667 default:
668 break;
671 if (parser == NULL)
672 return -1;
674 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
675 sdata->header.dshb_page_size,
676 entry_size, sym_index);
678 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
679 return -1;
680 if (bfd_bread (buf, entry_size, abfd) != entry_size)
681 return -1;
683 (*parser) (buf, entry_size, entry);
685 return 0;
689 bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
690 bfd_sym_contained_modules_table_entry *entry,
691 unsigned long sym_index)
693 void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *);
694 unsigned long offset;
695 unsigned long entry_size = 0;
696 unsigned char buf[6];
697 bfd_sym_data_struct *sdata = NULL;
699 parser = NULL;
700 BFD_ASSERT (bfd_sym_valid (abfd));
701 sdata = abfd->tdata.sym_data;
703 if (sym_index == 0)
704 return -1;
706 switch (sdata->version)
708 case BFD_SYM_VERSION_3_3:
709 case BFD_SYM_VERSION_3_2:
710 entry_size = 6;
711 parser = bfd_sym_parse_contained_modules_table_entry_v32;
712 break;
714 case BFD_SYM_VERSION_3_5:
715 case BFD_SYM_VERSION_3_4:
716 case BFD_SYM_VERSION_3_1:
717 default:
718 break;
721 if (parser == NULL)
722 return -1;
724 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
725 sdata->header.dshb_page_size,
726 entry_size, sym_index);
728 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
729 return -1;
730 if (bfd_bread (buf, entry_size, abfd) != entry_size)
731 return -1;
733 (*parser) (buf, entry_size, entry);
735 return 0;
739 bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
740 bfd_sym_contained_variables_table_entry *entry,
741 unsigned long sym_index)
743 void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *);
744 unsigned long offset;
745 unsigned long entry_size = 0;
746 unsigned char buf[26];
747 bfd_sym_data_struct *sdata = NULL;
749 parser = NULL;
750 BFD_ASSERT (bfd_sym_valid (abfd));
751 sdata = abfd->tdata.sym_data;
753 if (sym_index == 0)
754 return -1;
756 switch (sdata->version)
758 case BFD_SYM_VERSION_3_3:
759 case BFD_SYM_VERSION_3_2:
760 entry_size = 26;
761 parser = bfd_sym_parse_contained_variables_table_entry_v32;
762 break;
764 case BFD_SYM_VERSION_3_5:
765 case BFD_SYM_VERSION_3_4:
766 case BFD_SYM_VERSION_3_1:
767 default:
768 break;
771 if (parser == NULL)
772 return -1;
774 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
775 sdata->header.dshb_page_size,
776 entry_size, sym_index);
778 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
779 return -1;
780 if (bfd_bread (buf, entry_size, abfd) != entry_size)
781 return -1;
783 (*parser) (buf, entry_size, entry);
785 return 0;
789 bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
790 bfd_sym_contained_statements_table_entry *entry,
791 unsigned long sym_index)
793 void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *);
794 unsigned long offset;
795 unsigned long entry_size = 0;
796 unsigned char buf[8];
797 bfd_sym_data_struct *sdata = NULL;
799 parser = NULL;
800 BFD_ASSERT (bfd_sym_valid (abfd));
801 sdata = abfd->tdata.sym_data;
803 if (sym_index == 0)
804 return -1;
806 switch (sdata->version)
808 case BFD_SYM_VERSION_3_3:
809 case BFD_SYM_VERSION_3_2:
810 entry_size = 8;
811 parser = bfd_sym_parse_contained_statements_table_entry_v32;
812 break;
814 case BFD_SYM_VERSION_3_5:
815 case BFD_SYM_VERSION_3_4:
816 case BFD_SYM_VERSION_3_1:
817 default:
818 break;
821 if (parser == NULL)
822 return -1;
824 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
825 sdata->header.dshb_page_size,
826 entry_size, sym_index);
828 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
829 return -1;
830 if (bfd_bread (buf, entry_size, abfd) != entry_size)
831 return -1;
833 (*parser) (buf, entry_size, entry);
835 return 0;
839 bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
840 bfd_sym_contained_labels_table_entry *entry,
841 unsigned long sym_index)
843 void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *);
844 unsigned long offset;
845 unsigned long entry_size = 0;
846 unsigned char buf[12];
847 bfd_sym_data_struct *sdata = NULL;
849 parser = NULL;
850 BFD_ASSERT (bfd_sym_valid (abfd));
851 sdata = abfd->tdata.sym_data;
853 if (sym_index == 0)
854 return -1;
856 switch (sdata->version)
858 case BFD_SYM_VERSION_3_3:
859 case BFD_SYM_VERSION_3_2:
860 entry_size = 12;
861 parser = bfd_sym_parse_contained_labels_table_entry_v32;
862 break;
864 case BFD_SYM_VERSION_3_5:
865 case BFD_SYM_VERSION_3_4:
866 case BFD_SYM_VERSION_3_1:
867 default:
868 break;
871 if (parser == NULL)
872 return -1;
874 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
875 sdata->header.dshb_page_size,
876 entry_size, sym_index);
878 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
879 return -1;
880 if (bfd_bread (buf, entry_size, abfd) != entry_size)
881 return -1;
883 (*parser) (buf, entry_size, entry);
885 return 0;
889 bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
890 bfd_sym_contained_types_table_entry *entry,
891 unsigned long sym_index)
893 void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *);
894 unsigned long offset;
895 unsigned long entry_size = 0;
896 unsigned char buf[0];
897 bfd_sym_data_struct *sdata = NULL;
899 parser = NULL;
900 BFD_ASSERT (bfd_sym_valid (abfd));
901 sdata = abfd->tdata.sym_data;
903 if (sym_index == 0)
904 return -1;
906 switch (sdata->version)
908 case BFD_SYM_VERSION_3_3:
909 case BFD_SYM_VERSION_3_2:
910 entry_size = 0;
911 parser = NULL;
912 break;
914 case BFD_SYM_VERSION_3_5:
915 case BFD_SYM_VERSION_3_4:
916 case BFD_SYM_VERSION_3_1:
917 default:
918 break;
921 if (parser == NULL)
922 return -1;
924 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
925 sdata->header.dshb_page_size,
926 entry_size, sym_index);
928 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
929 return -1;
930 if (bfd_bread (buf, entry_size, abfd) != entry_size)
931 return -1;
933 (*parser) (buf, entry_size, entry);
935 return 0;
939 bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
940 bfd_sym_file_references_index_table_entry *entry,
941 unsigned long sym_index)
943 void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *);
944 unsigned long offset;
945 unsigned long entry_size = 0;
946 unsigned char buf[0];
947 bfd_sym_data_struct *sdata = NULL;
949 parser = NULL;
950 BFD_ASSERT (bfd_sym_valid (abfd));
951 sdata = abfd->tdata.sym_data;
953 if (sym_index == 0)
954 return -1;
956 switch (sdata->version)
958 case BFD_SYM_VERSION_3_3:
959 case BFD_SYM_VERSION_3_2:
960 entry_size = 0;
961 parser = NULL;
962 break;
964 case BFD_SYM_VERSION_3_5:
965 case BFD_SYM_VERSION_3_4:
966 case BFD_SYM_VERSION_3_1:
967 default:
968 break;
971 if (parser == NULL)
972 return -1;
974 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
975 sdata->header.dshb_page_size,
976 entry_size, sym_index);
978 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
979 return -1;
980 if (bfd_bread (buf, entry_size, abfd) != entry_size)
981 return -1;
983 (*parser) (buf, entry_size, entry);
985 return 0;
989 bfd_sym_fetch_constant_pool_entry (bfd *abfd,
990 bfd_sym_constant_pool_entry *entry,
991 unsigned long sym_index)
993 void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *);
994 unsigned long offset;
995 unsigned long entry_size = 0;
996 unsigned char buf[0];
997 bfd_sym_data_struct *sdata = NULL;
999 parser = NULL;
1000 BFD_ASSERT (bfd_sym_valid (abfd));
1001 sdata = abfd->tdata.sym_data;
1003 if (sym_index == 0)
1004 return -1;
1006 switch (sdata->version)
1008 case BFD_SYM_VERSION_3_3:
1009 case BFD_SYM_VERSION_3_2:
1010 entry_size = 0;
1011 parser = NULL;
1012 break;
1014 case BFD_SYM_VERSION_3_5:
1015 case BFD_SYM_VERSION_3_4:
1016 case BFD_SYM_VERSION_3_1:
1017 default:
1018 break;
1021 if (parser == NULL)
1022 return -1;
1024 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1025 sdata->header.dshb_page_size,
1026 entry_size, sym_index);
1028 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1029 return -1;
1030 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1031 return -1;
1033 (*parser) (buf, entry_size, entry);
1035 return 0;
1039 bfd_sym_fetch_type_table_entry (bfd *abfd,
1040 bfd_sym_type_table_entry *entry,
1041 unsigned long sym_index)
1043 void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *);
1044 unsigned long offset;
1045 unsigned long entry_size = 0;
1046 unsigned char buf[4];
1047 bfd_sym_data_struct *sdata = NULL;
1049 parser = NULL;
1050 BFD_ASSERT (bfd_sym_valid (abfd));
1051 sdata = abfd->tdata.sym_data;
1053 switch (sdata->version)
1055 case BFD_SYM_VERSION_3_3:
1056 case BFD_SYM_VERSION_3_2:
1057 entry_size = 4;
1058 parser = bfd_sym_parse_type_table_entry_v32;
1059 break;
1061 case BFD_SYM_VERSION_3_5:
1062 case BFD_SYM_VERSION_3_4:
1063 case BFD_SYM_VERSION_3_1:
1064 default:
1065 break;
1068 if (parser == NULL)
1069 return -1;
1071 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1072 sdata->header.dshb_page_size,
1073 entry_size, sym_index);
1075 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1076 return -1;
1077 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1078 return -1;
1080 (*parser) (buf, entry_size, entry);
1082 return 0;
1086 bfd_sym_fetch_type_information_table_entry (bfd *abfd,
1087 bfd_sym_type_information_table_entry *entry,
1088 unsigned long offset)
1090 unsigned char buf[4];
1092 BFD_ASSERT (bfd_sym_valid (abfd));
1094 if (offset == 0)
1095 return -1;
1097 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1098 return -1;
1100 if (bfd_bread (buf, 4, abfd) != 4)
1101 return -1;
1102 entry->nte_index = bfd_getb32 (buf);
1104 if (bfd_bread (buf, 2, abfd) != 2)
1105 return -1;
1106 entry->physical_size = bfd_getb16 (buf);
1108 if (entry->physical_size & 0x8000)
1110 if (bfd_bread (buf, 4, abfd) != 4)
1111 return -1;
1112 entry->physical_size &= 0x7fff;
1113 entry->logical_size = bfd_getb32 (buf);
1114 entry->offset = offset + 10;
1116 else
1118 if (bfd_bread (buf, 2, abfd) != 2)
1119 return -1;
1120 entry->physical_size &= 0x7fff;
1121 entry->logical_size = bfd_getb16 (buf);
1122 entry->offset = offset + 8;
1125 return 0;
1129 bfd_sym_fetch_type_table_information (bfd *abfd,
1130 bfd_sym_type_information_table_entry *entry,
1131 unsigned long sym_index)
1133 bfd_sym_type_table_entry tindex;
1134 bfd_sym_data_struct *sdata = NULL;
1136 BFD_ASSERT (bfd_sym_valid (abfd));
1137 sdata = abfd->tdata.sym_data;
1139 if (sdata->header.dshb_tte.dti_object_count <= 99)
1140 return -1;
1141 if (sym_index < 100)
1142 return -1;
1144 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, sym_index - 100) < 0)
1145 return -1;
1146 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1147 return -1;
1149 return 0;
1152 const unsigned char *
1153 bfd_sym_symbol_name (bfd *abfd, unsigned long sym_index)
1155 bfd_sym_data_struct *sdata = NULL;
1157 BFD_ASSERT (bfd_sym_valid (abfd));
1158 sdata = abfd->tdata.sym_data;
1160 if (sym_index == 0)
1161 return (const unsigned char *) "";
1163 sym_index *= 2;
1164 if ((sym_index / sdata->header.dshb_page_size)
1165 > sdata->header.dshb_nte.dti_page_count)
1166 return (const unsigned char *) "\09[INVALID]";
1168 return (const unsigned char *) sdata->name_table + sym_index;
1171 const unsigned char *
1172 bfd_sym_module_name (bfd *abfd, unsigned long sym_index)
1174 bfd_sym_modules_table_entry entry;
1176 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, sym_index) < 0)
1177 return (const unsigned char *) "\09[INVALID]";
1179 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1182 const char *
1183 bfd_sym_unparse_storage_kind (enum bfd_sym_storage_kind kind)
1185 switch (kind)
1187 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1188 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1189 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1190 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1191 default: return "[UNKNOWN]";
1195 const char *
1196 bfd_sym_unparse_storage_class (enum bfd_sym_storage_class kind)
1198 switch (kind)
1200 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1201 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1202 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1203 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1204 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1205 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1206 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1207 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1208 default: return "[UNKNOWN]";
1212 const char *
1213 bfd_sym_unparse_module_kind (enum bfd_sym_module_kind kind)
1215 switch (kind)
1217 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1218 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1219 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1220 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1221 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1222 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1223 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1224 default: return "[UNKNOWN]";
1228 const char *
1229 bfd_sym_unparse_symbol_scope (enum bfd_sym_symbol_scope scope)
1231 switch (scope)
1233 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1234 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1235 default:
1236 return "[UNKNOWN]";
1240 void
1241 bfd_sym_print_file_reference (bfd *abfd,
1242 FILE *f,
1243 bfd_sym_file_reference *entry)
1245 bfd_sym_file_references_table_entry frtentry;
1246 int ret;
1248 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1249 entry->fref_frte_index);
1250 fprintf (f, "FILE ");
1252 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1253 fprintf (f, "[INVALID]");
1254 else
1255 fprintf (f, "\"%.*s\"",
1256 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1257 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1259 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1262 void
1263 bfd_sym_print_resources_table_entry (bfd *abfd,
1264 FILE *f,
1265 bfd_sym_resources_table_entry *entry)
1267 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1268 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1269 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1270 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1271 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1274 void
1275 bfd_sym_print_modules_table_entry (bfd *abfd,
1276 FILE *f,
1277 bfd_sym_modules_table_entry *entry)
1279 fprintf (f, "\"%.*s\" (NTE %lu)",
1280 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1281 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1282 entry->mte_nte_index);
1284 fprintf (f, "\n ");
1286 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1287 fprintf (f, " range %lu -- %lu",
1288 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1290 fprintf (f, "\n ");
1292 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1293 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1295 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1296 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1298 fprintf (f, "\n ");
1300 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1301 entry->mte_cmte_index, entry->mte_cvte_index,
1302 entry->mte_clte_index, entry->mte_ctte_index,
1303 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1305 if (entry->mte_parent != 0)
1306 fprintf (f, ", parent %lu", entry->mte_parent);
1307 else
1308 fprintf (f, ", no parent");
1310 if (entry->mte_cmte_index != 0)
1311 fprintf (f, ", child %lu", entry->mte_cmte_index);
1312 else
1313 fprintf (f, ", no child");
1316 void
1317 bfd_sym_print_file_references_table_entry (bfd *abfd,
1318 FILE *f,
1319 bfd_sym_file_references_table_entry *entry)
1321 switch (entry->generic.type)
1323 case BFD_SYM_FILE_NAME_INDEX:
1324 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1325 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1326 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1327 entry->filename.nte_index);
1329 fprintf (f, "[UNIMPLEMENTED]");
1330 /* printModDate (entry->filename.mod_date); */
1331 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1332 break;
1334 case BFD_SYM_END_OF_LIST:
1335 fprintf (f, "END");
1336 break;
1338 default:
1339 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1340 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1341 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1342 entry->entry.mte_index,
1343 entry->entry.file_offset);
1344 break;
1348 void
1349 bfd_sym_print_contained_modules_table_entry (bfd *abfd,
1350 FILE *f,
1351 bfd_sym_contained_modules_table_entry *entry)
1353 switch (entry->generic.type)
1355 case BFD_SYM_END_OF_LIST:
1356 fprintf (f, "END");
1357 break;
1359 default:
1360 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
1361 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1362 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1363 entry->entry.mte_index,
1364 entry->entry.nte_index);
1365 break;
1369 void
1370 bfd_sym_print_contained_variables_table_entry (bfd *abfd,
1371 FILE *f,
1372 bfd_sym_contained_variables_table_entry *entry)
1374 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1376 fprintf (f, "END");
1377 return;
1380 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1382 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1383 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1384 return;
1387 fprintf (f, "\"%.*s\" (NTE %lu)",
1388 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1389 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1390 entry->entry.nte_index);
1392 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1393 fprintf (f, ", offset %lu", entry->entry.file_delta);
1394 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1396 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1397 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1398 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1399 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1400 entry->entry.address.scstruct.sca_offset);
1401 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1403 unsigned long i;
1405 fprintf (f, ", la [");
1406 for (i = 0; i < entry->entry.la_size; i++)
1407 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1408 fprintf (f, "]");
1410 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1411 fprintf (f, ", bigla %lu, biglakind %u",
1412 entry->entry.address.biglastruct.big_la,
1413 entry->entry.address.biglastruct.big_la_kind);
1415 else
1416 fprintf (f, ", la [INVALID]");
1419 void
1420 bfd_sym_print_contained_statements_table_entry (bfd *abfd,
1421 FILE *f,
1422 bfd_sym_contained_statements_table_entry *entry)
1424 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1426 fprintf (f, "END");
1427 return;
1430 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1432 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1433 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1434 return;
1437 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1438 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1439 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1440 entry->entry.mte_index,
1441 entry->entry.mte_offset,
1442 entry->entry.file_delta);
1445 void
1446 bfd_sym_print_contained_labels_table_entry (bfd *abfd,
1447 FILE *f,
1448 bfd_sym_contained_labels_table_entry *entry)
1450 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1452 fprintf (f, "END");
1453 return;
1456 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1458 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1459 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1460 return;
1463 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1464 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1465 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1466 entry->entry.mte_index,
1467 entry->entry.mte_offset,
1468 entry->entry.file_delta,
1469 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1472 void
1473 bfd_sym_print_contained_types_table_entry (bfd *abfd ATTRIBUTE_UNUSED,
1474 FILE *f,
1475 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED)
1477 fprintf (f, "[UNIMPLEMENTED]");
1480 const char *
1481 bfd_sym_type_operator_name (unsigned char num)
1483 switch (num)
1485 case 1: return "TTE";
1486 case 2: return "PointerTo";
1487 case 3: return "ScalarOf";
1488 case 4: return "ConstantOf";
1489 case 5: return "EnumerationOf";
1490 case 6: return "VectorOf";
1491 case 7: return "RecordOf";
1492 case 8: return "UnionOf";
1493 case 9: return "SubRangeOf";
1494 case 10: return "SetOf";
1495 case 11: return "NamedTypeOf";
1496 case 12: return "ProcOf";
1497 case 13: return "ValueOf";
1498 case 14: return "ArrayOf";
1499 default: return "[UNKNOWN OPERATOR]";
1503 const char *
1504 bfd_sym_type_basic_name (unsigned char num)
1506 switch (num)
1508 case 0: return "void";
1509 case 1: return "pascal string";
1510 case 2: return "unsigned long";
1511 case 3: return "signed long";
1512 case 4: return "extended (10 bytes)";
1513 case 5: return "pascal boolean (1 byte)";
1514 case 6: return "unsigned byte";
1515 case 7: return "signed byte";
1516 case 8: return "character (1 byte)";
1517 case 9: return "wide character (2 bytes)";
1518 case 10: return "unsigned short";
1519 case 11: return "signed short";
1520 case 12: return "singled";
1521 case 13: return "double";
1522 case 14: return "extended (12 bytes)";
1523 case 15: return "computational (8 bytes)";
1524 case 16: return "c string";
1525 case 17: return "as-is string";
1526 default: return "[UNKNOWN BASIC TYPE]";
1531 bfd_sym_fetch_long (unsigned char *buf,
1532 unsigned long len,
1533 unsigned long offset,
1534 unsigned long *offsetptr,
1535 long *value)
1537 int ret;
1539 if (offset >= len)
1541 *value = 0;
1542 offset += 0;
1543 ret = -1;
1545 else if (! (buf[offset] & 0x80))
1547 *value = buf[offset];
1548 offset += 1;
1549 ret = 0;
1551 else if (buf[offset] == 0xc0)
1553 if ((offset + 5) > len)
1555 *value = 0;
1556 offset = len;
1557 ret = -1;
1559 else
1561 *value = bfd_getb32 (buf + offset + 1);
1562 offset += 5;
1563 ret = 0;
1566 else if ((buf[offset] & 0xc0) == 0xc0)
1568 *value = -(buf[offset] & 0x3f);
1569 offset += 1;
1570 ret = 0;
1572 else if ((buf[offset] & 0xc0) == 0x80)
1574 if ((offset + 2) > len)
1576 *value = 0;
1577 offset = len;
1578 ret = -1;
1580 else
1582 *value = bfd_getb16 (buf + offset) & 0x3fff;
1583 offset += 2;
1584 ret = 0;
1587 else
1588 abort ();
1590 if (offsetptr != NULL)
1591 *offsetptr = offset;
1593 return ret;
1596 void
1597 bfd_sym_print_type_information (bfd *abfd,
1598 FILE *f,
1599 unsigned char *buf,
1600 unsigned long len,
1601 unsigned long offset,
1602 unsigned long *offsetptr)
1604 unsigned int type;
1606 if (offset >= len)
1608 fprintf (f, "[NULL]");
1610 if (offsetptr != NULL)
1611 *offsetptr = offset;
1612 return;
1615 type = buf[offset];
1616 offset++;
1618 if (! (type & 0x80))
1620 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1622 if (offsetptr != NULL)
1623 *offsetptr = offset;
1624 return;
1627 if (type & 0x40)
1628 fprintf (f, "[packed ");
1629 else
1630 fprintf (f, "[");
1632 switch (type & 0x3f)
1634 case 1:
1636 long value;
1637 bfd_sym_type_information_table_entry tinfo;
1639 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1640 if (value <= 0)
1641 fprintf (f, "[INVALID]");
1642 else
1644 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1645 fprintf (f, "[INVALID]");
1646 else
1647 fprintf (f, "\"%.*s\"",
1648 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1649 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1651 fprintf (f, " (TTE %lu)", (unsigned long) value);
1652 break;
1655 case 2:
1656 fprintf (f, "pointer (0x%x) to ", type);
1657 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1658 break;
1660 case 3:
1662 long value;
1664 fprintf (f, "scalar (0x%x) of ", type);
1665 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1666 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1667 fprintf (f, " (%lu)", (unsigned long) value);
1668 break;
1671 case 5:
1673 long lower, upper, nelem;
1674 int i;
1676 fprintf (f, "enumeration (0x%x) of ", type);
1677 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1678 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1679 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1680 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1681 fprintf (f, " from %lu to %lu with %lu elements: ",
1682 (unsigned long) lower, (unsigned long) upper,
1683 (unsigned long) nelem);
1685 for (i = 0; i < nelem; i++)
1687 fprintf (f, "\n ");
1688 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1690 break;
1693 case 6:
1694 fprintf (f, "vector (0x%x)", type);
1695 fprintf (f, "\n index ");
1696 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1697 fprintf (f, "\n target ");
1698 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1699 break;
1701 case 7:
1702 case 8:
1704 long nrec, eloff, i;
1706 if ((type & 0x3f) == 7)
1707 fprintf (f, "record (0x%x) of ", type);
1708 else
1709 fprintf (f, "union (0x%x) of ", type);
1711 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1712 fprintf (f, "%lu elements: ", (unsigned long) nrec);
1714 for (i = 0; i < nrec; i++)
1716 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1717 fprintf (f, "\n ");
1718 fprintf (f, "offset %lu: ", (unsigned long) eloff);
1719 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1721 break;
1724 case 9:
1725 fprintf (f, "subrange (0x%x) of ", type);
1726 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1727 fprintf (f, " lower ");
1728 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1729 fprintf (f, " upper ");
1730 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1731 break;
1733 case 11:
1735 long value;
1737 fprintf (f, "named type (0x%x) ", type);
1738 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1739 if (value <= 0)
1740 fprintf (f, "[INVALID]");
1741 else
1742 fprintf (f, "\"%.*s\"",
1743 bfd_sym_symbol_name (abfd, value)[0],
1744 &bfd_sym_symbol_name (abfd, value)[1]);
1746 fprintf (f, " (NTE %lu) with type ", (unsigned long) value);
1747 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1748 break;
1751 default:
1752 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1753 break;
1756 if (type == (0x40 | 0x6))
1758 /* Vector. */
1759 long n, width, m;
1760 long l;
1761 long i;
1763 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1764 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1765 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1766 /* fprintf (f, "\n "); */
1767 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1768 for (i = 0; i < m; i++)
1770 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1771 if (i != 0)
1772 fprintf (f, " ");
1773 fprintf (f, "%ld", l);
1776 else if (type & 0x40)
1778 /* Other packed type. */
1779 long msb, lsb;
1781 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1782 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1783 /* fprintf (f, "\n "); */
1784 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1787 fprintf (f, "]");
1789 if (offsetptr != NULL)
1790 *offsetptr = offset;
1793 void
1794 bfd_sym_print_type_information_table_entry (bfd *abfd,
1795 FILE *f,
1796 bfd_sym_type_information_table_entry *entry)
1798 unsigned char *buf;
1799 unsigned long offset;
1800 unsigned int i;
1802 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1803 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1804 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1805 entry->nte_index,
1806 entry->physical_size, entry->offset, entry->logical_size);
1808 fprintf (f, "\n ");
1810 buf = malloc (entry->physical_size);
1811 if (buf == NULL)
1813 fprintf (f, "[ERROR]\n");
1814 return;
1816 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1818 fprintf (f, "[ERROR]\n");
1819 free (buf);
1820 return;
1822 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1824 fprintf (f, "[ERROR]\n");
1825 free (buf);
1826 return;
1829 fprintf (f, "[");
1830 for (i = 0; i < entry->physical_size; i++)
1832 if (i == 0)
1833 fprintf (f, "0x%02x", buf[i]);
1834 else
1835 fprintf (f, " 0x%02x", buf[i]);
1838 fprintf (f, "]");
1839 fprintf (f, "\n ");
1841 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1843 if (offset != entry->physical_size)
1844 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size);
1845 free (buf);
1848 void
1849 bfd_sym_print_file_references_index_table_entry (bfd *abfd ATTRIBUTE_UNUSED,
1850 FILE *f,
1851 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED)
1853 fprintf (f, "[UNIMPLEMENTED]");
1856 void
1857 bfd_sym_print_constant_pool_entry (bfd *abfd ATTRIBUTE_UNUSED,
1858 FILE *f,
1859 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED)
1861 fprintf (f, "[UNIMPLEMENTED]");
1864 unsigned char *
1865 bfd_sym_display_name_table_entry (bfd *abfd,
1866 FILE *f,
1867 unsigned char *entry)
1869 unsigned long sym_index;
1870 unsigned long offset;
1871 bfd_sym_data_struct *sdata = NULL;
1873 BFD_ASSERT (bfd_sym_valid (abfd));
1874 sdata = abfd->tdata.sym_data;
1875 sym_index = (entry - sdata->name_table) / 2;
1877 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1879 unsigned short length = bfd_getb16 (entry + 2);
1880 fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, length, entry + 4);
1881 offset = 2 + length + 1;
1883 else
1885 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1886 fprintf (f, "[%8lu] \"%.*s\"\n", sym_index, entry[0], entry + 1);
1888 if (sdata->version >= BFD_SYM_VERSION_3_4)
1889 offset = entry[0] + 2;
1890 else
1891 offset = entry[0] + 1;
1894 return (entry + offset + (offset % 2));
1897 void
1898 bfd_sym_display_name_table (bfd *abfd, FILE *f)
1900 unsigned long name_table_len;
1901 unsigned char *name_table, *name_table_end, *cur;
1902 bfd_sym_data_struct *sdata = NULL;
1904 BFD_ASSERT (bfd_sym_valid (abfd));
1905 sdata = abfd->tdata.sym_data;
1907 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1908 name_table = sdata->name_table;
1909 name_table_end = name_table + name_table_len;
1911 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1913 cur = name_table;
1914 for (;;)
1916 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1917 if (cur >= name_table_end)
1918 break;
1922 void
1923 bfd_sym_display_resources_table (bfd *abfd, FILE *f)
1925 unsigned long i;
1926 bfd_sym_resources_table_entry entry;
1927 bfd_sym_data_struct *sdata = NULL;
1929 BFD_ASSERT (bfd_sym_valid (abfd));
1930 sdata = abfd->tdata.sym_data;
1932 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
1933 sdata->header.dshb_rte.dti_object_count);
1935 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
1937 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
1938 fprintf (f, " [%8lu] [INVALID]\n", i);
1939 else
1941 fprintf (f, " [%8lu] ", i);
1942 bfd_sym_print_resources_table_entry (abfd, f, &entry);
1943 fprintf (f, "\n");
1948 void
1949 bfd_sym_display_modules_table (bfd *abfd, FILE *f)
1951 unsigned long i;
1952 bfd_sym_modules_table_entry entry;
1953 bfd_sym_data_struct *sdata = NULL;
1955 BFD_ASSERT (bfd_sym_valid (abfd));
1956 sdata = abfd->tdata.sym_data;
1958 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
1959 sdata->header.dshb_mte.dti_object_count);
1961 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
1963 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
1964 fprintf (f, " [%8lu] [INVALID]\n", i);
1965 else
1967 fprintf (f, " [%8lu] ", i);
1968 bfd_sym_print_modules_table_entry (abfd, f, &entry);
1969 fprintf (f, "\n");
1974 void
1975 bfd_sym_display_file_references_table (bfd *abfd, FILE *f)
1977 unsigned long i;
1978 bfd_sym_file_references_table_entry entry;
1979 bfd_sym_data_struct *sdata = NULL;
1981 BFD_ASSERT (bfd_sym_valid (abfd));
1982 sdata = abfd->tdata.sym_data;
1984 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
1985 sdata->header.dshb_frte.dti_object_count);
1987 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
1989 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
1990 fprintf (f, " [%8lu] [INVALID]\n", i);
1991 else
1993 fprintf (f, " [%8lu] ", i);
1994 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
1995 fprintf (f, "\n");
2000 void
2001 bfd_sym_display_contained_modules_table (bfd *abfd, FILE *f)
2003 unsigned long i;
2004 bfd_sym_contained_modules_table_entry entry;
2005 bfd_sym_data_struct *sdata = NULL;
2007 BFD_ASSERT (bfd_sym_valid (abfd));
2008 sdata = abfd->tdata.sym_data;
2010 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
2011 sdata->header.dshb_cmte.dti_object_count);
2013 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2015 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
2016 fprintf (f, " [%8lu] [INVALID]\n", i);
2017 else
2019 fprintf (f, " [%8lu] ", i);
2020 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
2021 fprintf (f, "\n");
2026 void
2027 bfd_sym_display_contained_variables_table (bfd *abfd, FILE *f)
2029 unsigned long i;
2030 bfd_sym_contained_variables_table_entry entry;
2031 bfd_sym_data_struct *sdata = NULL;
2033 BFD_ASSERT (bfd_sym_valid (abfd));
2034 sdata = abfd->tdata.sym_data;
2036 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2037 sdata->header.dshb_cvte.dti_object_count);
2039 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2041 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2042 fprintf (f, " [%8lu] [INVALID]\n", i);
2043 else
2045 fprintf (f, " [%8lu] ", i);
2046 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2047 fprintf (f, "\n");
2051 fprintf (f, "\n");
2054 void
2055 bfd_sym_display_contained_statements_table (bfd *abfd, FILE *f)
2057 unsigned long i;
2058 bfd_sym_contained_statements_table_entry entry;
2059 bfd_sym_data_struct *sdata = NULL;
2061 BFD_ASSERT (bfd_sym_valid (abfd));
2062 sdata = abfd->tdata.sym_data;
2064 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
2065 sdata->header.dshb_csnte.dti_object_count);
2067 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2069 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
2070 fprintf (f, " [%8lu] [INVALID]\n", i);
2071 else
2073 fprintf (f, " [%8lu] ", i);
2074 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
2075 fprintf (f, "\n");
2080 void
2081 bfd_sym_display_contained_labels_table (bfd *abfd, FILE *f)
2083 unsigned long i;
2084 bfd_sym_contained_labels_table_entry entry;
2085 bfd_sym_data_struct *sdata = NULL;
2087 BFD_ASSERT (bfd_sym_valid (abfd));
2088 sdata = abfd->tdata.sym_data;
2090 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
2091 sdata->header.dshb_clte.dti_object_count);
2093 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2095 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
2096 fprintf (f, " [%8lu] [INVALID]\n", i);
2097 else
2099 fprintf (f, " [%8lu] ", i);
2100 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
2101 fprintf (f, "\n");
2106 void
2107 bfd_sym_display_contained_types_table (bfd *abfd, FILE *f)
2109 unsigned long i;
2110 bfd_sym_contained_types_table_entry entry;
2111 bfd_sym_data_struct *sdata = NULL;
2113 BFD_ASSERT (bfd_sym_valid (abfd));
2114 sdata = abfd->tdata.sym_data;
2116 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
2117 sdata->header.dshb_ctte.dti_object_count);
2119 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2121 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2122 fprintf (f, " [%8lu] [INVALID]\n", i);
2123 else
2125 fprintf (f, " [%8lu] ", i);
2126 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2127 fprintf (f, "\n");
2132 void
2133 bfd_sym_display_file_references_index_table (bfd *abfd, FILE *f)
2135 unsigned long i;
2136 bfd_sym_file_references_index_table_entry entry;
2137 bfd_sym_data_struct *sdata = NULL;
2139 BFD_ASSERT (bfd_sym_valid (abfd));
2140 sdata = abfd->tdata.sym_data;
2142 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
2143 sdata->header.dshb_fite.dti_object_count);
2145 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2147 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2148 fprintf (f, " [%8lu] [INVALID]\n", i);
2149 else
2151 fprintf (f, " [%8lu] ", i);
2152 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2153 fprintf (f, "\n");
2158 void
2159 bfd_sym_display_constant_pool (bfd *abfd, FILE *f)
2161 unsigned long i;
2162 bfd_sym_constant_pool_entry entry;
2163 bfd_sym_data_struct *sdata = NULL;
2165 BFD_ASSERT (bfd_sym_valid (abfd));
2166 sdata = abfd->tdata.sym_data;
2168 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2169 sdata->header.dshb_const.dti_object_count);
2171 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2173 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2174 fprintf (f, " [%8lu] [INVALID]\n", i);
2175 else
2177 fprintf (f, " [%8lu] ", i);
2178 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2179 fprintf (f, "\n");
2184 void
2185 bfd_sym_display_type_information_table (bfd *abfd, FILE *f)
2187 unsigned long i;
2188 bfd_sym_type_table_entry sym_index;
2189 bfd_sym_type_information_table_entry entry;
2190 bfd_sym_data_struct *sdata = NULL;
2192 BFD_ASSERT (bfd_sym_valid (abfd));
2193 sdata = abfd->tdata.sym_data;
2195 if (sdata->header.dshb_tte.dti_object_count > 99)
2196 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2197 sdata->header.dshb_tte.dti_object_count - 99);
2198 else
2200 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2201 return;
2204 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2206 if (bfd_sym_fetch_type_table_entry (abfd, &sym_index, i - 100) < 0)
2207 fprintf (f, " [%8lu] [INVALID]\n", i);
2208 else
2210 fprintf (f, " [%8lu] (TINFO %lu) ", i, sym_index);
2212 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, sym_index) < 0)
2213 fprintf (f, "[INVALID]");
2214 else
2215 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2217 fprintf (f, "\n");
2223 bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
2225 asection *bfdsec;
2226 const char *name = "symbols";
2228 mdata->name_table = 0;
2229 mdata->sbfd = abfd;
2230 mdata->version = version;
2232 bfd_seek (abfd, 0, SEEK_SET);
2233 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2234 return -1;
2236 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2237 if (mdata->name_table == NULL)
2238 return -1;
2240 bfdsec = bfd_make_section_anyway_with_flags (abfd, name, SEC_HAS_CONTENTS);
2241 if (bfdsec == NULL)
2242 return -1;
2244 bfdsec->vma = 0;
2245 bfdsec->lma = 0;
2246 bfdsec->size = 0;
2247 bfdsec->filepos = 0;
2248 bfdsec->alignment_power = 0;
2250 abfd->tdata.sym_data = mdata;
2252 return 0;
2255 const bfd_target *
2256 bfd_sym_object_p (bfd *abfd)
2258 bfd_sym_version version = -1;
2259 bfd_sym_data_struct *mdata;
2261 bfd_seek (abfd, 0, SEEK_SET);
2262 if (bfd_sym_read_version (abfd, &version) != 0)
2263 goto wrong;
2265 mdata = (bfd_sym_data_struct *) bfd_alloc (abfd, sizeof (*mdata));
2266 if (mdata == NULL)
2267 goto fail;
2269 if (bfd_sym_scan (abfd, version, mdata) != 0)
2270 goto wrong;
2272 return abfd->xvec;
2274 wrong:
2275 bfd_set_error (bfd_error_wrong_format);
2277 fail:
2278 return NULL;
2281 #define bfd_sym_make_empty_symbol _bfd_generic_make_empty_symbol
2283 void
2284 bfd_sym_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED, asymbol *symbol, symbol_info *ret)
2286 bfd_symbol_info (symbol, ret);
2289 long
2290 bfd_sym_get_symtab_upper_bound (bfd *abfd ATTRIBUTE_UNUSED)
2292 return 0;
2295 long
2296 bfd_sym_canonicalize_symtab (bfd *abfd ATTRIBUTE_UNUSED, asymbol **sym ATTRIBUTE_UNUSED)
2298 return 0;
2302 bfd_sym_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED,
2303 struct bfd_link_info *info ATTRIBUTE_UNUSED)
2305 return 0;
2308 const bfd_target sym_vec =
2310 "sym", /* Name. */
2311 bfd_target_sym_flavour, /* Flavour. */
2312 BFD_ENDIAN_BIG, /* Byteorder. */
2313 BFD_ENDIAN_BIG, /* Header byteorder. */
2314 (HAS_RELOC | EXEC_P | /* Object flags. */
2315 HAS_LINENO | HAS_DEBUG |
2316 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2317 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2318 | SEC_ROM | SEC_HAS_CONTENTS), /* Section_flags. */
2319 0, /* Symbol_leading_char. */
2320 ' ', /* AR_pad_char. */
2321 16, /* AR_max_namelen. */
2322 0, /* match priority. */
2323 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2324 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2325 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
2326 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2327 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2328 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Hdrs. */
2329 { /* bfd_check_format. */
2330 _bfd_dummy_target,
2331 bfd_sym_object_p, /* bfd_check_format. */
2332 _bfd_dummy_target,
2333 _bfd_dummy_target,
2335 { /* bfd_set_format. */
2336 _bfd_bool_bfd_false_error,
2337 bfd_sym_mkobject,
2338 _bfd_bool_bfd_false_error,
2339 _bfd_bool_bfd_false_error,
2341 { /* bfd_write_contents. */
2342 _bfd_bool_bfd_false_error,
2343 _bfd_bool_bfd_true,
2344 _bfd_bool_bfd_false_error,
2345 _bfd_bool_bfd_false_error,
2348 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2349 BFD_JUMP_TABLE_COPY (_bfd_generic),
2350 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2351 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2352 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2353 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs),
2354 BFD_JUMP_TABLE_WRITE (bfd_sym),
2355 BFD_JUMP_TABLE_LINK (bfd_sym),
2356 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2358 NULL,
2360 NULL