* rddbg.c (read_section_stabs_debugging_info): Also recognize
[binutils.git] / bfd / xsym.c
blob99b4eb719c4201eb3ffb2b83452c4d7485f1f388
1 /* xSYM symbol-file support for BFD.
2 Copyright 1999, 2000, 2001, 2002
3 Free Software Foundation, Inc.
5 This file is part of BFD, the Binary File Descriptor library.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #include "xsym.h"
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include "libbfd.h"
26 #define bfd_sym_close_and_cleanup _bfd_generic_close_and_cleanup
27 #define bfd_sym_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
28 #define bfd_sym_new_section_hook _bfd_generic_new_section_hook
29 #define bfd_sym_bfd_is_local_label_name bfd_generic_is_local_label_name
30 #define bfd_sym_get_lineno _bfd_nosymbols_get_lineno
31 #define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line
32 #define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
33 #define bfd_sym_read_minisymbols _bfd_generic_read_minisymbols
34 #define bfd_sym_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
35 #define bfd_sym_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
36 #define bfd_sym_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
37 #define bfd_sym_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
38 #define bfd_sym_set_arch_mach _bfd_generic_set_arch_mach
39 #define bfd_sym_get_section_contents _bfd_generic_get_section_contents
40 #define bfd_sym_set_section_contents _bfd_generic_set_section_contents
41 #define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
42 #define bfd_sym_bfd_relax_section bfd_generic_relax_section
43 #define bfd_sym_bfd_gc_sections bfd_generic_gc_sections
44 #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections
45 #define bfd_sym_bfd_discard_group bfd_generic_discard_group
46 #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
47 #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
48 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
49 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
50 #define bfd_sym_bfd_final_link _bfd_generic_final_link
51 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
52 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
54 static int pstrcmp PARAMS ((unsigned char *, unsigned char *));
55 static unsigned long compute_offset
56 PARAMS ((unsigned long, unsigned long, unsigned long, unsigned long));
58 extern const bfd_target sym_vec;
60 static int
61 pstrcmp (a, b)
62 unsigned char *a;
63 unsigned char *b;
65 unsigned char clen;
66 int ret;
68 clen = (a[0] > b[0]) ? a[0] : b[0];
69 ret = memcmp (a + 1, b + 1, clen);
70 if (ret != 0)
71 return ret;
73 if (a[0] == b[0])
74 return 0;
75 else if (a[0] < b[0])
76 return -1;
77 else
78 return 0;
81 static unsigned long
82 compute_offset (first_page, page_size, entry_size, index)
83 unsigned long first_page;
84 unsigned long page_size;
85 unsigned long entry_size;
86 unsigned long index;
88 unsigned long entries_per_page = page_size / entry_size;
89 unsigned long page_number = first_page + (index / entries_per_page);
90 unsigned long page_offset = (index % entries_per_page) * entry_size;
92 return (page_number * page_size) + page_offset;
95 boolean
96 bfd_sym_mkobject (abfd)
97 bfd *abfd ATTRIBUTE_UNUSED;
99 return (boolean) true;
102 void
103 bfd_sym_print_symbol (abfd, afile, symbol, how)
104 bfd *abfd ATTRIBUTE_UNUSED;
105 PTR afile ATTRIBUTE_UNUSED;
106 asymbol *symbol ATTRIBUTE_UNUSED;
107 bfd_print_symbol_type how ATTRIBUTE_UNUSED;
109 return;
112 boolean
113 bfd_sym_valid (abfd)
114 bfd *abfd;
116 if (abfd == NULL || abfd->xvec == NULL)
117 return 0;
119 return (abfd->xvec == &sym_vec);
122 unsigned char *
123 bfd_sym_read_name_table (abfd, dshb)
124 bfd *abfd;
125 bfd_sym_header_block *dshb;
127 unsigned char *rstr;
128 long ret;
129 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
130 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
132 rstr = (unsigned char *) bfd_alloc (abfd, table_size);
133 if (rstr == NULL)
134 return rstr;
136 bfd_seek (abfd, table_offset, SEEK_SET);
137 ret = bfd_bread (rstr, table_size, abfd);
138 if ((ret < 0) || ((unsigned long) ret != table_size))
140 bfd_release (abfd, rstr);
141 return NULL;
144 return rstr;
147 void
148 bfd_sym_parse_file_reference_v32 (buf, len, entry)
149 unsigned char *buf;
150 size_t len;
151 bfd_sym_file_reference *entry;
153 BFD_ASSERT (len == 6);
155 entry->fref_frte_index = bfd_getb16 (buf);
156 entry->fref_offset = bfd_getb32 (buf + 2);
159 void
160 bfd_sym_parse_disk_table_v32 (buf, len, table)
161 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 (buf, len, header)
174 unsigned char *buf;
175 size_t len;
176 bfd_sym_header_block *header;
178 BFD_ASSERT (len == 154);
180 memcpy (header->dshb_id, buf, 32);
181 header->dshb_page_size = bfd_getb16 (buf + 32);
182 header->dshb_hash_page = bfd_getb16 (buf + 34);
183 header->dshb_root_mte = bfd_getb16 (buf + 36);
184 header->dshb_mod_date = bfd_getb32 (buf + 38);
186 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
187 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
188 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
189 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
190 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
191 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
192 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
193 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
194 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
195 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
196 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
197 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
198 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
200 memcpy (&header->dshb_file_creator, buf + 146, 4);
201 memcpy (&header->dshb_file_type, buf + 150, 4);
205 bfd_sym_read_header_v32 (abfd, header)
206 bfd *abfd;
207 bfd_sym_header_block *header;
209 unsigned char buf[154];
210 long ret;
212 ret = bfd_bread (buf, 154, abfd);
213 if (ret != 154)
214 return -1;
216 bfd_sym_parse_header_v32 (buf, 154, header);
218 return 0;
222 bfd_sym_read_header_v34 (abfd, header)
223 bfd *abfd ATTRIBUTE_UNUSED;
224 bfd_sym_header_block *header ATTRIBUTE_UNUSED;
226 abort ();
230 bfd_sym_read_header (abfd, header, version)
231 bfd *abfd;
232 bfd_sym_header_block *header;
233 bfd_sym_version version;
235 switch (version)
237 case BFD_SYM_VERSION_3_5:
238 case BFD_SYM_VERSION_3_4:
239 return bfd_sym_read_header_v34 (abfd, header);
240 case BFD_SYM_VERSION_3_3:
241 case BFD_SYM_VERSION_3_2:
242 return bfd_sym_read_header_v32 (abfd, header);
243 case BFD_SYM_VERSION_3_1:
244 default:
245 return false;
250 bfd_sym_read_version (abfd, version)
251 bfd *abfd;
252 bfd_sym_version *version;
254 unsigned char version_string[32];
255 long ret;
257 ret = bfd_bread (version_string, sizeof (version_string), abfd);
258 if (ret != sizeof (version_string))
259 return -1;
261 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
262 *version = BFD_SYM_VERSION_3_1;
263 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
264 *version = BFD_SYM_VERSION_3_2;
265 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
266 *version = BFD_SYM_VERSION_3_3;
267 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
268 *version = BFD_SYM_VERSION_3_4;
269 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
270 *version = BFD_SYM_VERSION_3_5;
271 else
272 return -1;
274 return 0;
277 void
278 bfd_sym_display_table_summary (f, dti, name)
279 FILE *f;
280 bfd_sym_table_info *dti;
281 const char *name;
283 fprintf (f, "%-6s %13ld %13ld %13ld\n",
284 name,
285 dti->dti_first_page,
286 dti->dti_page_count,
287 dti->dti_object_count);
290 void
291 bfd_sym_display_header (f, dshb)
292 FILE *f;
293 bfd_sym_header_block *dshb;
295 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
296 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
297 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
298 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
299 fprintf (f, " Modification Date: ");
300 fprintf (f, "[unimplemented]");
301 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
303 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
304 dshb->dshb_file_creator, dshb->dshb_file_type);
306 fprintf (f, "Table Name First Page Page Count Object Count\n");
307 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
309 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
310 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
311 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
312 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
313 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
314 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
315 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
316 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
317 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
318 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
319 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
320 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
321 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
323 fprintf (f, "\n");
326 void
327 bfd_sym_parse_resources_table_entry_v32 (buf, len, entry)
328 unsigned char *buf;
329 size_t len;
330 bfd_sym_resources_table_entry *entry;
332 BFD_ASSERT (len == 18);
334 memcpy (&entry->rte_res_type, buf, 4);
335 entry->rte_res_number = bfd_getb16 (buf + 4);
336 entry->rte_nte_index = bfd_getb32 (buf + 6);
337 entry->rte_mte_first = bfd_getb16 (buf + 10);
338 entry->rte_mte_last = bfd_getb16 (buf + 12);
339 entry->rte_res_size = bfd_getb32 (buf + 14);
342 void
343 bfd_sym_parse_modules_table_entry_v33 (buf, len, entry)
344 unsigned char *buf;
345 size_t len;
346 bfd_sym_modules_table_entry *entry;
348 BFD_ASSERT (len == 46);
350 entry->mte_rte_index = bfd_getb16 (buf);
351 entry->mte_res_offset = bfd_getb32 (buf + 2);
352 entry->mte_size = bfd_getb32 (buf + 6);
353 entry->mte_kind = buf[10];
354 entry->mte_scope = buf[11];
355 entry->mte_parent = bfd_getb16 (buf + 12);
356 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
357 entry->mte_imp_end = bfd_getb32 (buf + 20);
358 entry->mte_nte_index = bfd_getb32 (buf + 24);
359 entry->mte_cmte_index = bfd_getb16 (buf + 28);
360 entry->mte_cvte_index = bfd_getb32 (buf + 30);
361 entry->mte_clte_index = bfd_getb16 (buf + 34);
362 entry->mte_ctte_index = bfd_getb16 (buf + 36);
363 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
364 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
367 void
368 bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry)
369 unsigned char *buf;
370 size_t len;
371 bfd_sym_file_references_table_entry *entry;
373 unsigned int type;
375 BFD_ASSERT (len == 10);
377 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
378 type = bfd_getb16 (buf);
380 switch (type)
382 case BFD_SYM_END_OF_LIST_3_2:
383 entry->generic.type = BFD_SYM_END_OF_LIST;
384 break;
386 case BFD_SYM_FILE_NAME_INDEX_3_2:
387 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
388 entry->filename.nte_index = bfd_getb32 (buf + 2);
389 entry->filename.mod_date = bfd_getb32 (buf + 6);
390 break;
392 default:
393 entry->entry.mte_index = type;
394 entry->entry.file_offset = bfd_getb32 (buf + 2);
398 void
399 bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry)
400 unsigned char *buf;
401 size_t len;
402 bfd_sym_contained_modules_table_entry *entry;
404 unsigned int type;
406 BFD_ASSERT (len == 6);
408 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
409 type = bfd_getb16 (buf);
411 switch (type)
413 case BFD_SYM_END_OF_LIST_3_2:
414 entry->generic.type = BFD_SYM_END_OF_LIST;
415 break;
417 default:
418 entry->entry.mte_index = type;
419 entry->entry.nte_index = bfd_getb32 (buf + 2);
420 break;
424 void
425 bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry)
426 unsigned char *buf;
427 size_t len;
428 bfd_sym_contained_variables_table_entry *entry;
430 unsigned int type;
432 BFD_ASSERT (len == 26);
434 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
435 type = bfd_getb16 (buf);
437 switch (type)
439 case BFD_SYM_END_OF_LIST_3_2:
440 entry->generic.type = BFD_SYM_END_OF_LIST;
441 break;
443 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
444 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
445 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
446 break;
448 default:
449 entry->entry.tte_index = type;
450 entry->entry.nte_index = bfd_getb32 (buf + 2);
451 entry->entry.file_delta = bfd_getb16 (buf + 6);
452 entry->entry.scope = buf[8];
453 entry->entry.la_size = buf[9];
455 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
457 entry->entry.address.scstruct.sca_kind = buf[10];
458 entry->entry.address.scstruct.sca_class = buf[11];
459 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
461 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
463 memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA);
464 entry->entry.address.lastruct.la_kind = buf[23];
466 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
468 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
469 entry->entry.address.biglastruct.big_la_kind = buf[12];
474 void
475 bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
476 unsigned char *buf;
477 size_t len;
478 bfd_sym_contained_statements_table_entry *entry;
480 unsigned int type;
482 BFD_ASSERT (len == 8);
484 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
485 type = bfd_getb16 (buf);
487 switch (type)
489 case BFD_SYM_END_OF_LIST_3_2:
490 entry->generic.type = BFD_SYM_END_OF_LIST;
491 break;
493 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
494 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
495 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
496 break;
498 default:
499 entry->entry.mte_index = type;
500 entry->entry.mte_offset = bfd_getb16 (buf + 2);
501 entry->entry.file_delta = bfd_getb32 (buf + 4);
502 break;
506 void
507 bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
508 unsigned char *buf;
509 size_t len;
510 bfd_sym_contained_labels_table_entry *entry;
512 unsigned int type;
514 BFD_ASSERT (len == 12);
516 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
517 type = bfd_getb16 (buf);
519 switch (type)
521 case BFD_SYM_END_OF_LIST_3_2:
522 entry->generic.type = BFD_SYM_END_OF_LIST;
523 break;
525 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
526 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
527 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
528 break;
530 default:
531 entry->entry.mte_index = type;
532 entry->entry.mte_offset = bfd_getb16 (buf + 2);
533 entry->entry.nte_index = bfd_getb32 (buf + 4);
534 entry->entry.file_delta = bfd_getb16 (buf + 8);
535 entry->entry.scope = bfd_getb16 (buf + 10);
536 break;
540 void
541 bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
542 unsigned char *buf;
543 size_t len;
544 bfd_sym_type_table_entry *entry;
546 BFD_ASSERT (len == 4);
548 *entry = bfd_getb32 (buf);
552 bfd_sym_fetch_resources_table_entry (abfd, entry, index)
553 bfd *abfd;
554 bfd_sym_resources_table_entry *entry;
555 unsigned long index;
557 void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *) = NULL;
558 unsigned long offset;
559 unsigned long entry_size;
560 unsigned char buf[18];
561 bfd_sym_data_struct *sdata = NULL;
563 BFD_ASSERT (bfd_sym_valid (abfd));
564 sdata = abfd->tdata.sym_data;
566 if (index == 0)
567 return -1;
569 switch (sdata->version)
571 case BFD_SYM_VERSION_3_5:
572 case BFD_SYM_VERSION_3_4:
573 return -1;
575 case BFD_SYM_VERSION_3_3:
576 case BFD_SYM_VERSION_3_2:
577 entry_size = 18;
578 parser = bfd_sym_parse_resources_table_entry_v32;
579 break;
581 case BFD_SYM_VERSION_3_1:
582 default:
583 return -1;
585 if (parser == NULL)
586 return -1;
588 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
589 sdata->header.dshb_page_size,
590 entry_size, index);
592 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
593 return -1;
594 if (bfd_bread (buf, entry_size, abfd) != entry_size)
595 return -1;
597 (*parser) (buf, entry_size, entry);
599 return 0;
603 bfd_sym_fetch_modules_table_entry (abfd, entry, index)
604 bfd *abfd;
605 bfd_sym_modules_table_entry *entry;
606 unsigned long index;
608 void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *) = NULL;
609 unsigned long offset;
610 unsigned long entry_size;
611 unsigned char buf[46];
612 bfd_sym_data_struct *sdata = NULL;
614 BFD_ASSERT (bfd_sym_valid (abfd));
615 sdata = abfd->tdata.sym_data;
617 if (index == 0)
618 return -1;
620 switch (sdata->version)
622 case BFD_SYM_VERSION_3_5:
623 case BFD_SYM_VERSION_3_4:
624 return -1;
626 case BFD_SYM_VERSION_3_3:
627 entry_size = 46;
628 parser = bfd_sym_parse_modules_table_entry_v33;
629 break;
631 case BFD_SYM_VERSION_3_2:
632 case BFD_SYM_VERSION_3_1:
633 default:
634 return -1;
636 if (parser == NULL)
637 return -1;
639 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
640 sdata->header.dshb_page_size,
641 entry_size, index);
643 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
644 return -1;
645 if (bfd_bread (buf, entry_size, abfd) != entry_size)
646 return -1;
648 (*parser) (buf, entry_size, entry);
650 return 0;
654 bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
655 bfd *abfd;
656 bfd_sym_file_references_table_entry *entry;
657 unsigned long index;
659 void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *) = NULL;
660 unsigned long offset;
661 unsigned long entry_size = 0;
662 unsigned char buf[8];
663 bfd_sym_data_struct *sdata = NULL;
665 BFD_ASSERT (bfd_sym_valid (abfd));
666 sdata = abfd->tdata.sym_data;
668 if (index == 0)
669 return -1;
671 switch (sdata->version)
673 case BFD_SYM_VERSION_3_3:
674 case BFD_SYM_VERSION_3_2:
675 entry_size = 10;
676 parser = bfd_sym_parse_file_references_table_entry_v32;
677 break;
679 case BFD_SYM_VERSION_3_5:
680 case BFD_SYM_VERSION_3_4:
681 case BFD_SYM_VERSION_3_1:
682 default:
683 break;
686 if (parser == NULL)
687 return -1;
689 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
690 sdata->header.dshb_page_size,
691 entry_size, index);
693 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
694 return -1;
695 if (bfd_bread (buf, entry_size, abfd) != entry_size)
696 return -1;
698 (*parser) (buf, entry_size, entry);
700 return 0;
704 bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
705 bfd *abfd;
706 bfd_sym_contained_modules_table_entry *entry;
707 unsigned long index;
709 void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *) = NULL;
710 unsigned long offset;
711 unsigned long entry_size = 0;
712 unsigned char buf[6];
713 bfd_sym_data_struct *sdata = NULL;
715 BFD_ASSERT (bfd_sym_valid (abfd));
716 sdata = abfd->tdata.sym_data;
718 if (index == 0)
719 return -1;
721 switch (sdata->version)
723 case BFD_SYM_VERSION_3_3:
724 case BFD_SYM_VERSION_3_2:
725 entry_size = 6;
726 parser = bfd_sym_parse_contained_modules_table_entry_v32;
727 break;
729 case BFD_SYM_VERSION_3_5:
730 case BFD_SYM_VERSION_3_4:
731 case BFD_SYM_VERSION_3_1:
732 default:
733 break;
736 if (parser == NULL)
737 return -1;
739 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
740 sdata->header.dshb_page_size,
741 entry_size, index);
743 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
744 return -1;
745 if (bfd_bread (buf, entry_size, abfd) != entry_size)
746 return -1;
748 (*parser) (buf, entry_size, entry);
750 return 0;
754 bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
755 bfd *abfd;
756 bfd_sym_contained_variables_table_entry *entry;
757 unsigned long index;
759 void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *) = NULL;
760 unsigned long offset;
761 unsigned long entry_size = 0;
762 unsigned char buf[26];
763 bfd_sym_data_struct *sdata = NULL;
765 BFD_ASSERT (bfd_sym_valid (abfd));
766 sdata = abfd->tdata.sym_data;
768 if (index == 0)
769 return -1;
771 switch (sdata->version)
773 case BFD_SYM_VERSION_3_3:
774 case BFD_SYM_VERSION_3_2:
775 entry_size = 26;
776 parser = bfd_sym_parse_contained_variables_table_entry_v32;
777 break;
779 case BFD_SYM_VERSION_3_5:
780 case BFD_SYM_VERSION_3_4:
781 case BFD_SYM_VERSION_3_1:
782 default:
783 break;
786 if (parser == NULL)
787 return -1;
789 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
790 sdata->header.dshb_page_size,
791 entry_size, index);
793 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
794 return -1;
795 if (bfd_bread (buf, entry_size, abfd) != entry_size)
796 return -1;
798 (*parser) (buf, entry_size, entry);
800 return 0;
804 bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
805 bfd *abfd;
806 bfd_sym_contained_statements_table_entry *entry;
807 unsigned long index;
809 void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *) = NULL;
810 unsigned long offset;
811 unsigned long entry_size = 0;
812 unsigned char buf[8];
813 bfd_sym_data_struct *sdata = NULL;
815 BFD_ASSERT (bfd_sym_valid (abfd));
816 sdata = abfd->tdata.sym_data;
818 if (index == 0)
819 return -1;
821 switch (sdata->version)
823 case BFD_SYM_VERSION_3_3:
824 case BFD_SYM_VERSION_3_2:
825 entry_size = 8;
826 parser = bfd_sym_parse_contained_statements_table_entry_v32;
827 break;
829 case BFD_SYM_VERSION_3_5:
830 case BFD_SYM_VERSION_3_4:
831 case BFD_SYM_VERSION_3_1:
832 default:
833 break;
836 if (parser == NULL)
837 return -1;
839 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
840 sdata->header.dshb_page_size,
841 entry_size, index);
843 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
844 return -1;
845 if (bfd_bread (buf, entry_size, abfd) != entry_size)
846 return -1;
848 (*parser) (buf, entry_size, entry);
850 return 0;
854 bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
855 bfd *abfd;
856 bfd_sym_contained_labels_table_entry *entry;
857 unsigned long index;
859 void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *) = NULL;
860 unsigned long offset;
861 unsigned long entry_size = 0;
862 unsigned char buf[12];
863 bfd_sym_data_struct *sdata = NULL;
865 BFD_ASSERT (bfd_sym_valid (abfd));
866 sdata = abfd->tdata.sym_data;
868 if (index == 0)
869 return -1;
871 switch (sdata->version)
873 case BFD_SYM_VERSION_3_3:
874 case BFD_SYM_VERSION_3_2:
875 entry_size = 12;
876 parser = bfd_sym_parse_contained_labels_table_entry_v32;
877 break;
879 case BFD_SYM_VERSION_3_5:
880 case BFD_SYM_VERSION_3_4:
881 case BFD_SYM_VERSION_3_1:
882 default:
883 break;
886 if (parser == NULL)
887 return -1;
889 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
890 sdata->header.dshb_page_size,
891 entry_size, index);
893 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
894 return -1;
895 if (bfd_bread (buf, entry_size, abfd) != entry_size)
896 return -1;
898 (*parser) (buf, entry_size, entry);
900 return 0;
904 bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
905 bfd *abfd;
906 bfd_sym_contained_types_table_entry *entry;
907 unsigned long index;
909 void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *) = NULL;
910 unsigned long offset;
911 unsigned long entry_size = 0;
912 unsigned char buf[0];
913 bfd_sym_data_struct *sdata = NULL;
915 BFD_ASSERT (bfd_sym_valid (abfd));
916 sdata = abfd->tdata.sym_data;
918 if (index == 0)
919 return -1;
921 switch (sdata->version)
923 case BFD_SYM_VERSION_3_3:
924 case BFD_SYM_VERSION_3_2:
925 entry_size = 0;
926 parser = NULL;
927 break;
929 case BFD_SYM_VERSION_3_5:
930 case BFD_SYM_VERSION_3_4:
931 case BFD_SYM_VERSION_3_1:
932 default:
933 break;
936 if (parser == NULL)
937 return -1;
939 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
940 sdata->header.dshb_page_size,
941 entry_size, index);
943 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
944 return -1;
945 if (bfd_bread (buf, entry_size, abfd) != entry_size)
946 return -1;
948 (*parser) (buf, entry_size, entry);
950 return 0;
954 bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
955 bfd *abfd;
956 bfd_sym_file_references_index_table_entry *entry;
957 unsigned long index;
959 void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *) = NULL;
960 unsigned long offset;
961 unsigned long entry_size = 0;
962 unsigned char buf[0];
963 bfd_sym_data_struct *sdata = NULL;
965 BFD_ASSERT (bfd_sym_valid (abfd));
966 sdata = abfd->tdata.sym_data;
968 if (index == 0)
969 return -1;
971 switch (sdata->version)
973 case BFD_SYM_VERSION_3_3:
974 case BFD_SYM_VERSION_3_2:
975 entry_size = 0;
976 parser = NULL;
977 break;
979 case BFD_SYM_VERSION_3_5:
980 case BFD_SYM_VERSION_3_4:
981 case BFD_SYM_VERSION_3_1:
982 default:
983 break;
986 if (parser == NULL)
987 return -1;
989 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
990 sdata->header.dshb_page_size,
991 entry_size, index);
993 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
994 return -1;
995 if (bfd_bread (buf, entry_size, abfd) != entry_size)
996 return -1;
998 (*parser) (buf, entry_size, entry);
1000 return 0;
1004 bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
1005 bfd *abfd;
1006 bfd_sym_constant_pool_entry *entry;
1007 unsigned long index;
1009 void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *) = NULL;
1010 unsigned long offset;
1011 unsigned long entry_size = 0;
1012 unsigned char buf[0];
1013 bfd_sym_data_struct *sdata = NULL;
1015 BFD_ASSERT (bfd_sym_valid (abfd));
1016 sdata = abfd->tdata.sym_data;
1018 if (index == 0)
1019 return -1;
1021 switch (sdata->version)
1023 case BFD_SYM_VERSION_3_3:
1024 case BFD_SYM_VERSION_3_2:
1025 entry_size = 0;
1026 parser = NULL;
1027 break;
1029 case BFD_SYM_VERSION_3_5:
1030 case BFD_SYM_VERSION_3_4:
1031 case BFD_SYM_VERSION_3_1:
1032 default:
1033 break;
1036 if (parser == NULL)
1037 return -1;
1039 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1040 sdata->header.dshb_page_size,
1041 entry_size, index);
1043 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1044 return -1;
1045 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1046 return -1;
1048 (*parser) (buf, entry_size, entry);
1050 return 0;
1054 bfd_sym_fetch_type_table_entry (abfd, entry, index)
1055 bfd *abfd;
1056 bfd_sym_type_table_entry *entry;
1057 unsigned long index;
1059 void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *) = NULL;
1060 unsigned long offset;
1061 unsigned long entry_size = 0;
1062 unsigned char buf[4];
1063 bfd_sym_data_struct *sdata = NULL;
1065 BFD_ASSERT (bfd_sym_valid (abfd));
1066 sdata = abfd->tdata.sym_data;
1068 switch (sdata->version)
1070 case BFD_SYM_VERSION_3_3:
1071 case BFD_SYM_VERSION_3_2:
1072 entry_size = 4;
1073 parser = bfd_sym_parse_type_table_entry_v32;
1074 break;
1076 case BFD_SYM_VERSION_3_5:
1077 case BFD_SYM_VERSION_3_4:
1078 case BFD_SYM_VERSION_3_1:
1079 default:
1080 break;
1083 if (parser == NULL)
1084 return -1;
1086 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1087 sdata->header.dshb_page_size,
1088 entry_size, index);
1090 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1091 return -1;
1092 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1093 return -1;
1095 (*parser) (buf, entry_size, entry);
1097 return 0;
1101 bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
1102 bfd *abfd;
1103 bfd_sym_type_information_table_entry *entry;
1104 unsigned long offset;
1106 unsigned char buf[4];
1107 bfd_sym_data_struct *sdata = NULL;
1109 BFD_ASSERT (bfd_sym_valid (abfd));
1110 sdata = abfd->tdata.sym_data;
1112 if (index == 0)
1113 return -1;
1115 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1116 return -1;
1118 if (bfd_bread (buf, 4, abfd) != 4)
1119 return -1;
1120 entry->nte_index = bfd_getb32 (buf);
1122 if (bfd_bread (buf, 2, abfd) != 2)
1123 return -1;
1124 entry->physical_size = bfd_getb16 (buf);
1126 if (entry->physical_size & 0x8000)
1128 if (bfd_bread (buf, 4, abfd) != 4)
1129 return -1;
1130 entry->physical_size &= 0x7fff;
1131 entry->logical_size = bfd_getb32 (buf);
1132 entry->offset = offset + 10;
1134 else
1136 if (bfd_bread (buf, 2, abfd) != 2)
1137 return -1;
1138 entry->physical_size &= 0x7fff;
1139 entry->logical_size = bfd_getb16 (buf);
1140 entry->offset = offset + 8;
1143 return 0;
1147 bfd_sym_fetch_type_table_information (abfd, entry, index)
1148 bfd *abfd;
1149 bfd_sym_type_information_table_entry *entry;
1150 unsigned long index;
1152 bfd_sym_type_table_entry tindex;
1153 bfd_sym_data_struct *sdata = NULL;
1155 BFD_ASSERT (bfd_sym_valid (abfd));
1156 sdata = abfd->tdata.sym_data;
1158 if (sdata->header.dshb_tte.dti_object_count <= 99)
1159 return -1;
1160 if (index < 100)
1161 return -1;
1163 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
1164 return -1;
1165 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1166 return -1;
1168 return 0;
1171 const unsigned char *
1172 bfd_sym_symbol_name (abfd, index)
1173 bfd *abfd;
1174 unsigned long index;
1176 bfd_sym_data_struct *sdata = NULL;
1178 BFD_ASSERT (bfd_sym_valid (abfd));
1179 sdata = abfd->tdata.sym_data;
1181 if (index == 0)
1182 return "";
1184 index *= 2;
1185 if ((index / sdata->header.dshb_page_size) > sdata->header.dshb_nte.dti_page_count)
1186 return "\009[INVALID]";
1188 return ((const unsigned char *) sdata->name_table + index);
1191 const unsigned char *
1192 bfd_sym_module_name (abfd, index)
1193 bfd *abfd;
1194 unsigned long index;
1196 bfd_sym_modules_table_entry entry;
1198 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
1199 return "\011[INVALID]";
1201 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1204 const char *
1205 bfd_sym_unparse_storage_kind (kind)
1206 enum bfd_sym_storage_kind kind;
1208 switch (kind)
1210 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1211 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1212 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1213 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1214 default: return "[UNKNOWN]";
1218 const char *
1219 bfd_sym_unparse_storage_class (kind)
1220 enum bfd_sym_storage_class kind;
1222 switch (kind)
1224 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1225 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1226 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1227 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1228 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1229 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1230 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1231 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1232 default: return "[UNKNOWN]";
1236 const char *
1237 bfd_sym_unparse_module_kind (kind)
1238 enum bfd_sym_module_kind kind;
1240 switch (kind)
1242 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1243 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1244 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1245 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1246 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1247 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1248 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1249 default: return "[UNKNOWN]";
1253 const char *
1254 bfd_sym_unparse_symbol_scope (scope)
1255 enum bfd_sym_symbol_scope scope;
1257 switch (scope)
1259 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1260 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1261 default:
1262 return "[UNKNOWN]";
1266 void
1267 bfd_sym_print_file_reference (abfd, f, entry)
1268 bfd *abfd;
1269 FILE *f;
1270 bfd_sym_file_reference *entry;
1272 bfd_sym_file_references_table_entry frtentry;
1273 int ret;
1275 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry, entry->fref_frte_index);
1276 fprintf (f, "FILE ");
1278 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1279 fprintf (f, "[INVALID]");
1280 else
1281 fprintf (f, "\"%.*s\"",
1282 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1283 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1285 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1288 void
1289 bfd_sym_print_resources_table_entry (abfd, f, entry)
1290 bfd *abfd;
1291 FILE *f;
1292 bfd_sym_resources_table_entry *entry;
1294 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1295 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1296 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1297 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1298 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1301 void
1302 bfd_sym_print_modules_table_entry (abfd, f, entry)
1303 bfd *abfd;
1304 FILE *f;
1305 bfd_sym_modules_table_entry *entry;
1307 fprintf (f, "\"%.*s\" (NTE %lu)",
1308 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1309 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1310 entry->mte_nte_index);
1312 fprintf (f, "\n ");
1314 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1315 fprintf (f, " range %lu -- %lu", entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1317 fprintf (f, "\n ");
1319 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1320 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1322 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1323 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1325 fprintf (f, "\n ");
1327 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1328 entry->mte_cmte_index, entry->mte_cvte_index,
1329 entry->mte_clte_index, entry->mte_ctte_index,
1330 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1332 if (entry->mte_parent != 0)
1333 fprintf (f, ", parent %lu", entry->mte_parent);
1334 else
1335 fprintf (f, ", no parent");
1337 if (entry->mte_cmte_index != 0)
1338 fprintf (f, ", child %lu", entry->mte_cmte_index);
1339 else
1340 fprintf (f, ", no child");
1342 #if 0
1344 MTE bfd_sym_modules_table_entry pentry;
1346 ret = bfd_sym_fetch_modules_table_entry (abfd, &pentry, entry->mte_parent);
1347 if (ret < 0)
1348 fprintf (f, " parent MTE %lu [INVALID]\n", entry->mte_parent);
1349 else
1350 fprintf (f, " parent MTE %lu \"%.*s\"\n",
1351 entry->mte_parent,
1352 bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[0],
1353 &bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[1]);
1355 #endif
1358 void
1359 bfd_sym_print_file_references_table_entry (abfd, f, entry)
1360 bfd *abfd;
1361 FILE *f;
1362 bfd_sym_file_references_table_entry *entry;
1364 switch (entry->generic.type)
1366 case BFD_SYM_FILE_NAME_INDEX:
1367 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1368 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1369 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1370 entry->filename.nte_index);
1372 fprintf (f, "[UNIMPLEMENTED]");
1373 /* printModDate (entry->filename.mod_date); */
1374 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1375 break;
1377 case BFD_SYM_END_OF_LIST:
1378 fprintf (f, "END");
1379 break;
1381 default:
1382 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1383 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1384 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1385 entry->entry.mte_index,
1386 entry->entry.file_offset);
1387 break;
1391 void
1392 bfd_sym_print_contained_modules_table_entry (abfd, f, entry)
1393 bfd *abfd;
1394 FILE *f;
1395 bfd_sym_contained_modules_table_entry *entry;
1397 switch (entry->generic.type)
1399 case BFD_SYM_END_OF_LIST:
1400 fprintf (f, "END");
1401 break;
1403 default:
1404 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
1405 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1406 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1407 entry->entry.mte_index,
1408 entry->entry.nte_index);
1409 break;
1413 void
1414 bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
1415 bfd *abfd;
1416 FILE *f;
1417 bfd_sym_contained_variables_table_entry *entry;
1419 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1421 fprintf (f, "END");
1422 return;
1425 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1427 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1428 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1429 return;
1432 fprintf (f, "\"%.*s\" (NTE %lu)",
1433 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1434 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1435 entry->entry.nte_index);
1437 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1438 fprintf (f, ", offset %lu", entry->entry.file_delta);
1439 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1441 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1442 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1443 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1444 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1445 entry->entry.address.scstruct.sca_offset);
1446 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1448 unsigned long i;
1450 fprintf (f, ", la [");
1451 for (i = 0; i < entry->entry.la_size; i++)
1452 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1453 fprintf (f, "]");
1455 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1456 fprintf (f, ", bigla %lu, biglakind %u",
1457 entry->entry.address.biglastruct.big_la,
1458 entry->entry.address.biglastruct.big_la_kind);
1460 else
1461 fprintf (f, ", la [INVALID]");
1464 void
1465 bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
1466 bfd *abfd;
1467 FILE *f;
1468 bfd_sym_contained_statements_table_entry *entry;
1470 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1472 fprintf (f, "END");
1473 return;
1476 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1478 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1479 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1480 return;
1483 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1484 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1485 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1486 entry->entry.mte_index,
1487 entry->entry.mte_offset,
1488 entry->entry.file_delta);
1491 void
1492 bfd_sym_print_contained_labels_table_entry (abfd, f, entry)
1493 bfd *abfd;
1494 FILE *f;
1495 bfd_sym_contained_labels_table_entry *entry;
1497 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1499 fprintf (f, "END");
1500 return;
1503 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1505 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1506 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1507 return;
1510 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1511 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1512 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1513 entry->entry.mte_index,
1514 entry->entry.mte_offset,
1515 entry->entry.file_delta,
1516 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1519 void
1520 bfd_sym_print_contained_types_table_entry (abfd, f, entry)
1521 bfd *abfd ATTRIBUTE_UNUSED;
1522 FILE *f;
1523 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED;
1525 fprintf (f, "[UNIMPLEMENTED]");
1528 const char *
1529 bfd_sym_type_operator_name (num)
1530 unsigned char num;
1532 switch (num)
1534 case 1: return "TTE";
1535 case 2: return "PointerTo";
1536 case 3: return "ScalarOf";
1537 case 4: return "ConstantOf";
1538 case 5: return "EnumerationOf";
1539 case 6: return "VectorOf";
1540 case 7: return "RecordOf";
1541 case 8: return "UnionOf";
1542 case 9: return "SubRangeOf";
1543 case 10: return "SetOf";
1544 case 11: return "NamedTypeOf";
1545 case 12: return "ProcOf";
1546 case 13: return "ValueOf";
1547 case 14: return "ArrayOf";
1548 default: return "[UNKNOWN OPERATOR]";
1552 const char *
1553 bfd_sym_type_basic_name (num)
1554 unsigned char num;
1556 switch (num)
1558 case 0: return "void";
1559 case 1: return "pascal string";
1560 case 2: return "unsigned long";
1561 case 3: return "signed long";
1562 case 4: return "extended (10 bytes)";
1563 case 5: return "pascal boolean (1 byte)";
1564 case 6: return "unsigned byte";
1565 case 7: return "signed byte";
1566 case 8: return "character (1 byte)";
1567 case 9: return "wide character (2 bytes)";
1568 case 10: return "unsigned short";
1569 case 11: return "signed short";
1570 case 12: return "singled";
1571 case 13: return "double";
1572 case 14: return "extended (12 bytes)";
1573 case 15: return "computational (8 bytes)";
1574 case 16: return "c string";
1575 case 17: return "as-is string";
1576 default: return "[UNKNOWN BASIC TYPE]";
1581 bfd_sym_fetch_long (buf, len, offset, offsetptr, value)
1582 unsigned char *buf;
1583 unsigned long len;
1584 unsigned long offset;
1585 unsigned long *offsetptr;
1586 long *value;
1588 int ret;
1590 if (offset >= len)
1592 *value = 0;
1593 offset += 0;
1594 ret = -1;
1596 else if (! (buf[offset] & 0x80))
1598 *value = buf[offset];
1599 offset += 1;
1600 ret = 0;
1602 else if (buf[offset] == 0xc0)
1604 if ((offset + 5) > len)
1606 *value = 0;
1607 offset = len;
1608 ret = -1;
1610 else
1612 *value = bfd_getb32 (buf + offset + 1);
1613 offset += 5;
1614 ret = 0;
1617 else if ((buf[offset] & 0xc0) == 0xc0)
1619 *value = -(buf[offset] & 0x3f);
1620 offset += 1;
1621 ret = 0;
1623 else if ((buf[offset] & 0xc0) == 0x80)
1625 if ((offset + 2) > len)
1627 *value = 0;
1628 offset = len;
1629 ret = -1;
1631 else
1633 *value = bfd_getb16 (buf + offset) & 0x3fff;
1634 offset += 2;
1635 ret = 0;
1638 else
1639 abort ();
1641 if (offsetptr != NULL)
1642 *offsetptr = offset;
1644 return ret;
1647 void
1648 bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
1649 bfd *abfd;
1650 FILE *f;
1651 unsigned char *buf;
1652 unsigned long len;
1653 unsigned long offset;
1654 unsigned long *offsetptr;
1656 unsigned int type;
1658 if (offset >= len)
1660 fprintf (f, "[NULL]");
1662 if (offsetptr != NULL)
1663 *offsetptr = offset;
1664 return;
1667 type = buf[offset];
1668 offset++;
1670 if (! (type & 0x80))
1672 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1674 if (offsetptr != NULL)
1675 *offsetptr = offset;
1676 return;
1679 if (type & 0x40)
1680 fprintf (f, "[packed ");
1681 else
1682 fprintf (f, "[");
1684 switch (type & 0x3f)
1686 case 1:
1688 long value;
1689 bfd_sym_type_information_table_entry tinfo;
1691 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1692 if (value <= 0)
1693 fprintf (f, "[INVALID]");
1694 else
1696 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1697 fprintf (f, "[INVALID]");
1698 else
1699 fprintf (f, "\"%.*s\"",
1700 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1701 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1703 fprintf (f, " (TTE %lu)", value);
1704 break;
1707 case 2:
1708 fprintf (f, "pointer (0x%x) to ", type);
1709 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1710 break;
1712 case 3:
1714 unsigned long value;
1716 fprintf (f, "scalar (0x%x) of ", type);
1717 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1718 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1719 fprintf (f, " (%lu)", value);
1720 break;
1723 case 5:
1725 unsigned long lower, upper, nelem;
1726 unsigned long i;
1728 fprintf (f, "enumeration (0x%x) of ", type);
1729 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1730 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1731 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1732 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1733 fprintf (f, " from %lu to %lu with %lu elements: ", lower, upper, nelem);
1735 for (i = 0; i < nelem; i++)
1737 fprintf (f, "\n ");
1738 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1740 break;
1743 case 6:
1744 fprintf (f, "vector (0x%x)", type);
1745 fprintf (f, "\n index ");
1746 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1747 fprintf (f, "\n target ");
1748 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1749 break;
1751 case 7:
1752 case 8:
1754 long nrec, eloff, i;
1756 if ((type & 0x3f) == 7)
1757 fprintf (f, "record (0x%x) of ", type);
1758 else
1759 fprintf (f, "union (0x%x) of ", type);
1761 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1762 fprintf (f, "%lu elements: ", nrec);
1764 for (i = 0; i < nrec; i++)
1766 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1767 fprintf (f, "\n ");
1768 fprintf (f, "offset %lu: ", eloff);
1769 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1771 break;
1774 case 9:
1775 fprintf (f, "subrange (0x%x) of ", type);
1776 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1777 fprintf (f, " lower ");
1778 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1779 fprintf (f, " upper ");
1780 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1781 break;
1783 case 11:
1785 long value;
1787 fprintf (f, "named type (0x%x) ", type);
1788 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1789 if (value <= 0)
1790 fprintf (f, "[INVALID]");
1791 else
1792 fprintf (f, "\"%.*s\"",
1793 bfd_sym_symbol_name (abfd, value)[0],
1794 &bfd_sym_symbol_name (abfd, value)[1]);
1796 fprintf (f, " (NTE %lu) with type ", value);
1797 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1798 break;
1801 default:
1802 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1803 break;
1806 if (type == (0x40 | 0x6))
1808 /* Vector. */
1809 long n, width, m;
1810 long l;
1811 long i;
1813 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1814 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1815 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1816 /* fprintf (f, "\n "); */
1817 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1818 for (i = 0; i < m; i++)
1820 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1821 if (i != 0)
1822 fprintf (f, " ");
1823 fprintf (f, "%ld", l);
1826 else if (type & 0x40)
1828 /* Other packed type. */
1829 long msb, lsb;
1831 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1832 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1833 /* fprintf (f, "\n "); */
1834 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1837 fprintf (f, "]");
1839 if (offsetptr != NULL)
1840 *offsetptr = offset;
1843 void
1844 bfd_sym_print_type_information_table_entry (abfd, f, entry)
1845 bfd *abfd;
1846 FILE *f;
1847 bfd_sym_type_information_table_entry *entry;
1849 unsigned char *buf;
1850 unsigned long offset;
1851 unsigned int i;
1853 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1854 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1855 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1856 entry->nte_index,
1857 entry->physical_size, entry->offset, entry->logical_size);
1859 fprintf (f, "\n ");
1861 buf = alloca (entry->physical_size);
1862 if (buf == NULL)
1864 fprintf (f, "[ERROR]\n");
1865 return;
1867 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1869 fprintf (f, "[ERROR]\n");
1870 return;
1872 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1874 fprintf (f, "[ERROR]\n");
1875 return;
1878 fprintf (f, "[");
1879 for (i = 0; i < entry->physical_size; i++)
1881 if (i == 0)
1882 fprintf (f, "0x%02x", buf[i]);
1883 else
1884 fprintf (f, " 0x%02x", buf[i]);
1887 fprintf (f, "]");
1888 fprintf (f, "\n ");
1890 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1892 if (offset != entry->physical_size)
1893 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); }
1895 void
1896 bfd_sym_print_file_references_index_table_entry (abfd, f, entry)
1897 bfd *abfd ATTRIBUTE_UNUSED;
1898 FILE *f;
1899 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED;
1901 fprintf (f, "[UNIMPLEMENTED]");
1904 void
1905 bfd_sym_print_constant_pool_entry (abfd, f, entry)
1906 bfd *abfd ATTRIBUTE_UNUSED;
1907 FILE *f;
1908 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED;
1910 fprintf (f, "[UNIMPLEMENTED]");
1913 unsigned char *
1914 bfd_sym_display_name_table_entry (abfd, f, entry)
1915 bfd *abfd;
1916 FILE *f;
1917 unsigned char *entry;
1919 unsigned long index;
1920 unsigned long offset;
1921 bfd_sym_data_struct *sdata = NULL;
1923 BFD_ASSERT (bfd_sym_valid (abfd));
1924 sdata = abfd->tdata.sym_data;
1925 index = (entry - sdata->name_table) / 2;
1927 if ((sdata->version >= BFD_SYM_VERSION_3_4) && (entry[0] == 255) && (entry[1] == 0))
1929 unsigned short length = bfd_getb16 (entry + 2);
1930 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
1931 offset = 2 + length + 1;
1933 else
1935 if (! ((entry[0] == 0) || ((entry[0] == 1) && (entry[1] == '\0'))))
1936 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
1938 if (sdata->version >= BFD_SYM_VERSION_3_4)
1939 offset = entry[0] + 2;
1940 else
1941 offset = entry[0] + 1;
1944 return (entry + offset + (offset % 2));
1947 void
1948 bfd_sym_display_name_table (abfd, f)
1949 bfd *abfd;
1950 FILE *f;
1952 unsigned long name_table_len;
1953 unsigned char *name_table, *name_table_end, *cur;
1954 bfd_sym_data_struct *sdata = NULL;
1956 BFD_ASSERT (bfd_sym_valid (abfd));
1957 sdata = abfd->tdata.sym_data;
1959 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1960 name_table = sdata->name_table;
1961 name_table_end = name_table + name_table_len;
1963 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1965 cur = name_table;
1966 for (;;)
1968 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1969 if (cur >= name_table_end)
1970 break;
1974 void
1975 bfd_sym_display_resources_table (abfd, f)
1976 bfd *abfd;
1977 FILE *f;
1979 unsigned long i;
1980 bfd_sym_resources_table_entry entry;
1981 bfd_sym_data_struct *sdata = NULL;
1983 BFD_ASSERT (bfd_sym_valid (abfd));
1984 sdata = abfd->tdata.sym_data;
1986 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
1987 sdata->header.dshb_rte.dti_object_count);
1989 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
1991 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
1992 fprintf (f, " [%8lu] [INVALID]\n", i);
1993 else
1995 fprintf (f, " [%8lu] ", i);
1996 bfd_sym_print_resources_table_entry (abfd, f, &entry);
1997 fprintf (f, "\n");
2002 void
2003 bfd_sym_display_modules_table (abfd, f)
2004 bfd *abfd;
2005 FILE *f;
2007 unsigned long i;
2008 bfd_sym_modules_table_entry entry;
2009 bfd_sym_data_struct *sdata = NULL;
2011 BFD_ASSERT (bfd_sym_valid (abfd));
2012 sdata = abfd->tdata.sym_data;
2014 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
2015 sdata->header.dshb_mte.dti_object_count);
2017 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
2019 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
2020 fprintf (f, " [%8lu] [INVALID]\n", i);
2021 else
2023 fprintf (f, " [%8lu] ", i);
2024 bfd_sym_print_modules_table_entry (abfd, f, &entry);
2025 fprintf (f, "\n");
2030 void
2031 bfd_sym_display_file_references_table (abfd, f)
2032 bfd *abfd;
2033 FILE *f;
2035 unsigned long i;
2036 bfd_sym_file_references_table_entry entry;
2037 bfd_sym_data_struct *sdata = NULL;
2039 BFD_ASSERT (bfd_sym_valid (abfd));
2040 sdata = abfd->tdata.sym_data;
2042 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
2043 sdata->header.dshb_frte.dti_object_count);
2045 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
2047 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
2048 fprintf (f, " [%8lu] [INVALID]\n", i);
2049 else
2051 fprintf (f, " [%8lu] ", i);
2052 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
2053 fprintf (f, "\n");
2058 void
2059 bfd_sym_display_contained_modules_table (abfd, f)
2060 bfd *abfd;
2061 FILE *f;
2063 unsigned long i;
2064 bfd_sym_contained_modules_table_entry entry;
2065 bfd_sym_data_struct *sdata = NULL;
2067 BFD_ASSERT (bfd_sym_valid (abfd));
2068 sdata = abfd->tdata.sym_data;
2070 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
2071 sdata->header.dshb_cmte.dti_object_count);
2073 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2075 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
2076 fprintf (f, " [%8lu] [INVALID]\n", i);
2077 else
2079 fprintf (f, " [%8lu] ", i);
2080 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
2081 fprintf (f, "\n");
2086 void
2087 bfd_sym_display_contained_variables_table (abfd, f)
2088 bfd *abfd;
2089 FILE *f;
2091 unsigned long i;
2092 bfd_sym_contained_variables_table_entry entry;
2093 bfd_sym_data_struct *sdata = NULL;
2095 BFD_ASSERT (bfd_sym_valid (abfd));
2096 sdata = abfd->tdata.sym_data;
2098 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2099 sdata->header.dshb_cvte.dti_object_count);
2101 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2103 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2104 fprintf (f, " [%8lu] [INVALID]\n", i);
2105 else
2107 fprintf (f, " [%8lu] ", i);
2108 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2109 fprintf (f, "\n");
2113 fprintf (f, "\n");
2116 void
2117 bfd_sym_display_contained_statements_table (abfd, f)
2118 bfd *abfd;
2119 FILE *f;
2121 unsigned long i;
2122 bfd_sym_contained_statements_table_entry entry;
2123 bfd_sym_data_struct *sdata = NULL;
2125 BFD_ASSERT (bfd_sym_valid (abfd));
2126 sdata = abfd->tdata.sym_data;
2128 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
2129 sdata->header.dshb_csnte.dti_object_count);
2131 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2133 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
2134 fprintf (f, " [%8lu] [INVALID]\n", i);
2135 else
2137 fprintf (f, " [%8lu] ", i);
2138 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
2139 fprintf (f, "\n");
2144 void
2145 bfd_sym_display_contained_labels_table (abfd, f)
2146 bfd *abfd;
2147 FILE *f;
2149 unsigned long i;
2150 bfd_sym_contained_labels_table_entry entry;
2151 bfd_sym_data_struct *sdata = NULL;
2153 BFD_ASSERT (bfd_sym_valid (abfd));
2154 sdata = abfd->tdata.sym_data;
2156 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
2157 sdata->header.dshb_clte.dti_object_count);
2159 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2161 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
2162 fprintf (f, " [%8lu] [INVALID]\n", i);
2163 else
2165 fprintf (f, " [%8lu] ", i);
2166 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
2167 fprintf (f, "\n");
2172 void
2173 bfd_sym_display_contained_types_table (abfd, f)
2174 bfd *abfd;
2175 FILE *f;
2177 unsigned long i;
2178 bfd_sym_contained_types_table_entry entry;
2179 bfd_sym_data_struct *sdata = NULL;
2181 BFD_ASSERT (bfd_sym_valid (abfd));
2182 sdata = abfd->tdata.sym_data;
2184 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
2185 sdata->header.dshb_ctte.dti_object_count);
2187 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2189 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2190 fprintf (f, " [%8lu] [INVALID]\n", i);
2191 else
2193 fprintf (f, " [%8lu] ", i);
2194 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2195 fprintf (f, "\n");
2200 void
2201 bfd_sym_display_file_references_index_table (abfd, f)
2202 bfd *abfd;
2203 FILE *f;
2205 unsigned long i;
2206 bfd_sym_file_references_index_table_entry entry;
2207 bfd_sym_data_struct *sdata = NULL;
2209 BFD_ASSERT (bfd_sym_valid (abfd));
2210 sdata = abfd->tdata.sym_data;
2212 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
2213 sdata->header.dshb_fite.dti_object_count);
2215 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2217 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2218 fprintf (f, " [%8lu] [INVALID]\n", i);
2219 else
2221 fprintf (f, " [%8lu] ", i);
2222 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2223 fprintf (f, "\n");
2228 void
2229 bfd_sym_display_constant_pool (abfd, f)
2230 bfd *abfd;
2231 FILE *f;
2233 unsigned long i;
2234 bfd_sym_constant_pool_entry entry;
2235 bfd_sym_data_struct *sdata = NULL;
2237 BFD_ASSERT (bfd_sym_valid (abfd));
2238 sdata = abfd->tdata.sym_data;
2240 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2241 sdata->header.dshb_const.dti_object_count);
2243 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2245 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2246 fprintf (f, " [%8lu] [INVALID]\n", i);
2247 else
2249 fprintf (f, " [%8lu] ", i);
2250 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2251 fprintf (f, "\n");
2256 void
2257 bfd_sym_display_type_information_table (abfd, f)
2258 bfd *abfd;
2259 FILE *f;
2261 unsigned long i;
2262 bfd_sym_type_table_entry index;
2263 bfd_sym_type_information_table_entry entry;
2264 bfd_sym_data_struct *sdata = NULL;
2266 BFD_ASSERT (bfd_sym_valid (abfd));
2267 sdata = abfd->tdata.sym_data;
2269 if (sdata->header.dshb_tte.dti_object_count > 99)
2270 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2271 sdata->header.dshb_tte.dti_object_count - 99);
2272 else
2274 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2275 return;
2278 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2280 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
2281 fprintf (f, " [%8lu] [INVALID]\n", i);
2282 else
2284 fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
2286 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
2287 fprintf (f, "[INVALID]");
2288 else
2289 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2291 fprintf (f, "\n");
2296 const bfd_target *
2297 bfd_sym_object_p (abfd)
2298 bfd *abfd;
2300 bfd_sym_data_struct *mdata = NULL;
2301 asection *bfdsec;
2302 const char *name = "symbols";
2304 mdata = ((bfd_sym_data_struct *)
2305 bfd_alloc (abfd, sizeof (bfd_sym_data_struct)));
2306 if (mdata == NULL)
2307 return NULL;
2309 abfd->tdata.sym_data = mdata;
2311 mdata->name_table = 0;
2312 mdata->sbfd = abfd;
2314 bfd_seek (abfd, 0, SEEK_SET);
2315 if (bfd_sym_read_version (abfd, &mdata->version) != 0)
2317 abfd->tdata.sym_data = NULL;
2318 bfd_set_error (bfd_error_wrong_format);
2319 return NULL;
2322 bfd_seek (abfd, 0, SEEK_SET);
2323 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2325 abfd->tdata.sym_data = NULL;
2326 bfd_set_error (bfd_error_wrong_format);
2327 return NULL;
2330 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2331 if (mdata->name_table == NULL)
2333 abfd->tdata.sym_data = NULL;
2334 bfd_set_error (bfd_error_wrong_format);
2335 return NULL;
2338 bfdsec = bfd_make_section_anyway (abfd, name);
2339 if (bfdsec == NULL)
2341 abfd->tdata.sym_data = NULL;
2342 bfd_set_error (bfd_error_wrong_format);
2343 return NULL;
2346 bfdsec->vma = 0;
2347 bfdsec->lma = 0;
2348 bfdsec->_raw_size = 0;
2349 bfdsec->filepos = 0;
2350 bfdsec->alignment_power = 0;
2352 bfdsec->flags = SEC_HAS_CONTENTS;
2354 return abfd->xvec;
2357 asymbol *
2358 bfd_sym_make_empty_symbol (abfd)
2359 bfd *abfd;
2361 return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
2364 void
2365 bfd_sym_get_symbol_info (abfd, symbol, ret)
2366 bfd *abfd ATTRIBUTE_UNUSED;
2367 asymbol *symbol;
2368 symbol_info *ret;
2370 bfd_symbol_info (symbol, ret);
2373 long
2374 bfd_sym_get_symtab_upper_bound (abfd)
2375 bfd *abfd ATTRIBUTE_UNUSED;
2377 return 0;
2380 long
2381 bfd_sym_get_symtab (abfd, sym)
2382 bfd *abfd ATTRIBUTE_UNUSED;
2383 asymbol **sym ATTRIBUTE_UNUSED;
2385 return 0;
2389 bfd_sym_sizeof_headers (abfd, exec)
2390 bfd *abfd ATTRIBUTE_UNUSED;
2391 boolean exec ATTRIBUTE_UNUSED;
2393 return 0;
2396 const bfd_target sym_vec =
2398 "sym", /* name */
2399 bfd_target_sym_flavour, /* flavour */
2400 BFD_ENDIAN_BIG, /* byteorder */
2401 BFD_ENDIAN_BIG, /* header_byteorder */
2402 (HAS_RELOC | EXEC_P | /* object flags */
2403 HAS_LINENO | HAS_DEBUG |
2404 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2405 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2406 | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
2407 0, /* symbol_leading_char */
2408 ' ', /* ar_pad_char */
2409 16, /* ar_max_namelen */
2410 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2411 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2412 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
2413 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2414 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2415 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
2416 { /* bfd_check_format */
2417 _bfd_dummy_target,
2418 bfd_sym_object_p, /* bfd_check_format */
2419 _bfd_dummy_target,
2420 _bfd_dummy_target,
2422 { /* bfd_set_format */
2423 bfd_false,
2424 bfd_sym_mkobject,
2425 bfd_false,
2426 bfd_false,
2428 { /* bfd_write_contents */
2429 bfd_false,
2430 bfd_true,
2431 bfd_false,
2432 bfd_false,
2435 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2436 BFD_JUMP_TABLE_COPY (_bfd_generic),
2437 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2438 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2439 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2440 BFD_JUMP_TABLE_RELOCS (bfd_sym),
2441 BFD_JUMP_TABLE_WRITE (bfd_sym),
2442 BFD_JUMP_TABLE_LINK (bfd_sym),
2443 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2445 NULL,
2447 NULL