* ld-cris/expdyn1.d, ld-cris/expdyn5.d, ld-cris/expdyn6.d,
[binutils.git] / bfd / xsym.c
blob3c4c84da9adc34eef30e22b213c7491b2ad3b9b9
1 /* xSYM symbol-file support for BFD.
2 Copyright 1999, 2000, 2001, 2002, 2003, 2004
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_is_group_section bfd_generic_is_group_section
46 #define bfd_sym_bfd_discard_group bfd_generic_discard_group
47 #define bfd_sym_section_already_linked \
48 _bfd_generic_section_already_linked
49 #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
50 #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
51 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
52 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
53 #define bfd_sym_bfd_final_link _bfd_generic_final_link
54 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
55 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
57 static int pstrcmp PARAMS ((unsigned char *, unsigned char *));
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 (a, b)
65 unsigned char *a;
66 unsigned char *b;
68 unsigned char clen;
69 int ret;
71 clen = (a[0] > b[0]) ? a[0] : b[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 0;
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 unsigned 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 memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA);
467 entry->entry.address.lastruct.la_kind = buf[23];
469 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
471 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
472 entry->entry.address.biglastruct.big_la_kind = buf[12];
477 void
478 bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
479 unsigned char *buf;
480 size_t len;
481 bfd_sym_contained_statements_table_entry *entry;
483 unsigned int type;
485 BFD_ASSERT (len == 8);
487 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
488 type = bfd_getb16 (buf);
490 switch (type)
492 case BFD_SYM_END_OF_LIST_3_2:
493 entry->generic.type = BFD_SYM_END_OF_LIST;
494 break;
496 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
497 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
498 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
499 break;
501 default:
502 entry->entry.mte_index = type;
503 entry->entry.mte_offset = bfd_getb16 (buf + 2);
504 entry->entry.file_delta = bfd_getb32 (buf + 4);
505 break;
509 void
510 bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
511 unsigned char *buf;
512 size_t len;
513 bfd_sym_contained_labels_table_entry *entry;
515 unsigned int type;
517 BFD_ASSERT (len == 12);
519 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
520 type = bfd_getb16 (buf);
522 switch (type)
524 case BFD_SYM_END_OF_LIST_3_2:
525 entry->generic.type = BFD_SYM_END_OF_LIST;
526 break;
528 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
529 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
530 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
531 break;
533 default:
534 entry->entry.mte_index = type;
535 entry->entry.mte_offset = bfd_getb16 (buf + 2);
536 entry->entry.nte_index = bfd_getb32 (buf + 4);
537 entry->entry.file_delta = bfd_getb16 (buf + 8);
538 entry->entry.scope = bfd_getb16 (buf + 10);
539 break;
543 void
544 bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
545 unsigned char *buf;
546 size_t len;
547 bfd_sym_type_table_entry *entry;
549 BFD_ASSERT (len == 4);
551 *entry = bfd_getb32 (buf);
555 bfd_sym_fetch_resources_table_entry (abfd, entry, index)
556 bfd *abfd;
557 bfd_sym_resources_table_entry *entry;
558 unsigned long index;
560 void (*parser) PARAMS ((unsigned char *, size_t,
561 bfd_sym_resources_table_entry *));
562 unsigned long offset;
563 unsigned long entry_size;
564 unsigned char buf[18];
565 bfd_sym_data_struct *sdata = NULL;
567 parser = NULL;
568 BFD_ASSERT (bfd_sym_valid (abfd));
569 sdata = abfd->tdata.sym_data;
571 if (index == 0)
572 return -1;
574 switch (sdata->version)
576 case BFD_SYM_VERSION_3_5:
577 case BFD_SYM_VERSION_3_4:
578 return -1;
580 case BFD_SYM_VERSION_3_3:
581 case BFD_SYM_VERSION_3_2:
582 entry_size = 18;
583 parser = bfd_sym_parse_resources_table_entry_v32;
584 break;
586 case BFD_SYM_VERSION_3_1:
587 default:
588 return -1;
590 if (parser == NULL)
591 return -1;
593 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
594 sdata->header.dshb_page_size,
595 entry_size, index);
597 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
598 return -1;
599 if (bfd_bread (buf, entry_size, abfd) != entry_size)
600 return -1;
602 (*parser) (buf, entry_size, entry);
604 return 0;
608 bfd_sym_fetch_modules_table_entry (abfd, entry, index)
609 bfd *abfd;
610 bfd_sym_modules_table_entry *entry;
611 unsigned long index;
613 void (*parser) PARAMS ((unsigned char *, size_t,
614 bfd_sym_modules_table_entry *));
615 unsigned long offset;
616 unsigned long entry_size;
617 unsigned char buf[46];
618 bfd_sym_data_struct *sdata = NULL;
620 parser = NULL;
621 BFD_ASSERT (bfd_sym_valid (abfd));
622 sdata = abfd->tdata.sym_data;
624 if (index == 0)
625 return -1;
627 switch (sdata->version)
629 case BFD_SYM_VERSION_3_5:
630 case BFD_SYM_VERSION_3_4:
631 return -1;
633 case BFD_SYM_VERSION_3_3:
634 entry_size = 46;
635 parser = bfd_sym_parse_modules_table_entry_v33;
636 break;
638 case BFD_SYM_VERSION_3_2:
639 case BFD_SYM_VERSION_3_1:
640 default:
641 return -1;
643 if (parser == NULL)
644 return -1;
646 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
647 sdata->header.dshb_page_size,
648 entry_size, index);
650 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
651 return -1;
652 if (bfd_bread (buf, entry_size, abfd) != entry_size)
653 return -1;
655 (*parser) (buf, entry_size, entry);
657 return 0;
661 bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
662 bfd *abfd;
663 bfd_sym_file_references_table_entry *entry;
664 unsigned long index;
666 void (*parser) PARAMS ((unsigned char *, size_t,
667 bfd_sym_file_references_table_entry *));
668 unsigned long offset;
669 unsigned long entry_size = 0;
670 unsigned char buf[8];
671 bfd_sym_data_struct *sdata = NULL;
673 parser = NULL;
674 BFD_ASSERT (bfd_sym_valid (abfd));
675 sdata = abfd->tdata.sym_data;
677 if (index == 0)
678 return -1;
680 switch (sdata->version)
682 case BFD_SYM_VERSION_3_3:
683 case BFD_SYM_VERSION_3_2:
684 entry_size = 10;
685 parser = bfd_sym_parse_file_references_table_entry_v32;
686 break;
688 case BFD_SYM_VERSION_3_5:
689 case BFD_SYM_VERSION_3_4:
690 case BFD_SYM_VERSION_3_1:
691 default:
692 break;
695 if (parser == NULL)
696 return -1;
698 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
699 sdata->header.dshb_page_size,
700 entry_size, index);
702 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
703 return -1;
704 if (bfd_bread (buf, entry_size, abfd) != entry_size)
705 return -1;
707 (*parser) (buf, entry_size, entry);
709 return 0;
713 bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
714 bfd *abfd;
715 bfd_sym_contained_modules_table_entry *entry;
716 unsigned long index;
718 void (*parser) PARAMS ((unsigned char *, size_t,
719 bfd_sym_contained_modules_table_entry *));
720 unsigned long offset;
721 unsigned long entry_size = 0;
722 unsigned char buf[6];
723 bfd_sym_data_struct *sdata = NULL;
725 parser = NULL;
726 BFD_ASSERT (bfd_sym_valid (abfd));
727 sdata = abfd->tdata.sym_data;
729 if (index == 0)
730 return -1;
732 switch (sdata->version)
734 case BFD_SYM_VERSION_3_3:
735 case BFD_SYM_VERSION_3_2:
736 entry_size = 6;
737 parser = bfd_sym_parse_contained_modules_table_entry_v32;
738 break;
740 case BFD_SYM_VERSION_3_5:
741 case BFD_SYM_VERSION_3_4:
742 case BFD_SYM_VERSION_3_1:
743 default:
744 break;
747 if (parser == NULL)
748 return -1;
750 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
751 sdata->header.dshb_page_size,
752 entry_size, index);
754 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
755 return -1;
756 if (bfd_bread (buf, entry_size, abfd) != entry_size)
757 return -1;
759 (*parser) (buf, entry_size, entry);
761 return 0;
765 bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
766 bfd *abfd;
767 bfd_sym_contained_variables_table_entry *entry;
768 unsigned long index;
770 void (*parser) PARAMS ((unsigned char *, size_t,
771 bfd_sym_contained_variables_table_entry *));
772 unsigned long offset;
773 unsigned long entry_size = 0;
774 unsigned char buf[26];
775 bfd_sym_data_struct *sdata = NULL;
777 parser = NULL;
778 BFD_ASSERT (bfd_sym_valid (abfd));
779 sdata = abfd->tdata.sym_data;
781 if (index == 0)
782 return -1;
784 switch (sdata->version)
786 case BFD_SYM_VERSION_3_3:
787 case BFD_SYM_VERSION_3_2:
788 entry_size = 26;
789 parser = bfd_sym_parse_contained_variables_table_entry_v32;
790 break;
792 case BFD_SYM_VERSION_3_5:
793 case BFD_SYM_VERSION_3_4:
794 case BFD_SYM_VERSION_3_1:
795 default:
796 break;
799 if (parser == NULL)
800 return -1;
802 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
803 sdata->header.dshb_page_size,
804 entry_size, index);
806 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
807 return -1;
808 if (bfd_bread (buf, entry_size, abfd) != entry_size)
809 return -1;
811 (*parser) (buf, entry_size, entry);
813 return 0;
817 bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
818 bfd *abfd;
819 bfd_sym_contained_statements_table_entry *entry;
820 unsigned long index;
822 void (*parser) PARAMS ((unsigned char *, size_t,
823 bfd_sym_contained_statements_table_entry *));
824 unsigned long offset;
825 unsigned long entry_size = 0;
826 unsigned char buf[8];
827 bfd_sym_data_struct *sdata = NULL;
829 parser = NULL;
830 BFD_ASSERT (bfd_sym_valid (abfd));
831 sdata = abfd->tdata.sym_data;
833 if (index == 0)
834 return -1;
836 switch (sdata->version)
838 case BFD_SYM_VERSION_3_3:
839 case BFD_SYM_VERSION_3_2:
840 entry_size = 8;
841 parser = bfd_sym_parse_contained_statements_table_entry_v32;
842 break;
844 case BFD_SYM_VERSION_3_5:
845 case BFD_SYM_VERSION_3_4:
846 case BFD_SYM_VERSION_3_1:
847 default:
848 break;
851 if (parser == NULL)
852 return -1;
854 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
855 sdata->header.dshb_page_size,
856 entry_size, index);
858 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
859 return -1;
860 if (bfd_bread (buf, entry_size, abfd) != entry_size)
861 return -1;
863 (*parser) (buf, entry_size, entry);
865 return 0;
869 bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
870 bfd *abfd;
871 bfd_sym_contained_labels_table_entry *entry;
872 unsigned long index;
874 void (*parser) PARAMS ((unsigned char *, size_t,
875 bfd_sym_contained_labels_table_entry *));
876 unsigned long offset;
877 unsigned long entry_size = 0;
878 unsigned char buf[12];
879 bfd_sym_data_struct *sdata = NULL;
881 parser = NULL;
882 BFD_ASSERT (bfd_sym_valid (abfd));
883 sdata = abfd->tdata.sym_data;
885 if (index == 0)
886 return -1;
888 switch (sdata->version)
890 case BFD_SYM_VERSION_3_3:
891 case BFD_SYM_VERSION_3_2:
892 entry_size = 12;
893 parser = bfd_sym_parse_contained_labels_table_entry_v32;
894 break;
896 case BFD_SYM_VERSION_3_5:
897 case BFD_SYM_VERSION_3_4:
898 case BFD_SYM_VERSION_3_1:
899 default:
900 break;
903 if (parser == NULL)
904 return -1;
906 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
907 sdata->header.dshb_page_size,
908 entry_size, index);
910 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
911 return -1;
912 if (bfd_bread (buf, entry_size, abfd) != entry_size)
913 return -1;
915 (*parser) (buf, entry_size, entry);
917 return 0;
921 bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
922 bfd *abfd;
923 bfd_sym_contained_types_table_entry *entry;
924 unsigned long index;
926 void (*parser) PARAMS ((unsigned char *, size_t,
927 bfd_sym_contained_types_table_entry *));
928 unsigned long offset;
929 unsigned long entry_size = 0;
930 unsigned char buf[0];
931 bfd_sym_data_struct *sdata = NULL;
933 parser = NULL;
934 BFD_ASSERT (bfd_sym_valid (abfd));
935 sdata = abfd->tdata.sym_data;
937 if (index == 0)
938 return -1;
940 switch (sdata->version)
942 case BFD_SYM_VERSION_3_3:
943 case BFD_SYM_VERSION_3_2:
944 entry_size = 0;
945 parser = NULL;
946 break;
948 case BFD_SYM_VERSION_3_5:
949 case BFD_SYM_VERSION_3_4:
950 case BFD_SYM_VERSION_3_1:
951 default:
952 break;
955 if (parser == NULL)
956 return -1;
958 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
959 sdata->header.dshb_page_size,
960 entry_size, index);
962 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
963 return -1;
964 if (bfd_bread (buf, entry_size, abfd) != entry_size)
965 return -1;
967 (*parser) (buf, entry_size, entry);
969 return 0;
973 bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
974 bfd *abfd;
975 bfd_sym_file_references_index_table_entry *entry;
976 unsigned long index;
978 void (*parser) PARAMS ((unsigned char *, size_t,
979 bfd_sym_file_references_index_table_entry *));
980 unsigned long offset;
981 unsigned long entry_size = 0;
982 unsigned char buf[0];
983 bfd_sym_data_struct *sdata = NULL;
985 parser = NULL;
986 BFD_ASSERT (bfd_sym_valid (abfd));
987 sdata = abfd->tdata.sym_data;
989 if (index == 0)
990 return -1;
992 switch (sdata->version)
994 case BFD_SYM_VERSION_3_3:
995 case BFD_SYM_VERSION_3_2:
996 entry_size = 0;
997 parser = NULL;
998 break;
1000 case BFD_SYM_VERSION_3_5:
1001 case BFD_SYM_VERSION_3_4:
1002 case BFD_SYM_VERSION_3_1:
1003 default:
1004 break;
1007 if (parser == NULL)
1008 return -1;
1010 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1011 sdata->header.dshb_page_size,
1012 entry_size, index);
1014 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1015 return -1;
1016 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1017 return -1;
1019 (*parser) (buf, entry_size, entry);
1021 return 0;
1025 bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
1026 bfd *abfd;
1027 bfd_sym_constant_pool_entry *entry;
1028 unsigned long index;
1030 void (*parser) PARAMS ((unsigned char *, size_t,
1031 bfd_sym_constant_pool_entry *));
1032 unsigned long offset;
1033 unsigned long entry_size = 0;
1034 unsigned char buf[0];
1035 bfd_sym_data_struct *sdata = NULL;
1037 parser = NULL;
1038 BFD_ASSERT (bfd_sym_valid (abfd));
1039 sdata = abfd->tdata.sym_data;
1041 if (index == 0)
1042 return -1;
1044 switch (sdata->version)
1046 case BFD_SYM_VERSION_3_3:
1047 case BFD_SYM_VERSION_3_2:
1048 entry_size = 0;
1049 parser = NULL;
1050 break;
1052 case BFD_SYM_VERSION_3_5:
1053 case BFD_SYM_VERSION_3_4:
1054 case BFD_SYM_VERSION_3_1:
1055 default:
1056 break;
1059 if (parser == NULL)
1060 return -1;
1062 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1063 sdata->header.dshb_page_size,
1064 entry_size, index);
1066 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1067 return -1;
1068 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1069 return -1;
1071 (*parser) (buf, entry_size, entry);
1073 return 0;
1077 bfd_sym_fetch_type_table_entry (abfd, entry, index)
1078 bfd *abfd;
1079 bfd_sym_type_table_entry *entry;
1080 unsigned long index;
1082 void (*parser) PARAMS ((unsigned char *, size_t,
1083 bfd_sym_type_table_entry *));
1084 unsigned long offset;
1085 unsigned long entry_size = 0;
1086 unsigned char buf[4];
1087 bfd_sym_data_struct *sdata = NULL;
1089 parser = NULL;
1090 BFD_ASSERT (bfd_sym_valid (abfd));
1091 sdata = abfd->tdata.sym_data;
1093 switch (sdata->version)
1095 case BFD_SYM_VERSION_3_3:
1096 case BFD_SYM_VERSION_3_2:
1097 entry_size = 4;
1098 parser = bfd_sym_parse_type_table_entry_v32;
1099 break;
1101 case BFD_SYM_VERSION_3_5:
1102 case BFD_SYM_VERSION_3_4:
1103 case BFD_SYM_VERSION_3_1:
1104 default:
1105 break;
1108 if (parser == NULL)
1109 return -1;
1111 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1112 sdata->header.dshb_page_size,
1113 entry_size, index);
1115 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1116 return -1;
1117 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1118 return -1;
1120 (*parser) (buf, entry_size, entry);
1122 return 0;
1126 bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
1127 bfd *abfd;
1128 bfd_sym_type_information_table_entry *entry;
1129 unsigned long offset;
1131 unsigned char buf[4];
1132 bfd_sym_data_struct *sdata = NULL;
1134 BFD_ASSERT (bfd_sym_valid (abfd));
1135 sdata = abfd->tdata.sym_data;
1137 if (offset == 0)
1138 return -1;
1140 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1141 return -1;
1143 if (bfd_bread (buf, 4, abfd) != 4)
1144 return -1;
1145 entry->nte_index = bfd_getb32 (buf);
1147 if (bfd_bread (buf, 2, abfd) != 2)
1148 return -1;
1149 entry->physical_size = bfd_getb16 (buf);
1151 if (entry->physical_size & 0x8000)
1153 if (bfd_bread (buf, 4, abfd) != 4)
1154 return -1;
1155 entry->physical_size &= 0x7fff;
1156 entry->logical_size = bfd_getb32 (buf);
1157 entry->offset = offset + 10;
1159 else
1161 if (bfd_bread (buf, 2, abfd) != 2)
1162 return -1;
1163 entry->physical_size &= 0x7fff;
1164 entry->logical_size = bfd_getb16 (buf);
1165 entry->offset = offset + 8;
1168 return 0;
1172 bfd_sym_fetch_type_table_information (abfd, entry, index)
1173 bfd *abfd;
1174 bfd_sym_type_information_table_entry *entry;
1175 unsigned long index;
1177 bfd_sym_type_table_entry tindex;
1178 bfd_sym_data_struct *sdata = NULL;
1180 BFD_ASSERT (bfd_sym_valid (abfd));
1181 sdata = abfd->tdata.sym_data;
1183 if (sdata->header.dshb_tte.dti_object_count <= 99)
1184 return -1;
1185 if (index < 100)
1186 return -1;
1188 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
1189 return -1;
1190 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1191 return -1;
1193 return 0;
1196 const unsigned char *
1197 bfd_sym_symbol_name (abfd, index)
1198 bfd *abfd;
1199 unsigned long index;
1201 bfd_sym_data_struct *sdata = NULL;
1203 BFD_ASSERT (bfd_sym_valid (abfd));
1204 sdata = abfd->tdata.sym_data;
1206 if (index == 0)
1207 return "";
1209 index *= 2;
1210 if ((index / sdata->header.dshb_page_size)
1211 > sdata->header.dshb_nte.dti_page_count)
1212 return "\009[INVALID]";
1214 return (const unsigned char *) sdata->name_table + index;
1217 const unsigned char *
1218 bfd_sym_module_name (abfd, index)
1219 bfd *abfd;
1220 unsigned long index;
1222 bfd_sym_modules_table_entry entry;
1224 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
1225 return "\011[INVALID]";
1227 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1230 const char *
1231 bfd_sym_unparse_storage_kind (kind)
1232 enum bfd_sym_storage_kind kind;
1234 switch (kind)
1236 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1237 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1238 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1239 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1240 default: return "[UNKNOWN]";
1244 const char *
1245 bfd_sym_unparse_storage_class (kind)
1246 enum bfd_sym_storage_class kind;
1248 switch (kind)
1250 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1251 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1252 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1253 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1254 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1255 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1256 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1257 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1258 default: return "[UNKNOWN]";
1262 const char *
1263 bfd_sym_unparse_module_kind (kind)
1264 enum bfd_sym_module_kind kind;
1266 switch (kind)
1268 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1269 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1270 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1271 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1272 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1273 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1274 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1275 default: return "[UNKNOWN]";
1279 const char *
1280 bfd_sym_unparse_symbol_scope (scope)
1281 enum bfd_sym_symbol_scope scope;
1283 switch (scope)
1285 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1286 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1287 default:
1288 return "[UNKNOWN]";
1292 void
1293 bfd_sym_print_file_reference (abfd, f, entry)
1294 bfd *abfd;
1295 FILE *f;
1296 bfd_sym_file_reference *entry;
1298 bfd_sym_file_references_table_entry frtentry;
1299 int ret;
1301 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1302 entry->fref_frte_index);
1303 fprintf (f, "FILE ");
1305 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1306 fprintf (f, "[INVALID]");
1307 else
1308 fprintf (f, "\"%.*s\"",
1309 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1310 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1312 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1315 void
1316 bfd_sym_print_resources_table_entry (abfd, f, entry)
1317 bfd *abfd;
1318 FILE *f;
1319 bfd_sym_resources_table_entry *entry;
1321 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1322 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1323 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1324 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1325 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1328 void
1329 bfd_sym_print_modules_table_entry (abfd, f, entry)
1330 bfd *abfd;
1331 FILE *f;
1332 bfd_sym_modules_table_entry *entry;
1334 fprintf (f, "\"%.*s\" (NTE %lu)",
1335 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1336 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1337 entry->mte_nte_index);
1339 fprintf (f, "\n ");
1341 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1342 fprintf (f, " range %lu -- %lu",
1343 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1345 fprintf (f, "\n ");
1347 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1348 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1350 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1351 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1353 fprintf (f, "\n ");
1355 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1356 entry->mte_cmte_index, entry->mte_cvte_index,
1357 entry->mte_clte_index, entry->mte_ctte_index,
1358 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1360 if (entry->mte_parent != 0)
1361 fprintf (f, ", parent %lu", entry->mte_parent);
1362 else
1363 fprintf (f, ", no parent");
1365 if (entry->mte_cmte_index != 0)
1366 fprintf (f, ", child %lu", entry->mte_cmte_index);
1367 else
1368 fprintf (f, ", no child");
1370 #if 0
1372 MTE bfd_sym_modules_table_entry pentry;
1374 ret = bfd_sym_fetch_modules_table_entry (abfd, &pentry, entry->mte_parent);
1375 if (ret < 0)
1376 fprintf (f, " parent MTE %lu [INVALID]\n", entry->mte_parent);
1377 else
1378 fprintf (f, " parent MTE %lu \"%.*s\"\n",
1379 entry->mte_parent,
1380 bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[0],
1381 &bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[1]);
1383 #endif
1386 void
1387 bfd_sym_print_file_references_table_entry (abfd, f, entry)
1388 bfd *abfd;
1389 FILE *f;
1390 bfd_sym_file_references_table_entry *entry;
1392 switch (entry->generic.type)
1394 case BFD_SYM_FILE_NAME_INDEX:
1395 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1396 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1397 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1398 entry->filename.nte_index);
1400 fprintf (f, "[UNIMPLEMENTED]");
1401 /* printModDate (entry->filename.mod_date); */
1402 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1403 break;
1405 case BFD_SYM_END_OF_LIST:
1406 fprintf (f, "END");
1407 break;
1409 default:
1410 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1411 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1412 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1413 entry->entry.mte_index,
1414 entry->entry.file_offset);
1415 break;
1419 void
1420 bfd_sym_print_contained_modules_table_entry (abfd, f, entry)
1421 bfd *abfd;
1422 FILE *f;
1423 bfd_sym_contained_modules_table_entry *entry;
1425 switch (entry->generic.type)
1427 case BFD_SYM_END_OF_LIST:
1428 fprintf (f, "END");
1429 break;
1431 default:
1432 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
1433 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1434 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1435 entry->entry.mte_index,
1436 entry->entry.nte_index);
1437 break;
1441 void
1442 bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
1443 bfd *abfd;
1444 FILE *f;
1445 bfd_sym_contained_variables_table_entry *entry;
1447 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1449 fprintf (f, "END");
1450 return;
1453 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1455 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1456 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1457 return;
1460 fprintf (f, "\"%.*s\" (NTE %lu)",
1461 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1462 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1463 entry->entry.nte_index);
1465 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1466 fprintf (f, ", offset %lu", entry->entry.file_delta);
1467 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1469 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1470 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1471 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1472 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1473 entry->entry.address.scstruct.sca_offset);
1474 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1476 unsigned long i;
1478 fprintf (f, ", la [");
1479 for (i = 0; i < entry->entry.la_size; i++)
1480 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1481 fprintf (f, "]");
1483 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1484 fprintf (f, ", bigla %lu, biglakind %u",
1485 entry->entry.address.biglastruct.big_la,
1486 entry->entry.address.biglastruct.big_la_kind);
1488 else
1489 fprintf (f, ", la [INVALID]");
1492 void
1493 bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
1494 bfd *abfd;
1495 FILE *f;
1496 bfd_sym_contained_statements_table_entry *entry;
1498 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1500 fprintf (f, "END");
1501 return;
1504 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1506 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1507 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1508 return;
1511 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1512 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1513 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1514 entry->entry.mte_index,
1515 entry->entry.mte_offset,
1516 entry->entry.file_delta);
1519 void
1520 bfd_sym_print_contained_labels_table_entry (abfd, f, entry)
1521 bfd *abfd;
1522 FILE *f;
1523 bfd_sym_contained_labels_table_entry *entry;
1525 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1527 fprintf (f, "END");
1528 return;
1531 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1533 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1534 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1535 return;
1538 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1539 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1540 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1541 entry->entry.mte_index,
1542 entry->entry.mte_offset,
1543 entry->entry.file_delta,
1544 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1547 void
1548 bfd_sym_print_contained_types_table_entry (abfd, f, entry)
1549 bfd *abfd ATTRIBUTE_UNUSED;
1550 FILE *f;
1551 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED;
1553 fprintf (f, "[UNIMPLEMENTED]");
1556 const char *
1557 bfd_sym_type_operator_name (num)
1558 unsigned char num;
1560 switch (num)
1562 case 1: return "TTE";
1563 case 2: return "PointerTo";
1564 case 3: return "ScalarOf";
1565 case 4: return "ConstantOf";
1566 case 5: return "EnumerationOf";
1567 case 6: return "VectorOf";
1568 case 7: return "RecordOf";
1569 case 8: return "UnionOf";
1570 case 9: return "SubRangeOf";
1571 case 10: return "SetOf";
1572 case 11: return "NamedTypeOf";
1573 case 12: return "ProcOf";
1574 case 13: return "ValueOf";
1575 case 14: return "ArrayOf";
1576 default: return "[UNKNOWN OPERATOR]";
1580 const char *
1581 bfd_sym_type_basic_name (num)
1582 unsigned char num;
1584 switch (num)
1586 case 0: return "void";
1587 case 1: return "pascal string";
1588 case 2: return "unsigned long";
1589 case 3: return "signed long";
1590 case 4: return "extended (10 bytes)";
1591 case 5: return "pascal boolean (1 byte)";
1592 case 6: return "unsigned byte";
1593 case 7: return "signed byte";
1594 case 8: return "character (1 byte)";
1595 case 9: return "wide character (2 bytes)";
1596 case 10: return "unsigned short";
1597 case 11: return "signed short";
1598 case 12: return "singled";
1599 case 13: return "double";
1600 case 14: return "extended (12 bytes)";
1601 case 15: return "computational (8 bytes)";
1602 case 16: return "c string";
1603 case 17: return "as-is string";
1604 default: return "[UNKNOWN BASIC TYPE]";
1609 bfd_sym_fetch_long (buf, len, offset, offsetptr, value)
1610 unsigned char *buf;
1611 unsigned long len;
1612 unsigned long offset;
1613 unsigned long *offsetptr;
1614 long *value;
1616 int ret;
1618 if (offset >= len)
1620 *value = 0;
1621 offset += 0;
1622 ret = -1;
1624 else if (! (buf[offset] & 0x80))
1626 *value = buf[offset];
1627 offset += 1;
1628 ret = 0;
1630 else if (buf[offset] == 0xc0)
1632 if ((offset + 5) > len)
1634 *value = 0;
1635 offset = len;
1636 ret = -1;
1638 else
1640 *value = bfd_getb32 (buf + offset + 1);
1641 offset += 5;
1642 ret = 0;
1645 else if ((buf[offset] & 0xc0) == 0xc0)
1647 *value = -(buf[offset] & 0x3f);
1648 offset += 1;
1649 ret = 0;
1651 else if ((buf[offset] & 0xc0) == 0x80)
1653 if ((offset + 2) > len)
1655 *value = 0;
1656 offset = len;
1657 ret = -1;
1659 else
1661 *value = bfd_getb16 (buf + offset) & 0x3fff;
1662 offset += 2;
1663 ret = 0;
1666 else
1667 abort ();
1669 if (offsetptr != NULL)
1670 *offsetptr = offset;
1672 return ret;
1675 void
1676 bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
1677 bfd *abfd;
1678 FILE *f;
1679 unsigned char *buf;
1680 unsigned long len;
1681 unsigned long offset;
1682 unsigned long *offsetptr;
1684 unsigned int type;
1686 if (offset >= len)
1688 fprintf (f, "[NULL]");
1690 if (offsetptr != NULL)
1691 *offsetptr = offset;
1692 return;
1695 type = buf[offset];
1696 offset++;
1698 if (! (type & 0x80))
1700 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1702 if (offsetptr != NULL)
1703 *offsetptr = offset;
1704 return;
1707 if (type & 0x40)
1708 fprintf (f, "[packed ");
1709 else
1710 fprintf (f, "[");
1712 switch (type & 0x3f)
1714 case 1:
1716 long value;
1717 bfd_sym_type_information_table_entry tinfo;
1719 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1720 if (value <= 0)
1721 fprintf (f, "[INVALID]");
1722 else
1724 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1725 fprintf (f, "[INVALID]");
1726 else
1727 fprintf (f, "\"%.*s\"",
1728 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1729 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1731 fprintf (f, " (TTE %lu)", value);
1732 break;
1735 case 2:
1736 fprintf (f, "pointer (0x%x) to ", type);
1737 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1738 break;
1740 case 3:
1742 unsigned long value;
1744 fprintf (f, "scalar (0x%x) of ", type);
1745 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1746 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1747 fprintf (f, " (%lu)", value);
1748 break;
1751 case 5:
1753 unsigned long lower, upper, nelem;
1754 unsigned long i;
1756 fprintf (f, "enumeration (0x%x) of ", type);
1757 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1758 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1759 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1760 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1761 fprintf (f, " from %lu to %lu with %lu elements: ", lower, upper, nelem);
1763 for (i = 0; i < nelem; i++)
1765 fprintf (f, "\n ");
1766 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1768 break;
1771 case 6:
1772 fprintf (f, "vector (0x%x)", type);
1773 fprintf (f, "\n index ");
1774 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1775 fprintf (f, "\n target ");
1776 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1777 break;
1779 case 7:
1780 case 8:
1782 long nrec, eloff, i;
1784 if ((type & 0x3f) == 7)
1785 fprintf (f, "record (0x%x) of ", type);
1786 else
1787 fprintf (f, "union (0x%x) of ", type);
1789 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1790 fprintf (f, "%lu elements: ", nrec);
1792 for (i = 0; i < nrec; i++)
1794 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1795 fprintf (f, "\n ");
1796 fprintf (f, "offset %lu: ", eloff);
1797 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1799 break;
1802 case 9:
1803 fprintf (f, "subrange (0x%x) of ", type);
1804 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1805 fprintf (f, " lower ");
1806 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1807 fprintf (f, " upper ");
1808 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1809 break;
1811 case 11:
1813 long value;
1815 fprintf (f, "named type (0x%x) ", type);
1816 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1817 if (value <= 0)
1818 fprintf (f, "[INVALID]");
1819 else
1820 fprintf (f, "\"%.*s\"",
1821 bfd_sym_symbol_name (abfd, value)[0],
1822 &bfd_sym_symbol_name (abfd, value)[1]);
1824 fprintf (f, " (NTE %lu) with type ", value);
1825 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1826 break;
1829 default:
1830 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1831 break;
1834 if (type == (0x40 | 0x6))
1836 /* Vector. */
1837 long n, width, m;
1838 long l;
1839 long i;
1841 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1842 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1843 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1844 /* fprintf (f, "\n "); */
1845 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1846 for (i = 0; i < m; i++)
1848 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1849 if (i != 0)
1850 fprintf (f, " ");
1851 fprintf (f, "%ld", l);
1854 else if (type & 0x40)
1856 /* Other packed type. */
1857 long msb, lsb;
1859 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1860 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1861 /* fprintf (f, "\n "); */
1862 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1865 fprintf (f, "]");
1867 if (offsetptr != NULL)
1868 *offsetptr = offset;
1871 void
1872 bfd_sym_print_type_information_table_entry (abfd, f, entry)
1873 bfd *abfd;
1874 FILE *f;
1875 bfd_sym_type_information_table_entry *entry;
1877 unsigned char *buf;
1878 unsigned long offset;
1879 unsigned int i;
1881 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1882 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1883 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1884 entry->nte_index,
1885 entry->physical_size, entry->offset, entry->logical_size);
1887 fprintf (f, "\n ");
1889 buf = alloca (entry->physical_size);
1890 if (buf == NULL)
1892 fprintf (f, "[ERROR]\n");
1893 return;
1895 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1897 fprintf (f, "[ERROR]\n");
1898 return;
1900 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1902 fprintf (f, "[ERROR]\n");
1903 return;
1906 fprintf (f, "[");
1907 for (i = 0; i < entry->physical_size; i++)
1909 if (i == 0)
1910 fprintf (f, "0x%02x", buf[i]);
1911 else
1912 fprintf (f, " 0x%02x", buf[i]);
1915 fprintf (f, "]");
1916 fprintf (f, "\n ");
1918 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1920 if (offset != entry->physical_size)
1921 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); }
1923 void
1924 bfd_sym_print_file_references_index_table_entry (abfd, f, entry)
1925 bfd *abfd ATTRIBUTE_UNUSED;
1926 FILE *f;
1927 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED;
1929 fprintf (f, "[UNIMPLEMENTED]");
1932 void
1933 bfd_sym_print_constant_pool_entry (abfd, f, entry)
1934 bfd *abfd ATTRIBUTE_UNUSED;
1935 FILE *f;
1936 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED;
1938 fprintf (f, "[UNIMPLEMENTED]");
1941 unsigned char *
1942 bfd_sym_display_name_table_entry (abfd, f, entry)
1943 bfd *abfd;
1944 FILE *f;
1945 unsigned char *entry;
1947 unsigned long index;
1948 unsigned long offset;
1949 bfd_sym_data_struct *sdata = NULL;
1951 BFD_ASSERT (bfd_sym_valid (abfd));
1952 sdata = abfd->tdata.sym_data;
1953 index = (entry - sdata->name_table) / 2;
1955 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1957 unsigned short length = bfd_getb16 (entry + 2);
1958 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
1959 offset = 2 + length + 1;
1961 else
1963 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1964 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
1966 if (sdata->version >= BFD_SYM_VERSION_3_4)
1967 offset = entry[0] + 2;
1968 else
1969 offset = entry[0] + 1;
1972 return (entry + offset + (offset % 2));
1975 void
1976 bfd_sym_display_name_table (abfd, f)
1977 bfd *abfd;
1978 FILE *f;
1980 unsigned long name_table_len;
1981 unsigned char *name_table, *name_table_end, *cur;
1982 bfd_sym_data_struct *sdata = NULL;
1984 BFD_ASSERT (bfd_sym_valid (abfd));
1985 sdata = abfd->tdata.sym_data;
1987 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1988 name_table = sdata->name_table;
1989 name_table_end = name_table + name_table_len;
1991 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1993 cur = name_table;
1994 for (;;)
1996 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1997 if (cur >= name_table_end)
1998 break;
2002 void
2003 bfd_sym_display_resources_table (abfd, f)
2004 bfd *abfd;
2005 FILE *f;
2007 unsigned long i;
2008 bfd_sym_resources_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, "resource table (RTE) contains %lu objects:\n\n",
2015 sdata->header.dshb_rte.dti_object_count);
2017 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
2019 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
2020 fprintf (f, " [%8lu] [INVALID]\n", i);
2021 else
2023 fprintf (f, " [%8lu] ", i);
2024 bfd_sym_print_resources_table_entry (abfd, f, &entry);
2025 fprintf (f, "\n");
2030 void
2031 bfd_sym_display_modules_table (abfd, f)
2032 bfd *abfd;
2033 FILE *f;
2035 unsigned long i;
2036 bfd_sym_modules_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, "module table (MTE) contains %lu objects:\n\n",
2043 sdata->header.dshb_mte.dti_object_count);
2045 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
2047 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
2048 fprintf (f, " [%8lu] [INVALID]\n", i);
2049 else
2051 fprintf (f, " [%8lu] ", i);
2052 bfd_sym_print_modules_table_entry (abfd, f, &entry);
2053 fprintf (f, "\n");
2058 void
2059 bfd_sym_display_file_references_table (abfd, f)
2060 bfd *abfd;
2061 FILE *f;
2063 unsigned long i;
2064 bfd_sym_file_references_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, "file reference table (FRTE) contains %lu objects:\n\n",
2071 sdata->header.dshb_frte.dti_object_count);
2073 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
2075 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
2076 fprintf (f, " [%8lu] [INVALID]\n", i);
2077 else
2079 fprintf (f, " [%8lu] ", i);
2080 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
2081 fprintf (f, "\n");
2086 void
2087 bfd_sym_display_contained_modules_table (abfd, f)
2088 bfd *abfd;
2089 FILE *f;
2091 unsigned long i;
2092 bfd_sym_contained_modules_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 modules table (CMTE) contains %lu objects:\n\n",
2099 sdata->header.dshb_cmte.dti_object_count);
2101 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2103 if (bfd_sym_fetch_contained_modules_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_modules_table_entry (abfd, f, &entry);
2109 fprintf (f, "\n");
2114 void
2115 bfd_sym_display_contained_variables_table (abfd, f)
2116 bfd *abfd;
2117 FILE *f;
2119 unsigned long i;
2120 bfd_sym_contained_variables_table_entry entry;
2121 bfd_sym_data_struct *sdata = NULL;
2123 BFD_ASSERT (bfd_sym_valid (abfd));
2124 sdata = abfd->tdata.sym_data;
2126 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2127 sdata->header.dshb_cvte.dti_object_count);
2129 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2131 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2132 fprintf (f, " [%8lu] [INVALID]\n", i);
2133 else
2135 fprintf (f, " [%8lu] ", i);
2136 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2137 fprintf (f, "\n");
2141 fprintf (f, "\n");
2144 void
2145 bfd_sym_display_contained_statements_table (abfd, f)
2146 bfd *abfd;
2147 FILE *f;
2149 unsigned long i;
2150 bfd_sym_contained_statements_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 statements table (CSNTE) contains %lu objects:\n\n",
2157 sdata->header.dshb_csnte.dti_object_count);
2159 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2161 if (bfd_sym_fetch_contained_statements_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_statements_table_entry (abfd, f, &entry);
2167 fprintf (f, "\n");
2172 void
2173 bfd_sym_display_contained_labels_table (abfd, f)
2174 bfd *abfd;
2175 FILE *f;
2177 unsigned long i;
2178 bfd_sym_contained_labels_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 labels table (CLTE) contains %lu objects:\n\n",
2185 sdata->header.dshb_clte.dti_object_count);
2187 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2189 if (bfd_sym_fetch_contained_labels_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_labels_table_entry (abfd, f, &entry);
2195 fprintf (f, "\n");
2200 void
2201 bfd_sym_display_contained_types_table (abfd, f)
2202 bfd *abfd;
2203 FILE *f;
2205 unsigned long i;
2206 bfd_sym_contained_types_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, "contained types table (CTTE) contains %lu objects:\n\n",
2213 sdata->header.dshb_ctte.dti_object_count);
2215 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2217 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2218 fprintf (f, " [%8lu] [INVALID]\n", i);
2219 else
2221 fprintf (f, " [%8lu] ", i);
2222 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2223 fprintf (f, "\n");
2228 void
2229 bfd_sym_display_file_references_index_table (abfd, f)
2230 bfd *abfd;
2231 FILE *f;
2233 unsigned long i;
2234 bfd_sym_file_references_index_table_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, "file references index table (FITE) contains %lu objects:\n\n",
2241 sdata->header.dshb_fite.dti_object_count);
2243 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2245 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2246 fprintf (f, " [%8lu] [INVALID]\n", i);
2247 else
2249 fprintf (f, " [%8lu] ", i);
2250 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2251 fprintf (f, "\n");
2256 void
2257 bfd_sym_display_constant_pool (abfd, f)
2258 bfd *abfd;
2259 FILE *f;
2261 unsigned long i;
2262 bfd_sym_constant_pool_entry entry;
2263 bfd_sym_data_struct *sdata = NULL;
2265 BFD_ASSERT (bfd_sym_valid (abfd));
2266 sdata = abfd->tdata.sym_data;
2268 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2269 sdata->header.dshb_const.dti_object_count);
2271 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2273 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2274 fprintf (f, " [%8lu] [INVALID]\n", i);
2275 else
2277 fprintf (f, " [%8lu] ", i);
2278 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2279 fprintf (f, "\n");
2284 void
2285 bfd_sym_display_type_information_table (abfd, f)
2286 bfd *abfd;
2287 FILE *f;
2289 unsigned long i;
2290 bfd_sym_type_table_entry index;
2291 bfd_sym_type_information_table_entry entry;
2292 bfd_sym_data_struct *sdata = NULL;
2294 BFD_ASSERT (bfd_sym_valid (abfd));
2295 sdata = abfd->tdata.sym_data;
2297 if (sdata->header.dshb_tte.dti_object_count > 99)
2298 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2299 sdata->header.dshb_tte.dti_object_count - 99);
2300 else
2302 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2303 return;
2306 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2308 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
2309 fprintf (f, " [%8lu] [INVALID]\n", i);
2310 else
2312 fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
2314 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
2315 fprintf (f, "[INVALID]");
2316 else
2317 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2319 fprintf (f, "\n");
2325 bfd_sym_scan (abfd, version, mdata)
2326 bfd *abfd;
2327 bfd_sym_version version;
2328 bfd_sym_data_struct *mdata;
2330 asection *bfdsec;
2331 const char *name = "symbols";
2333 mdata->name_table = 0;
2334 mdata->sbfd = abfd;
2335 mdata->version = version;
2337 bfd_seek (abfd, 0, SEEK_SET);
2338 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2339 return -1;
2341 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2342 if (mdata->name_table == NULL)
2343 return -1;
2345 bfdsec = bfd_make_section_anyway (abfd, name);
2346 if (bfdsec == NULL)
2347 return -1;
2349 bfdsec->vma = 0;
2350 bfdsec->lma = 0;
2351 bfdsec->size = 0;
2352 bfdsec->filepos = 0;
2353 bfdsec->alignment_power = 0;
2355 bfdsec->flags = SEC_HAS_CONTENTS;
2357 abfd->tdata.sym_data = mdata;
2359 return 0;
2362 const bfd_target *
2363 bfd_sym_object_p (abfd)
2364 bfd *abfd;
2366 struct bfd_preserve preserve;
2367 bfd_sym_version version = -1;
2369 preserve.marker = NULL;
2370 bfd_seek (abfd, 0, SEEK_SET);
2371 if (bfd_sym_read_version (abfd, &version) != 0)
2372 goto wrong;
2374 preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
2375 if (preserve.marker == NULL
2376 || ! bfd_preserve_save (abfd, &preserve))
2377 goto fail;
2379 if (bfd_sym_scan (abfd, version,
2380 (bfd_sym_data_struct *) preserve.marker) != 0)
2381 goto wrong;
2383 bfd_preserve_finish (abfd, &preserve);
2384 return abfd->xvec;
2386 wrong:
2387 bfd_set_error (bfd_error_wrong_format);
2389 fail:
2390 if (preserve.marker != NULL)
2391 bfd_preserve_restore (abfd, &preserve);
2392 return NULL;
2395 asymbol *
2396 bfd_sym_make_empty_symbol (abfd)
2397 bfd *abfd;
2399 return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
2402 void
2403 bfd_sym_get_symbol_info (abfd, symbol, ret)
2404 bfd *abfd ATTRIBUTE_UNUSED;
2405 asymbol *symbol;
2406 symbol_info *ret;
2408 bfd_symbol_info (symbol, ret);
2411 long
2412 bfd_sym_get_symtab_upper_bound (abfd)
2413 bfd *abfd ATTRIBUTE_UNUSED;
2415 return 0;
2418 long
2419 bfd_sym_canonicalize_symtab (abfd, sym)
2420 bfd *abfd ATTRIBUTE_UNUSED;
2421 asymbol **sym ATTRIBUTE_UNUSED;
2423 return 0;
2427 bfd_sym_sizeof_headers (abfd, exec)
2428 bfd *abfd ATTRIBUTE_UNUSED;
2429 bfd_boolean exec ATTRIBUTE_UNUSED;
2431 return 0;
2434 const bfd_target sym_vec =
2436 "sym", /* name */
2437 bfd_target_sym_flavour, /* flavour */
2438 BFD_ENDIAN_BIG, /* byteorder */
2439 BFD_ENDIAN_BIG, /* header_byteorder */
2440 (HAS_RELOC | EXEC_P | /* object flags */
2441 HAS_LINENO | HAS_DEBUG |
2442 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2443 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2444 | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
2445 0, /* symbol_leading_char */
2446 ' ', /* ar_pad_char */
2447 16, /* ar_max_namelen */
2448 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2449 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2450 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
2451 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2452 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2453 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
2454 { /* bfd_check_format */
2455 _bfd_dummy_target,
2456 bfd_sym_object_p, /* bfd_check_format */
2457 _bfd_dummy_target,
2458 _bfd_dummy_target,
2460 { /* bfd_set_format */
2461 bfd_false,
2462 bfd_sym_mkobject,
2463 bfd_false,
2464 bfd_false,
2466 { /* bfd_write_contents */
2467 bfd_false,
2468 bfd_true,
2469 bfd_false,
2470 bfd_false,
2473 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2474 BFD_JUMP_TABLE_COPY (_bfd_generic),
2475 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2476 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2477 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2478 BFD_JUMP_TABLE_RELOCS (bfd_sym),
2479 BFD_JUMP_TABLE_WRITE (bfd_sym),
2480 BFD_JUMP_TABLE_LINK (bfd_sym),
2481 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2483 NULL,
2485 NULL