Undo previous delta
[binutils.git] / bfd / xsym.c
blob6b80dcf4094643a0903d2f2ab5dff07c23604f0b
1 /* xSYM symbol-file support for BFD.
2 Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005
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_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
31 #define bfd_sym_get_lineno _bfd_nosymbols_get_lineno
32 #define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line
33 #define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
34 #define bfd_sym_read_minisymbols _bfd_generic_read_minisymbols
35 #define bfd_sym_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
36 #define bfd_sym_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
37 #define bfd_sym_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
38 #define bfd_sym_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
39 #define bfd_sym_set_arch_mach _bfd_generic_set_arch_mach
40 #define bfd_sym_get_section_contents _bfd_generic_get_section_contents
41 #define bfd_sym_set_section_contents _bfd_generic_set_section_contents
42 #define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
43 #define bfd_sym_bfd_relax_section bfd_generic_relax_section
44 #define bfd_sym_bfd_gc_sections bfd_generic_gc_sections
45 #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections
46 #define bfd_sym_bfd_is_group_section bfd_generic_is_group_section
47 #define bfd_sym_bfd_discard_group bfd_generic_discard_group
48 #define bfd_sym_section_already_linked \
49 _bfd_generic_section_already_linked
50 #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
51 #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
52 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
53 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
54 #define bfd_sym_bfd_final_link _bfd_generic_final_link
55 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
56 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
58 static unsigned long compute_offset
59 PARAMS ((unsigned long, unsigned long, unsigned long, unsigned long));
61 extern const bfd_target sym_vec;
63 static int
64 pstrcmp (const char *as, const char *bs)
66 const unsigned char *a = (const unsigned char *) as;
67 const unsigned char *b = (const unsigned char *) bs;
68 unsigned char clen;
69 int ret;
71 clen = (a[0] > b[0]) ? b[0] : a[0];
72 ret = memcmp (a + 1, b + 1, clen);
73 if (ret != 0)
74 return ret;
76 if (a[0] == b[0])
77 return 0;
78 else if (a[0] < b[0])
79 return -1;
80 else
81 return 1;
84 static unsigned long
85 compute_offset (first_page, page_size, entry_size, index)
86 unsigned long first_page;
87 unsigned long page_size;
88 unsigned long entry_size;
89 unsigned long index;
91 unsigned long entries_per_page = page_size / entry_size;
92 unsigned long page_number = first_page + (index / entries_per_page);
93 unsigned long page_offset = (index % entries_per_page) * entry_size;
95 return (page_number * page_size) + page_offset;
98 bfd_boolean
99 bfd_sym_mkobject (abfd)
100 bfd *abfd ATTRIBUTE_UNUSED;
102 return 1;
105 void
106 bfd_sym_print_symbol (abfd, afile, symbol, how)
107 bfd *abfd ATTRIBUTE_UNUSED;
108 PTR afile ATTRIBUTE_UNUSED;
109 asymbol *symbol ATTRIBUTE_UNUSED;
110 bfd_print_symbol_type how ATTRIBUTE_UNUSED;
112 return;
115 bfd_boolean
116 bfd_sym_valid (abfd)
117 bfd *abfd;
119 if (abfd == NULL || abfd->xvec == NULL)
120 return 0;
122 return abfd->xvec == &sym_vec;
125 unsigned char *
126 bfd_sym_read_name_table (abfd, dshb)
127 bfd *abfd;
128 bfd_sym_header_block *dshb;
130 unsigned char *rstr;
131 long ret;
132 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
133 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
135 rstr = (unsigned char *) bfd_alloc (abfd, table_size);
136 if (rstr == NULL)
137 return rstr;
139 bfd_seek (abfd, table_offset, SEEK_SET);
140 ret = bfd_bread (rstr, table_size, abfd);
141 if (ret < 0 || (unsigned long) ret != table_size)
143 bfd_release (abfd, rstr);
144 return NULL;
147 return rstr;
150 void
151 bfd_sym_parse_file_reference_v32 (buf, len, entry)
152 unsigned char *buf;
153 size_t len;
154 bfd_sym_file_reference *entry;
156 BFD_ASSERT (len == 6);
158 entry->fref_frte_index = bfd_getb16 (buf);
159 entry->fref_offset = bfd_getb32 (buf + 2);
162 void
163 bfd_sym_parse_disk_table_v32 (buf, len, table)
164 unsigned char *buf;
165 size_t len;
166 bfd_sym_table_info *table;
168 BFD_ASSERT (len == 8);
170 table->dti_first_page = bfd_getb16 (buf);
171 table->dti_page_count = bfd_getb16 (buf + 2);
172 table->dti_object_count = bfd_getb32 (buf + 4);
175 void
176 bfd_sym_parse_header_v32 (buf, len, header)
177 unsigned char *buf;
178 size_t len;
179 bfd_sym_header_block *header;
181 BFD_ASSERT (len == 154);
183 memcpy (header->dshb_id, buf, 32);
184 header->dshb_page_size = bfd_getb16 (buf + 32);
185 header->dshb_hash_page = bfd_getb16 (buf + 34);
186 header->dshb_root_mte = bfd_getb16 (buf + 36);
187 header->dshb_mod_date = bfd_getb32 (buf + 38);
189 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
190 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
191 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
192 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
193 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
194 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
195 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
196 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
197 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
198 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
199 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
200 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
201 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
203 memcpy (&header->dshb_file_creator, buf + 146, 4);
204 memcpy (&header->dshb_file_type, buf + 150, 4);
208 bfd_sym_read_header_v32 (abfd, header)
209 bfd *abfd;
210 bfd_sym_header_block *header;
212 unsigned char buf[154];
213 long ret;
215 ret = bfd_bread (buf, 154, abfd);
216 if (ret != 154)
217 return -1;
219 bfd_sym_parse_header_v32 (buf, 154, header);
221 return 0;
225 bfd_sym_read_header_v34 (abfd, header)
226 bfd *abfd ATTRIBUTE_UNUSED;
227 bfd_sym_header_block *header ATTRIBUTE_UNUSED;
229 abort ();
233 bfd_sym_read_header (abfd, header, version)
234 bfd *abfd;
235 bfd_sym_header_block *header;
236 bfd_sym_version version;
238 switch (version)
240 case BFD_SYM_VERSION_3_5:
241 case BFD_SYM_VERSION_3_4:
242 return bfd_sym_read_header_v34 (abfd, header);
243 case BFD_SYM_VERSION_3_3:
244 case BFD_SYM_VERSION_3_2:
245 return bfd_sym_read_header_v32 (abfd, header);
246 case BFD_SYM_VERSION_3_1:
247 default:
248 return FALSE;
253 bfd_sym_read_version (abfd, version)
254 bfd *abfd;
255 bfd_sym_version *version;
257 char version_string[32];
258 long ret;
260 ret = bfd_bread (version_string, sizeof (version_string), abfd);
261 if (ret != sizeof (version_string))
262 return -1;
264 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
265 *version = BFD_SYM_VERSION_3_1;
266 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
267 *version = BFD_SYM_VERSION_3_2;
268 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
269 *version = BFD_SYM_VERSION_3_3;
270 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
271 *version = BFD_SYM_VERSION_3_4;
272 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
273 *version = BFD_SYM_VERSION_3_5;
274 else
275 return -1;
277 return 0;
280 void
281 bfd_sym_display_table_summary (f, dti, name)
282 FILE *f;
283 bfd_sym_table_info *dti;
284 const char *name;
286 fprintf (f, "%-6s %13ld %13ld %13ld\n",
287 name,
288 dti->dti_first_page,
289 dti->dti_page_count,
290 dti->dti_object_count);
293 void
294 bfd_sym_display_header (f, dshb)
295 FILE *f;
296 bfd_sym_header_block *dshb;
298 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
299 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
300 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
301 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
302 fprintf (f, " Modification Date: ");
303 fprintf (f, "[unimplemented]");
304 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
306 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
307 dshb->dshb_file_creator, dshb->dshb_file_type);
309 fprintf (f, "Table Name First Page Page Count Object Count\n");
310 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
312 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
313 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
314 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
315 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
316 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
317 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
318 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
319 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
320 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
321 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
322 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
323 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
324 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
326 fprintf (f, "\n");
329 void
330 bfd_sym_parse_resources_table_entry_v32 (buf, len, entry)
331 unsigned char *buf;
332 size_t len;
333 bfd_sym_resources_table_entry *entry;
335 BFD_ASSERT (len == 18);
337 memcpy (&entry->rte_res_type, buf, 4);
338 entry->rte_res_number = bfd_getb16 (buf + 4);
339 entry->rte_nte_index = bfd_getb32 (buf + 6);
340 entry->rte_mte_first = bfd_getb16 (buf + 10);
341 entry->rte_mte_last = bfd_getb16 (buf + 12);
342 entry->rte_res_size = bfd_getb32 (buf + 14);
345 void
346 bfd_sym_parse_modules_table_entry_v33 (buf, len, entry)
347 unsigned char *buf;
348 size_t len;
349 bfd_sym_modules_table_entry *entry;
351 BFD_ASSERT (len == 46);
353 entry->mte_rte_index = bfd_getb16 (buf);
354 entry->mte_res_offset = bfd_getb32 (buf + 2);
355 entry->mte_size = bfd_getb32 (buf + 6);
356 entry->mte_kind = buf[10];
357 entry->mte_scope = buf[11];
358 entry->mte_parent = bfd_getb16 (buf + 12);
359 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
360 entry->mte_imp_end = bfd_getb32 (buf + 20);
361 entry->mte_nte_index = bfd_getb32 (buf + 24);
362 entry->mte_cmte_index = bfd_getb16 (buf + 28);
363 entry->mte_cvte_index = bfd_getb32 (buf + 30);
364 entry->mte_clte_index = bfd_getb16 (buf + 34);
365 entry->mte_ctte_index = bfd_getb16 (buf + 36);
366 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
367 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
370 void
371 bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry)
372 unsigned char *buf;
373 size_t len;
374 bfd_sym_file_references_table_entry *entry;
376 unsigned int type;
378 BFD_ASSERT (len == 10);
380 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
381 type = bfd_getb16 (buf);
383 switch (type)
385 case BFD_SYM_END_OF_LIST_3_2:
386 entry->generic.type = BFD_SYM_END_OF_LIST;
387 break;
389 case BFD_SYM_FILE_NAME_INDEX_3_2:
390 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
391 entry->filename.nte_index = bfd_getb32 (buf + 2);
392 entry->filename.mod_date = bfd_getb32 (buf + 6);
393 break;
395 default:
396 entry->entry.mte_index = type;
397 entry->entry.file_offset = bfd_getb32 (buf + 2);
401 void
402 bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry)
403 unsigned char *buf;
404 size_t len;
405 bfd_sym_contained_modules_table_entry *entry;
407 unsigned int type;
409 BFD_ASSERT (len == 6);
411 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
412 type = bfd_getb16 (buf);
414 switch (type)
416 case BFD_SYM_END_OF_LIST_3_2:
417 entry->generic.type = BFD_SYM_END_OF_LIST;
418 break;
420 default:
421 entry->entry.mte_index = type;
422 entry->entry.nte_index = bfd_getb32 (buf + 2);
423 break;
427 void
428 bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry)
429 unsigned char *buf;
430 size_t len;
431 bfd_sym_contained_variables_table_entry *entry;
433 unsigned int type;
435 BFD_ASSERT (len == 26);
437 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
438 type = bfd_getb16 (buf);
440 switch (type)
442 case BFD_SYM_END_OF_LIST_3_2:
443 entry->generic.type = BFD_SYM_END_OF_LIST;
444 break;
446 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
447 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
448 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
449 break;
451 default:
452 entry->entry.tte_index = type;
453 entry->entry.nte_index = bfd_getb32 (buf + 2);
454 entry->entry.file_delta = bfd_getb16 (buf + 6);
455 entry->entry.scope = buf[8];
456 entry->entry.la_size = buf[9];
458 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
460 entry->entry.address.scstruct.sca_kind = buf[10];
461 entry->entry.address.scstruct.sca_class = buf[11];
462 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
464 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
466 #if BFD_SYM_CVTE_SCA > 0
467 memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA);
468 #endif
469 entry->entry.address.lastruct.la_kind = buf[23];
471 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
473 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
474 entry->entry.address.biglastruct.big_la_kind = buf[12];
479 void
480 bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
481 unsigned char *buf;
482 size_t len;
483 bfd_sym_contained_statements_table_entry *entry;
485 unsigned int type;
487 BFD_ASSERT (len == 8);
489 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
490 type = bfd_getb16 (buf);
492 switch (type)
494 case BFD_SYM_END_OF_LIST_3_2:
495 entry->generic.type = BFD_SYM_END_OF_LIST;
496 break;
498 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
499 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
500 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
501 break;
503 default:
504 entry->entry.mte_index = type;
505 entry->entry.mte_offset = bfd_getb16 (buf + 2);
506 entry->entry.file_delta = bfd_getb32 (buf + 4);
507 break;
511 void
512 bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
513 unsigned char *buf;
514 size_t len;
515 bfd_sym_contained_labels_table_entry *entry;
517 unsigned int type;
519 BFD_ASSERT (len == 12);
521 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
522 type = bfd_getb16 (buf);
524 switch (type)
526 case BFD_SYM_END_OF_LIST_3_2:
527 entry->generic.type = BFD_SYM_END_OF_LIST;
528 break;
530 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
531 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
532 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
533 break;
535 default:
536 entry->entry.mte_index = type;
537 entry->entry.mte_offset = bfd_getb16 (buf + 2);
538 entry->entry.nte_index = bfd_getb32 (buf + 4);
539 entry->entry.file_delta = bfd_getb16 (buf + 8);
540 entry->entry.scope = bfd_getb16 (buf + 10);
541 break;
545 void
546 bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
547 unsigned char *buf;
548 size_t len;
549 bfd_sym_type_table_entry *entry;
551 BFD_ASSERT (len == 4);
553 *entry = bfd_getb32 (buf);
557 bfd_sym_fetch_resources_table_entry (abfd, entry, index)
558 bfd *abfd;
559 bfd_sym_resources_table_entry *entry;
560 unsigned long index;
562 void (*parser) PARAMS ((unsigned char *, size_t,
563 bfd_sym_resources_table_entry *));
564 unsigned long offset;
565 unsigned long entry_size;
566 unsigned char buf[18];
567 bfd_sym_data_struct *sdata = NULL;
569 parser = NULL;
570 BFD_ASSERT (bfd_sym_valid (abfd));
571 sdata = abfd->tdata.sym_data;
573 if (index == 0)
574 return -1;
576 switch (sdata->version)
578 case BFD_SYM_VERSION_3_5:
579 case BFD_SYM_VERSION_3_4:
580 return -1;
582 case BFD_SYM_VERSION_3_3:
583 case BFD_SYM_VERSION_3_2:
584 entry_size = 18;
585 parser = bfd_sym_parse_resources_table_entry_v32;
586 break;
588 case BFD_SYM_VERSION_3_1:
589 default:
590 return -1;
592 if (parser == NULL)
593 return -1;
595 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
596 sdata->header.dshb_page_size,
597 entry_size, index);
599 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
600 return -1;
601 if (bfd_bread (buf, entry_size, abfd) != entry_size)
602 return -1;
604 (*parser) (buf, entry_size, entry);
606 return 0;
610 bfd_sym_fetch_modules_table_entry (abfd, entry, index)
611 bfd *abfd;
612 bfd_sym_modules_table_entry *entry;
613 unsigned long index;
615 void (*parser) PARAMS ((unsigned char *, size_t,
616 bfd_sym_modules_table_entry *));
617 unsigned long offset;
618 unsigned long entry_size;
619 unsigned char buf[46];
620 bfd_sym_data_struct *sdata = NULL;
622 parser = NULL;
623 BFD_ASSERT (bfd_sym_valid (abfd));
624 sdata = abfd->tdata.sym_data;
626 if (index == 0)
627 return -1;
629 switch (sdata->version)
631 case BFD_SYM_VERSION_3_5:
632 case BFD_SYM_VERSION_3_4:
633 return -1;
635 case BFD_SYM_VERSION_3_3:
636 entry_size = 46;
637 parser = bfd_sym_parse_modules_table_entry_v33;
638 break;
640 case BFD_SYM_VERSION_3_2:
641 case BFD_SYM_VERSION_3_1:
642 default:
643 return -1;
645 if (parser == NULL)
646 return -1;
648 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
649 sdata->header.dshb_page_size,
650 entry_size, index);
652 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
653 return -1;
654 if (bfd_bread (buf, entry_size, abfd) != entry_size)
655 return -1;
657 (*parser) (buf, entry_size, entry);
659 return 0;
663 bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
664 bfd *abfd;
665 bfd_sym_file_references_table_entry *entry;
666 unsigned long index;
668 void (*parser) PARAMS ((unsigned char *, size_t,
669 bfd_sym_file_references_table_entry *));
670 unsigned long offset;
671 unsigned long entry_size = 0;
672 unsigned char buf[8];
673 bfd_sym_data_struct *sdata = NULL;
675 parser = NULL;
676 BFD_ASSERT (bfd_sym_valid (abfd));
677 sdata = abfd->tdata.sym_data;
679 if (index == 0)
680 return -1;
682 switch (sdata->version)
684 case BFD_SYM_VERSION_3_3:
685 case BFD_SYM_VERSION_3_2:
686 entry_size = 10;
687 parser = bfd_sym_parse_file_references_table_entry_v32;
688 break;
690 case BFD_SYM_VERSION_3_5:
691 case BFD_SYM_VERSION_3_4:
692 case BFD_SYM_VERSION_3_1:
693 default:
694 break;
697 if (parser == NULL)
698 return -1;
700 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
701 sdata->header.dshb_page_size,
702 entry_size, index);
704 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
705 return -1;
706 if (bfd_bread (buf, entry_size, abfd) != entry_size)
707 return -1;
709 (*parser) (buf, entry_size, entry);
711 return 0;
715 bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
716 bfd *abfd;
717 bfd_sym_contained_modules_table_entry *entry;
718 unsigned long index;
720 void (*parser) PARAMS ((unsigned char *, size_t,
721 bfd_sym_contained_modules_table_entry *));
722 unsigned long offset;
723 unsigned long entry_size = 0;
724 unsigned char buf[6];
725 bfd_sym_data_struct *sdata = NULL;
727 parser = NULL;
728 BFD_ASSERT (bfd_sym_valid (abfd));
729 sdata = abfd->tdata.sym_data;
731 if (index == 0)
732 return -1;
734 switch (sdata->version)
736 case BFD_SYM_VERSION_3_3:
737 case BFD_SYM_VERSION_3_2:
738 entry_size = 6;
739 parser = bfd_sym_parse_contained_modules_table_entry_v32;
740 break;
742 case BFD_SYM_VERSION_3_5:
743 case BFD_SYM_VERSION_3_4:
744 case BFD_SYM_VERSION_3_1:
745 default:
746 break;
749 if (parser == NULL)
750 return -1;
752 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
753 sdata->header.dshb_page_size,
754 entry_size, index);
756 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
757 return -1;
758 if (bfd_bread (buf, entry_size, abfd) != entry_size)
759 return -1;
761 (*parser) (buf, entry_size, entry);
763 return 0;
767 bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
768 bfd *abfd;
769 bfd_sym_contained_variables_table_entry *entry;
770 unsigned long index;
772 void (*parser) PARAMS ((unsigned char *, size_t,
773 bfd_sym_contained_variables_table_entry *));
774 unsigned long offset;
775 unsigned long entry_size = 0;
776 unsigned char buf[26];
777 bfd_sym_data_struct *sdata = NULL;
779 parser = NULL;
780 BFD_ASSERT (bfd_sym_valid (abfd));
781 sdata = abfd->tdata.sym_data;
783 if (index == 0)
784 return -1;
786 switch (sdata->version)
788 case BFD_SYM_VERSION_3_3:
789 case BFD_SYM_VERSION_3_2:
790 entry_size = 26;
791 parser = bfd_sym_parse_contained_variables_table_entry_v32;
792 break;
794 case BFD_SYM_VERSION_3_5:
795 case BFD_SYM_VERSION_3_4:
796 case BFD_SYM_VERSION_3_1:
797 default:
798 break;
801 if (parser == NULL)
802 return -1;
804 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
805 sdata->header.dshb_page_size,
806 entry_size, index);
808 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
809 return -1;
810 if (bfd_bread (buf, entry_size, abfd) != entry_size)
811 return -1;
813 (*parser) (buf, entry_size, entry);
815 return 0;
819 bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
820 bfd *abfd;
821 bfd_sym_contained_statements_table_entry *entry;
822 unsigned long index;
824 void (*parser) PARAMS ((unsigned char *, size_t,
825 bfd_sym_contained_statements_table_entry *));
826 unsigned long offset;
827 unsigned long entry_size = 0;
828 unsigned char buf[8];
829 bfd_sym_data_struct *sdata = NULL;
831 parser = NULL;
832 BFD_ASSERT (bfd_sym_valid (abfd));
833 sdata = abfd->tdata.sym_data;
835 if (index == 0)
836 return -1;
838 switch (sdata->version)
840 case BFD_SYM_VERSION_3_3:
841 case BFD_SYM_VERSION_3_2:
842 entry_size = 8;
843 parser = bfd_sym_parse_contained_statements_table_entry_v32;
844 break;
846 case BFD_SYM_VERSION_3_5:
847 case BFD_SYM_VERSION_3_4:
848 case BFD_SYM_VERSION_3_1:
849 default:
850 break;
853 if (parser == NULL)
854 return -1;
856 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
857 sdata->header.dshb_page_size,
858 entry_size, index);
860 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
861 return -1;
862 if (bfd_bread (buf, entry_size, abfd) != entry_size)
863 return -1;
865 (*parser) (buf, entry_size, entry);
867 return 0;
871 bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
872 bfd *abfd;
873 bfd_sym_contained_labels_table_entry *entry;
874 unsigned long index;
876 void (*parser) PARAMS ((unsigned char *, size_t,
877 bfd_sym_contained_labels_table_entry *));
878 unsigned long offset;
879 unsigned long entry_size = 0;
880 unsigned char buf[12];
881 bfd_sym_data_struct *sdata = NULL;
883 parser = NULL;
884 BFD_ASSERT (bfd_sym_valid (abfd));
885 sdata = abfd->tdata.sym_data;
887 if (index == 0)
888 return -1;
890 switch (sdata->version)
892 case BFD_SYM_VERSION_3_3:
893 case BFD_SYM_VERSION_3_2:
894 entry_size = 12;
895 parser = bfd_sym_parse_contained_labels_table_entry_v32;
896 break;
898 case BFD_SYM_VERSION_3_5:
899 case BFD_SYM_VERSION_3_4:
900 case BFD_SYM_VERSION_3_1:
901 default:
902 break;
905 if (parser == NULL)
906 return -1;
908 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
909 sdata->header.dshb_page_size,
910 entry_size, index);
912 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
913 return -1;
914 if (bfd_bread (buf, entry_size, abfd) != entry_size)
915 return -1;
917 (*parser) (buf, entry_size, entry);
919 return 0;
923 bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
924 bfd *abfd;
925 bfd_sym_contained_types_table_entry *entry;
926 unsigned long index;
928 void (*parser) PARAMS ((unsigned char *, size_t,
929 bfd_sym_contained_types_table_entry *));
930 unsigned long offset;
931 unsigned long entry_size = 0;
932 unsigned char buf[0];
933 bfd_sym_data_struct *sdata = NULL;
935 parser = NULL;
936 BFD_ASSERT (bfd_sym_valid (abfd));
937 sdata = abfd->tdata.sym_data;
939 if (index == 0)
940 return -1;
942 switch (sdata->version)
944 case BFD_SYM_VERSION_3_3:
945 case BFD_SYM_VERSION_3_2:
946 entry_size = 0;
947 parser = NULL;
948 break;
950 case BFD_SYM_VERSION_3_5:
951 case BFD_SYM_VERSION_3_4:
952 case BFD_SYM_VERSION_3_1:
953 default:
954 break;
957 if (parser == NULL)
958 return -1;
960 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
961 sdata->header.dshb_page_size,
962 entry_size, index);
964 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
965 return -1;
966 if (bfd_bread (buf, entry_size, abfd) != entry_size)
967 return -1;
969 (*parser) (buf, entry_size, entry);
971 return 0;
975 bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
976 bfd *abfd;
977 bfd_sym_file_references_index_table_entry *entry;
978 unsigned long index;
980 void (*parser) PARAMS ((unsigned char *, size_t,
981 bfd_sym_file_references_index_table_entry *));
982 unsigned long offset;
983 unsigned long entry_size = 0;
984 unsigned char buf[0];
985 bfd_sym_data_struct *sdata = NULL;
987 parser = NULL;
988 BFD_ASSERT (bfd_sym_valid (abfd));
989 sdata = abfd->tdata.sym_data;
991 if (index == 0)
992 return -1;
994 switch (sdata->version)
996 case BFD_SYM_VERSION_3_3:
997 case BFD_SYM_VERSION_3_2:
998 entry_size = 0;
999 parser = NULL;
1000 break;
1002 case BFD_SYM_VERSION_3_5:
1003 case BFD_SYM_VERSION_3_4:
1004 case BFD_SYM_VERSION_3_1:
1005 default:
1006 break;
1009 if (parser == NULL)
1010 return -1;
1012 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1013 sdata->header.dshb_page_size,
1014 entry_size, index);
1016 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1017 return -1;
1018 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1019 return -1;
1021 (*parser) (buf, entry_size, entry);
1023 return 0;
1027 bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
1028 bfd *abfd;
1029 bfd_sym_constant_pool_entry *entry;
1030 unsigned long index;
1032 void (*parser) PARAMS ((unsigned char *, size_t,
1033 bfd_sym_constant_pool_entry *));
1034 unsigned long offset;
1035 unsigned long entry_size = 0;
1036 unsigned char buf[0];
1037 bfd_sym_data_struct *sdata = NULL;
1039 parser = NULL;
1040 BFD_ASSERT (bfd_sym_valid (abfd));
1041 sdata = abfd->tdata.sym_data;
1043 if (index == 0)
1044 return -1;
1046 switch (sdata->version)
1048 case BFD_SYM_VERSION_3_3:
1049 case BFD_SYM_VERSION_3_2:
1050 entry_size = 0;
1051 parser = NULL;
1052 break;
1054 case BFD_SYM_VERSION_3_5:
1055 case BFD_SYM_VERSION_3_4:
1056 case BFD_SYM_VERSION_3_1:
1057 default:
1058 break;
1061 if (parser == NULL)
1062 return -1;
1064 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1065 sdata->header.dshb_page_size,
1066 entry_size, index);
1068 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1069 return -1;
1070 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1071 return -1;
1073 (*parser) (buf, entry_size, entry);
1075 return 0;
1079 bfd_sym_fetch_type_table_entry (abfd, entry, index)
1080 bfd *abfd;
1081 bfd_sym_type_table_entry *entry;
1082 unsigned long index;
1084 void (*parser) PARAMS ((unsigned char *, size_t,
1085 bfd_sym_type_table_entry *));
1086 unsigned long offset;
1087 unsigned long entry_size = 0;
1088 unsigned char buf[4];
1089 bfd_sym_data_struct *sdata = NULL;
1091 parser = NULL;
1092 BFD_ASSERT (bfd_sym_valid (abfd));
1093 sdata = abfd->tdata.sym_data;
1095 switch (sdata->version)
1097 case BFD_SYM_VERSION_3_3:
1098 case BFD_SYM_VERSION_3_2:
1099 entry_size = 4;
1100 parser = bfd_sym_parse_type_table_entry_v32;
1101 break;
1103 case BFD_SYM_VERSION_3_5:
1104 case BFD_SYM_VERSION_3_4:
1105 case BFD_SYM_VERSION_3_1:
1106 default:
1107 break;
1110 if (parser == NULL)
1111 return -1;
1113 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1114 sdata->header.dshb_page_size,
1115 entry_size, index);
1117 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1118 return -1;
1119 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1120 return -1;
1122 (*parser) (buf, entry_size, entry);
1124 return 0;
1128 bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
1129 bfd *abfd;
1130 bfd_sym_type_information_table_entry *entry;
1131 unsigned long offset;
1133 unsigned char buf[4];
1134 bfd_sym_data_struct *sdata = NULL;
1136 BFD_ASSERT (bfd_sym_valid (abfd));
1137 sdata = abfd->tdata.sym_data;
1139 if (offset == 0)
1140 return -1;
1142 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1143 return -1;
1145 if (bfd_bread (buf, 4, abfd) != 4)
1146 return -1;
1147 entry->nte_index = bfd_getb32 (buf);
1149 if (bfd_bread (buf, 2, abfd) != 2)
1150 return -1;
1151 entry->physical_size = bfd_getb16 (buf);
1153 if (entry->physical_size & 0x8000)
1155 if (bfd_bread (buf, 4, abfd) != 4)
1156 return -1;
1157 entry->physical_size &= 0x7fff;
1158 entry->logical_size = bfd_getb32 (buf);
1159 entry->offset = offset + 10;
1161 else
1163 if (bfd_bread (buf, 2, abfd) != 2)
1164 return -1;
1165 entry->physical_size &= 0x7fff;
1166 entry->logical_size = bfd_getb16 (buf);
1167 entry->offset = offset + 8;
1170 return 0;
1174 bfd_sym_fetch_type_table_information (abfd, entry, index)
1175 bfd *abfd;
1176 bfd_sym_type_information_table_entry *entry;
1177 unsigned long index;
1179 bfd_sym_type_table_entry tindex;
1180 bfd_sym_data_struct *sdata = NULL;
1182 BFD_ASSERT (bfd_sym_valid (abfd));
1183 sdata = abfd->tdata.sym_data;
1185 if (sdata->header.dshb_tte.dti_object_count <= 99)
1186 return -1;
1187 if (index < 100)
1188 return -1;
1190 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
1191 return -1;
1192 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1193 return -1;
1195 return 0;
1198 const unsigned char *
1199 bfd_sym_symbol_name (abfd, index)
1200 bfd *abfd;
1201 unsigned long index;
1203 bfd_sym_data_struct *sdata = NULL;
1205 BFD_ASSERT (bfd_sym_valid (abfd));
1206 sdata = abfd->tdata.sym_data;
1208 if (index == 0)
1209 return (const unsigned char *) "";
1211 index *= 2;
1212 if ((index / sdata->header.dshb_page_size)
1213 > sdata->header.dshb_nte.dti_page_count)
1214 return (const unsigned char *) "\09[INVALID]";
1216 return (const unsigned char *) sdata->name_table + index;
1219 const unsigned char *
1220 bfd_sym_module_name (abfd, index)
1221 bfd *abfd;
1222 unsigned long index;
1224 bfd_sym_modules_table_entry entry;
1226 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
1227 return (const unsigned char *) "\09[INVALID]";
1229 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1232 const char *
1233 bfd_sym_unparse_storage_kind (kind)
1234 enum bfd_sym_storage_kind kind;
1236 switch (kind)
1238 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1239 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1240 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1241 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1242 default: return "[UNKNOWN]";
1246 const char *
1247 bfd_sym_unparse_storage_class (kind)
1248 enum bfd_sym_storage_class kind;
1250 switch (kind)
1252 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1253 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1254 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1255 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1256 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1257 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1258 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1259 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1260 default: return "[UNKNOWN]";
1264 const char *
1265 bfd_sym_unparse_module_kind (kind)
1266 enum bfd_sym_module_kind kind;
1268 switch (kind)
1270 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1271 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1272 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1273 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1274 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1275 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1276 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1277 default: return "[UNKNOWN]";
1281 const char *
1282 bfd_sym_unparse_symbol_scope (scope)
1283 enum bfd_sym_symbol_scope scope;
1285 switch (scope)
1287 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1288 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1289 default:
1290 return "[UNKNOWN]";
1294 void
1295 bfd_sym_print_file_reference (abfd, f, entry)
1296 bfd *abfd;
1297 FILE *f;
1298 bfd_sym_file_reference *entry;
1300 bfd_sym_file_references_table_entry frtentry;
1301 int ret;
1303 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1304 entry->fref_frte_index);
1305 fprintf (f, "FILE ");
1307 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1308 fprintf (f, "[INVALID]");
1309 else
1310 fprintf (f, "\"%.*s\"",
1311 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1312 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1314 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1317 void
1318 bfd_sym_print_resources_table_entry (abfd, f, entry)
1319 bfd *abfd;
1320 FILE *f;
1321 bfd_sym_resources_table_entry *entry;
1323 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1324 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1325 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1326 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1327 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1330 void
1331 bfd_sym_print_modules_table_entry (abfd, f, entry)
1332 bfd *abfd;
1333 FILE *f;
1334 bfd_sym_modules_table_entry *entry;
1336 fprintf (f, "\"%.*s\" (NTE %lu)",
1337 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1338 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1339 entry->mte_nte_index);
1341 fprintf (f, "\n ");
1343 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1344 fprintf (f, " range %lu -- %lu",
1345 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1347 fprintf (f, "\n ");
1349 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1350 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1352 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1353 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1355 fprintf (f, "\n ");
1357 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1358 entry->mte_cmte_index, entry->mte_cvte_index,
1359 entry->mte_clte_index, entry->mte_ctte_index,
1360 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1362 if (entry->mte_parent != 0)
1363 fprintf (f, ", parent %lu", entry->mte_parent);
1364 else
1365 fprintf (f, ", no parent");
1367 if (entry->mte_cmte_index != 0)
1368 fprintf (f, ", child %lu", entry->mte_cmte_index);
1369 else
1370 fprintf (f, ", no child");
1373 void
1374 bfd_sym_print_file_references_table_entry (abfd, f, entry)
1375 bfd *abfd;
1376 FILE *f;
1377 bfd_sym_file_references_table_entry *entry;
1379 switch (entry->generic.type)
1381 case BFD_SYM_FILE_NAME_INDEX:
1382 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1383 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1384 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1385 entry->filename.nte_index);
1387 fprintf (f, "[UNIMPLEMENTED]");
1388 /* printModDate (entry->filename.mod_date); */
1389 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1390 break;
1392 case BFD_SYM_END_OF_LIST:
1393 fprintf (f, "END");
1394 break;
1396 default:
1397 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1398 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1399 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1400 entry->entry.mte_index,
1401 entry->entry.file_offset);
1402 break;
1406 void
1407 bfd_sym_print_contained_modules_table_entry (abfd, f, entry)
1408 bfd *abfd;
1409 FILE *f;
1410 bfd_sym_contained_modules_table_entry *entry;
1412 switch (entry->generic.type)
1414 case BFD_SYM_END_OF_LIST:
1415 fprintf (f, "END");
1416 break;
1418 default:
1419 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
1420 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1421 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1422 entry->entry.mte_index,
1423 entry->entry.nte_index);
1424 break;
1428 void
1429 bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
1430 bfd *abfd;
1431 FILE *f;
1432 bfd_sym_contained_variables_table_entry *entry;
1434 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1436 fprintf (f, "END");
1437 return;
1440 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1442 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1443 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1444 return;
1447 fprintf (f, "\"%.*s\" (NTE %lu)",
1448 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1449 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1450 entry->entry.nte_index);
1452 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1453 fprintf (f, ", offset %lu", entry->entry.file_delta);
1454 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1456 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1457 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1458 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1459 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1460 entry->entry.address.scstruct.sca_offset);
1461 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1463 unsigned long i;
1465 fprintf (f, ", la [");
1466 for (i = 0; i < entry->entry.la_size; i++)
1467 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1468 fprintf (f, "]");
1470 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1471 fprintf (f, ", bigla %lu, biglakind %u",
1472 entry->entry.address.biglastruct.big_la,
1473 entry->entry.address.biglastruct.big_la_kind);
1475 else
1476 fprintf (f, ", la [INVALID]");
1479 void
1480 bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
1481 bfd *abfd;
1482 FILE *f;
1483 bfd_sym_contained_statements_table_entry *entry;
1485 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1487 fprintf (f, "END");
1488 return;
1491 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1493 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1494 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1495 return;
1498 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1499 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1500 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1501 entry->entry.mte_index,
1502 entry->entry.mte_offset,
1503 entry->entry.file_delta);
1506 void
1507 bfd_sym_print_contained_labels_table_entry (abfd, f, entry)
1508 bfd *abfd;
1509 FILE *f;
1510 bfd_sym_contained_labels_table_entry *entry;
1512 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1514 fprintf (f, "END");
1515 return;
1518 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1520 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1521 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1522 return;
1525 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1526 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1527 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1528 entry->entry.mte_index,
1529 entry->entry.mte_offset,
1530 entry->entry.file_delta,
1531 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1534 void
1535 bfd_sym_print_contained_types_table_entry (abfd, f, entry)
1536 bfd *abfd ATTRIBUTE_UNUSED;
1537 FILE *f;
1538 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED;
1540 fprintf (f, "[UNIMPLEMENTED]");
1543 const char *
1544 bfd_sym_type_operator_name (num)
1545 unsigned char num;
1547 switch (num)
1549 case 1: return "TTE";
1550 case 2: return "PointerTo";
1551 case 3: return "ScalarOf";
1552 case 4: return "ConstantOf";
1553 case 5: return "EnumerationOf";
1554 case 6: return "VectorOf";
1555 case 7: return "RecordOf";
1556 case 8: return "UnionOf";
1557 case 9: return "SubRangeOf";
1558 case 10: return "SetOf";
1559 case 11: return "NamedTypeOf";
1560 case 12: return "ProcOf";
1561 case 13: return "ValueOf";
1562 case 14: return "ArrayOf";
1563 default: return "[UNKNOWN OPERATOR]";
1567 const char *
1568 bfd_sym_type_basic_name (num)
1569 unsigned char num;
1571 switch (num)
1573 case 0: return "void";
1574 case 1: return "pascal string";
1575 case 2: return "unsigned long";
1576 case 3: return "signed long";
1577 case 4: return "extended (10 bytes)";
1578 case 5: return "pascal boolean (1 byte)";
1579 case 6: return "unsigned byte";
1580 case 7: return "signed byte";
1581 case 8: return "character (1 byte)";
1582 case 9: return "wide character (2 bytes)";
1583 case 10: return "unsigned short";
1584 case 11: return "signed short";
1585 case 12: return "singled";
1586 case 13: return "double";
1587 case 14: return "extended (12 bytes)";
1588 case 15: return "computational (8 bytes)";
1589 case 16: return "c string";
1590 case 17: return "as-is string";
1591 default: return "[UNKNOWN BASIC TYPE]";
1596 bfd_sym_fetch_long (buf, len, offset, offsetptr, value)
1597 unsigned char *buf;
1598 unsigned long len;
1599 unsigned long offset;
1600 unsigned long *offsetptr;
1601 long *value;
1603 int ret;
1605 if (offset >= len)
1607 *value = 0;
1608 offset += 0;
1609 ret = -1;
1611 else if (! (buf[offset] & 0x80))
1613 *value = buf[offset];
1614 offset += 1;
1615 ret = 0;
1617 else if (buf[offset] == 0xc0)
1619 if ((offset + 5) > len)
1621 *value = 0;
1622 offset = len;
1623 ret = -1;
1625 else
1627 *value = bfd_getb32 (buf + offset + 1);
1628 offset += 5;
1629 ret = 0;
1632 else if ((buf[offset] & 0xc0) == 0xc0)
1634 *value = -(buf[offset] & 0x3f);
1635 offset += 1;
1636 ret = 0;
1638 else if ((buf[offset] & 0xc0) == 0x80)
1640 if ((offset + 2) > len)
1642 *value = 0;
1643 offset = len;
1644 ret = -1;
1646 else
1648 *value = bfd_getb16 (buf + offset) & 0x3fff;
1649 offset += 2;
1650 ret = 0;
1653 else
1654 abort ();
1656 if (offsetptr != NULL)
1657 *offsetptr = offset;
1659 return ret;
1662 void
1663 bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
1664 bfd *abfd;
1665 FILE *f;
1666 unsigned char *buf;
1667 unsigned long len;
1668 unsigned long offset;
1669 unsigned long *offsetptr;
1671 unsigned int type;
1673 if (offset >= len)
1675 fprintf (f, "[NULL]");
1677 if (offsetptr != NULL)
1678 *offsetptr = offset;
1679 return;
1682 type = buf[offset];
1683 offset++;
1685 if (! (type & 0x80))
1687 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1689 if (offsetptr != NULL)
1690 *offsetptr = offset;
1691 return;
1694 if (type & 0x40)
1695 fprintf (f, "[packed ");
1696 else
1697 fprintf (f, "[");
1699 switch (type & 0x3f)
1701 case 1:
1703 long value;
1704 bfd_sym_type_information_table_entry tinfo;
1706 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1707 if (value <= 0)
1708 fprintf (f, "[INVALID]");
1709 else
1711 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1712 fprintf (f, "[INVALID]");
1713 else
1714 fprintf (f, "\"%.*s\"",
1715 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1716 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1718 fprintf (f, " (TTE %lu)", value);
1719 break;
1722 case 2:
1723 fprintf (f, "pointer (0x%x) to ", type);
1724 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1725 break;
1727 case 3:
1729 long value;
1731 fprintf (f, "scalar (0x%x) of ", type);
1732 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1733 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1734 fprintf (f, " (%lu)", (unsigned long) value);
1735 break;
1738 case 5:
1740 long lower, upper, nelem;
1741 int i;
1743 fprintf (f, "enumeration (0x%x) of ", type);
1744 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1745 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1746 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1747 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1748 fprintf (f, " from %lu to %lu with %lu elements: ",
1749 (unsigned long) lower, (unsigned long) upper,
1750 (unsigned long) nelem);
1752 for (i = 0; i < nelem; i++)
1754 fprintf (f, "\n ");
1755 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1757 break;
1760 case 6:
1761 fprintf (f, "vector (0x%x)", type);
1762 fprintf (f, "\n index ");
1763 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1764 fprintf (f, "\n target ");
1765 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1766 break;
1768 case 7:
1769 case 8:
1771 long nrec, eloff, i;
1773 if ((type & 0x3f) == 7)
1774 fprintf (f, "record (0x%x) of ", type);
1775 else
1776 fprintf (f, "union (0x%x) of ", type);
1778 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1779 fprintf (f, "%lu elements: ", nrec);
1781 for (i = 0; i < nrec; i++)
1783 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1784 fprintf (f, "\n ");
1785 fprintf (f, "offset %lu: ", eloff);
1786 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1788 break;
1791 case 9:
1792 fprintf (f, "subrange (0x%x) of ", type);
1793 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1794 fprintf (f, " lower ");
1795 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1796 fprintf (f, " upper ");
1797 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1798 break;
1800 case 11:
1802 long value;
1804 fprintf (f, "named type (0x%x) ", type);
1805 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1806 if (value <= 0)
1807 fprintf (f, "[INVALID]");
1808 else
1809 fprintf (f, "\"%.*s\"",
1810 bfd_sym_symbol_name (abfd, value)[0],
1811 &bfd_sym_symbol_name (abfd, value)[1]);
1813 fprintf (f, " (NTE %lu) with type ", value);
1814 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1815 break;
1818 default:
1819 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1820 break;
1823 if (type == (0x40 | 0x6))
1825 /* Vector. */
1826 long n, width, m;
1827 long l;
1828 long i;
1830 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1831 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1832 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1833 /* fprintf (f, "\n "); */
1834 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1835 for (i = 0; i < m; i++)
1837 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1838 if (i != 0)
1839 fprintf (f, " ");
1840 fprintf (f, "%ld", l);
1843 else if (type & 0x40)
1845 /* Other packed type. */
1846 long msb, lsb;
1848 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1849 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1850 /* fprintf (f, "\n "); */
1851 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1854 fprintf (f, "]");
1856 if (offsetptr != NULL)
1857 *offsetptr = offset;
1860 void
1861 bfd_sym_print_type_information_table_entry (abfd, f, entry)
1862 bfd *abfd;
1863 FILE *f;
1864 bfd_sym_type_information_table_entry *entry;
1866 unsigned char *buf;
1867 unsigned long offset;
1868 unsigned int i;
1870 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1871 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1872 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1873 entry->nte_index,
1874 entry->physical_size, entry->offset, entry->logical_size);
1876 fprintf (f, "\n ");
1878 buf = alloca (entry->physical_size);
1879 if (buf == NULL)
1881 fprintf (f, "[ERROR]\n");
1882 return;
1884 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1886 fprintf (f, "[ERROR]\n");
1887 return;
1889 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1891 fprintf (f, "[ERROR]\n");
1892 return;
1895 fprintf (f, "[");
1896 for (i = 0; i < entry->physical_size; i++)
1898 if (i == 0)
1899 fprintf (f, "0x%02x", buf[i]);
1900 else
1901 fprintf (f, " 0x%02x", buf[i]);
1904 fprintf (f, "]");
1905 fprintf (f, "\n ");
1907 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1909 if (offset != entry->physical_size)
1910 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); }
1912 void
1913 bfd_sym_print_file_references_index_table_entry (abfd, f, entry)
1914 bfd *abfd ATTRIBUTE_UNUSED;
1915 FILE *f;
1916 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED;
1918 fprintf (f, "[UNIMPLEMENTED]");
1921 void
1922 bfd_sym_print_constant_pool_entry (abfd, f, entry)
1923 bfd *abfd ATTRIBUTE_UNUSED;
1924 FILE *f;
1925 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED;
1927 fprintf (f, "[UNIMPLEMENTED]");
1930 unsigned char *
1931 bfd_sym_display_name_table_entry (abfd, f, entry)
1932 bfd *abfd;
1933 FILE *f;
1934 unsigned char *entry;
1936 unsigned long index;
1937 unsigned long offset;
1938 bfd_sym_data_struct *sdata = NULL;
1940 BFD_ASSERT (bfd_sym_valid (abfd));
1941 sdata = abfd->tdata.sym_data;
1942 index = (entry - sdata->name_table) / 2;
1944 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1946 unsigned short length = bfd_getb16 (entry + 2);
1947 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
1948 offset = 2 + length + 1;
1950 else
1952 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1953 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
1955 if (sdata->version >= BFD_SYM_VERSION_3_4)
1956 offset = entry[0] + 2;
1957 else
1958 offset = entry[0] + 1;
1961 return (entry + offset + (offset % 2));
1964 void
1965 bfd_sym_display_name_table (abfd, f)
1966 bfd *abfd;
1967 FILE *f;
1969 unsigned long name_table_len;
1970 unsigned char *name_table, *name_table_end, *cur;
1971 bfd_sym_data_struct *sdata = NULL;
1973 BFD_ASSERT (bfd_sym_valid (abfd));
1974 sdata = abfd->tdata.sym_data;
1976 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1977 name_table = sdata->name_table;
1978 name_table_end = name_table + name_table_len;
1980 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1982 cur = name_table;
1983 for (;;)
1985 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1986 if (cur >= name_table_end)
1987 break;
1991 void
1992 bfd_sym_display_resources_table (abfd, f)
1993 bfd *abfd;
1994 FILE *f;
1996 unsigned long i;
1997 bfd_sym_resources_table_entry entry;
1998 bfd_sym_data_struct *sdata = NULL;
2000 BFD_ASSERT (bfd_sym_valid (abfd));
2001 sdata = abfd->tdata.sym_data;
2003 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
2004 sdata->header.dshb_rte.dti_object_count);
2006 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
2008 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
2009 fprintf (f, " [%8lu] [INVALID]\n", i);
2010 else
2012 fprintf (f, " [%8lu] ", i);
2013 bfd_sym_print_resources_table_entry (abfd, f, &entry);
2014 fprintf (f, "\n");
2019 void
2020 bfd_sym_display_modules_table (abfd, f)
2021 bfd *abfd;
2022 FILE *f;
2024 unsigned long i;
2025 bfd_sym_modules_table_entry entry;
2026 bfd_sym_data_struct *sdata = NULL;
2028 BFD_ASSERT (bfd_sym_valid (abfd));
2029 sdata = abfd->tdata.sym_data;
2031 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
2032 sdata->header.dshb_mte.dti_object_count);
2034 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
2036 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
2037 fprintf (f, " [%8lu] [INVALID]\n", i);
2038 else
2040 fprintf (f, " [%8lu] ", i);
2041 bfd_sym_print_modules_table_entry (abfd, f, &entry);
2042 fprintf (f, "\n");
2047 void
2048 bfd_sym_display_file_references_table (abfd, f)
2049 bfd *abfd;
2050 FILE *f;
2052 unsigned long i;
2053 bfd_sym_file_references_table_entry entry;
2054 bfd_sym_data_struct *sdata = NULL;
2056 BFD_ASSERT (bfd_sym_valid (abfd));
2057 sdata = abfd->tdata.sym_data;
2059 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
2060 sdata->header.dshb_frte.dti_object_count);
2062 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
2064 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
2065 fprintf (f, " [%8lu] [INVALID]\n", i);
2066 else
2068 fprintf (f, " [%8lu] ", i);
2069 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
2070 fprintf (f, "\n");
2075 void
2076 bfd_sym_display_contained_modules_table (abfd, f)
2077 bfd *abfd;
2078 FILE *f;
2080 unsigned long i;
2081 bfd_sym_contained_modules_table_entry entry;
2082 bfd_sym_data_struct *sdata = NULL;
2084 BFD_ASSERT (bfd_sym_valid (abfd));
2085 sdata = abfd->tdata.sym_data;
2087 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
2088 sdata->header.dshb_cmte.dti_object_count);
2090 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2092 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
2093 fprintf (f, " [%8lu] [INVALID]\n", i);
2094 else
2096 fprintf (f, " [%8lu] ", i);
2097 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
2098 fprintf (f, "\n");
2103 void
2104 bfd_sym_display_contained_variables_table (abfd, f)
2105 bfd *abfd;
2106 FILE *f;
2108 unsigned long i;
2109 bfd_sym_contained_variables_table_entry entry;
2110 bfd_sym_data_struct *sdata = NULL;
2112 BFD_ASSERT (bfd_sym_valid (abfd));
2113 sdata = abfd->tdata.sym_data;
2115 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2116 sdata->header.dshb_cvte.dti_object_count);
2118 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2120 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2121 fprintf (f, " [%8lu] [INVALID]\n", i);
2122 else
2124 fprintf (f, " [%8lu] ", i);
2125 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2126 fprintf (f, "\n");
2130 fprintf (f, "\n");
2133 void
2134 bfd_sym_display_contained_statements_table (abfd, f)
2135 bfd *abfd;
2136 FILE *f;
2138 unsigned long i;
2139 bfd_sym_contained_statements_table_entry entry;
2140 bfd_sym_data_struct *sdata = NULL;
2142 BFD_ASSERT (bfd_sym_valid (abfd));
2143 sdata = abfd->tdata.sym_data;
2145 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
2146 sdata->header.dshb_csnte.dti_object_count);
2148 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2150 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
2151 fprintf (f, " [%8lu] [INVALID]\n", i);
2152 else
2154 fprintf (f, " [%8lu] ", i);
2155 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
2156 fprintf (f, "\n");
2161 void
2162 bfd_sym_display_contained_labels_table (abfd, f)
2163 bfd *abfd;
2164 FILE *f;
2166 unsigned long i;
2167 bfd_sym_contained_labels_table_entry entry;
2168 bfd_sym_data_struct *sdata = NULL;
2170 BFD_ASSERT (bfd_sym_valid (abfd));
2171 sdata = abfd->tdata.sym_data;
2173 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
2174 sdata->header.dshb_clte.dti_object_count);
2176 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2178 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
2179 fprintf (f, " [%8lu] [INVALID]\n", i);
2180 else
2182 fprintf (f, " [%8lu] ", i);
2183 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
2184 fprintf (f, "\n");
2189 void
2190 bfd_sym_display_contained_types_table (abfd, f)
2191 bfd *abfd;
2192 FILE *f;
2194 unsigned long i;
2195 bfd_sym_contained_types_table_entry entry;
2196 bfd_sym_data_struct *sdata = NULL;
2198 BFD_ASSERT (bfd_sym_valid (abfd));
2199 sdata = abfd->tdata.sym_data;
2201 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
2202 sdata->header.dshb_ctte.dti_object_count);
2204 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2206 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2207 fprintf (f, " [%8lu] [INVALID]\n", i);
2208 else
2210 fprintf (f, " [%8lu] ", i);
2211 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2212 fprintf (f, "\n");
2217 void
2218 bfd_sym_display_file_references_index_table (abfd, f)
2219 bfd *abfd;
2220 FILE *f;
2222 unsigned long i;
2223 bfd_sym_file_references_index_table_entry entry;
2224 bfd_sym_data_struct *sdata = NULL;
2226 BFD_ASSERT (bfd_sym_valid (abfd));
2227 sdata = abfd->tdata.sym_data;
2229 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
2230 sdata->header.dshb_fite.dti_object_count);
2232 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2234 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2235 fprintf (f, " [%8lu] [INVALID]\n", i);
2236 else
2238 fprintf (f, " [%8lu] ", i);
2239 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2240 fprintf (f, "\n");
2245 void
2246 bfd_sym_display_constant_pool (abfd, f)
2247 bfd *abfd;
2248 FILE *f;
2250 unsigned long i;
2251 bfd_sym_constant_pool_entry entry;
2252 bfd_sym_data_struct *sdata = NULL;
2254 BFD_ASSERT (bfd_sym_valid (abfd));
2255 sdata = abfd->tdata.sym_data;
2257 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2258 sdata->header.dshb_const.dti_object_count);
2260 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2262 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2263 fprintf (f, " [%8lu] [INVALID]\n", i);
2264 else
2266 fprintf (f, " [%8lu] ", i);
2267 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2268 fprintf (f, "\n");
2273 void
2274 bfd_sym_display_type_information_table (abfd, f)
2275 bfd *abfd;
2276 FILE *f;
2278 unsigned long i;
2279 bfd_sym_type_table_entry index;
2280 bfd_sym_type_information_table_entry entry;
2281 bfd_sym_data_struct *sdata = NULL;
2283 BFD_ASSERT (bfd_sym_valid (abfd));
2284 sdata = abfd->tdata.sym_data;
2286 if (sdata->header.dshb_tte.dti_object_count > 99)
2287 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2288 sdata->header.dshb_tte.dti_object_count - 99);
2289 else
2291 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2292 return;
2295 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2297 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
2298 fprintf (f, " [%8lu] [INVALID]\n", i);
2299 else
2301 fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
2303 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
2304 fprintf (f, "[INVALID]");
2305 else
2306 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2308 fprintf (f, "\n");
2314 bfd_sym_scan (abfd, version, mdata)
2315 bfd *abfd;
2316 bfd_sym_version version;
2317 bfd_sym_data_struct *mdata;
2319 asection *bfdsec;
2320 const char *name = "symbols";
2322 mdata->name_table = 0;
2323 mdata->sbfd = abfd;
2324 mdata->version = version;
2326 bfd_seek (abfd, 0, SEEK_SET);
2327 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2328 return -1;
2330 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2331 if (mdata->name_table == NULL)
2332 return -1;
2334 bfdsec = bfd_make_section_anyway (abfd, name);
2335 if (bfdsec == NULL)
2336 return -1;
2338 bfdsec->vma = 0;
2339 bfdsec->lma = 0;
2340 bfdsec->size = 0;
2341 bfdsec->filepos = 0;
2342 bfdsec->alignment_power = 0;
2344 bfdsec->flags = SEC_HAS_CONTENTS;
2346 abfd->tdata.sym_data = mdata;
2348 return 0;
2351 const bfd_target *
2352 bfd_sym_object_p (abfd)
2353 bfd *abfd;
2355 struct bfd_preserve preserve;
2356 bfd_sym_version version = -1;
2358 preserve.marker = NULL;
2359 bfd_seek (abfd, 0, SEEK_SET);
2360 if (bfd_sym_read_version (abfd, &version) != 0)
2361 goto wrong;
2363 preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
2364 if (preserve.marker == NULL
2365 || ! bfd_preserve_save (abfd, &preserve))
2366 goto fail;
2368 if (bfd_sym_scan (abfd, version,
2369 (bfd_sym_data_struct *) preserve.marker) != 0)
2370 goto wrong;
2372 bfd_preserve_finish (abfd, &preserve);
2373 return abfd->xvec;
2375 wrong:
2376 bfd_set_error (bfd_error_wrong_format);
2378 fail:
2379 if (preserve.marker != NULL)
2380 bfd_preserve_restore (abfd, &preserve);
2381 return NULL;
2384 asymbol *
2385 bfd_sym_make_empty_symbol (abfd)
2386 bfd *abfd;
2388 return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
2391 void
2392 bfd_sym_get_symbol_info (abfd, symbol, ret)
2393 bfd *abfd ATTRIBUTE_UNUSED;
2394 asymbol *symbol;
2395 symbol_info *ret;
2397 bfd_symbol_info (symbol, ret);
2400 long
2401 bfd_sym_get_symtab_upper_bound (abfd)
2402 bfd *abfd ATTRIBUTE_UNUSED;
2404 return 0;
2407 long
2408 bfd_sym_canonicalize_symtab (abfd, sym)
2409 bfd *abfd ATTRIBUTE_UNUSED;
2410 asymbol **sym ATTRIBUTE_UNUSED;
2412 return 0;
2416 bfd_sym_sizeof_headers (abfd, exec)
2417 bfd *abfd ATTRIBUTE_UNUSED;
2418 bfd_boolean exec ATTRIBUTE_UNUSED;
2420 return 0;
2423 const bfd_target sym_vec =
2425 "sym", /* name */
2426 bfd_target_sym_flavour, /* flavour */
2427 BFD_ENDIAN_BIG, /* byteorder */
2428 BFD_ENDIAN_BIG, /* header_byteorder */
2429 (HAS_RELOC | EXEC_P | /* object flags */
2430 HAS_LINENO | HAS_DEBUG |
2431 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2432 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2433 | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
2434 0, /* symbol_leading_char */
2435 ' ', /* ar_pad_char */
2436 16, /* ar_max_namelen */
2437 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2438 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2439 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
2440 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2441 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2442 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
2443 { /* bfd_check_format */
2444 _bfd_dummy_target,
2445 bfd_sym_object_p, /* bfd_check_format */
2446 _bfd_dummy_target,
2447 _bfd_dummy_target,
2449 { /* bfd_set_format */
2450 bfd_false,
2451 bfd_sym_mkobject,
2452 bfd_false,
2453 bfd_false,
2455 { /* bfd_write_contents */
2456 bfd_false,
2457 bfd_true,
2458 bfd_false,
2459 bfd_false,
2462 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2463 BFD_JUMP_TABLE_COPY (_bfd_generic),
2464 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2465 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2466 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2467 BFD_JUMP_TABLE_RELOCS (bfd_sym),
2468 BFD_JUMP_TABLE_WRITE (bfd_sym),
2469 BFD_JUMP_TABLE_LINK (bfd_sym),
2470 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2472 NULL,
2474 NULL