* dlltool.c (dtab): Remove empty function.
[binutils.git] / bfd / xsym.c
blobb54b74c2ac1e210eb988f48177d967217a0483f5
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 _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 extern const bfd_target sym_vec;
59 static int
60 pstrcmp (const char *as, const char *bs)
62 const unsigned char *a = (const unsigned char *) as;
63 const unsigned char *b = (const unsigned char *) bs;
64 unsigned char clen;
65 int ret;
67 clen = (a[0] > b[0]) ? b[0] : a[0];
68 ret = memcmp (a + 1, b + 1, clen);
69 if (ret != 0)
70 return ret;
72 if (a[0] == b[0])
73 return 0;
74 else if (a[0] < b[0])
75 return -1;
76 else
77 return 1;
80 static unsigned long
81 compute_offset (unsigned long first_page,
82 unsigned long page_size,
83 unsigned long entry_size,
84 unsigned long index)
86 unsigned long entries_per_page = page_size / entry_size;
87 unsigned long page_number = first_page + (index / entries_per_page);
88 unsigned long page_offset = (index % entries_per_page) * entry_size;
90 return (page_number * page_size) + page_offset;
93 bfd_boolean
94 bfd_sym_mkobject (bfd *abfd ATTRIBUTE_UNUSED)
96 return 1;
99 void
100 bfd_sym_print_symbol (bfd *abfd ATTRIBUTE_UNUSED,
101 void * afile ATTRIBUTE_UNUSED,
102 asymbol *symbol ATTRIBUTE_UNUSED,
103 bfd_print_symbol_type how ATTRIBUTE_UNUSED)
105 return;
108 bfd_boolean
109 bfd_sym_valid (bfd *abfd)
111 if (abfd == NULL || abfd->xvec == NULL)
112 return 0;
114 return abfd->xvec == &sym_vec;
117 unsigned char *
118 bfd_sym_read_name_table (bfd *abfd, bfd_sym_header_block *dshb)
120 unsigned char *rstr;
121 long ret;
122 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
123 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
125 rstr = bfd_alloc (abfd, table_size);
126 if (rstr == NULL)
127 return rstr;
129 bfd_seek (abfd, table_offset, SEEK_SET);
130 ret = bfd_bread (rstr, table_size, abfd);
131 if (ret < 0 || (unsigned long) ret != table_size)
133 bfd_release (abfd, rstr);
134 return NULL;
137 return rstr;
140 void
141 bfd_sym_parse_file_reference_v32 (unsigned char *buf,
142 size_t len,
143 bfd_sym_file_reference *entry)
145 BFD_ASSERT (len == 6);
147 entry->fref_frte_index = bfd_getb16 (buf);
148 entry->fref_offset = bfd_getb32 (buf + 2);
151 void
152 bfd_sym_parse_disk_table_v32 (unsigned char *buf,
153 size_t len,
154 bfd_sym_table_info *table)
156 BFD_ASSERT (len == 8);
158 table->dti_first_page = bfd_getb16 (buf);
159 table->dti_page_count = bfd_getb16 (buf + 2);
160 table->dti_object_count = bfd_getb32 (buf + 4);
163 void
164 bfd_sym_parse_header_v32 (unsigned char *buf,
165 size_t len,
166 bfd_sym_header_block *header)
168 BFD_ASSERT (len == 154);
170 memcpy (header->dshb_id, buf, 32);
171 header->dshb_page_size = bfd_getb16 (buf + 32);
172 header->dshb_hash_page = bfd_getb16 (buf + 34);
173 header->dshb_root_mte = bfd_getb16 (buf + 36);
174 header->dshb_mod_date = bfd_getb32 (buf + 38);
176 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
177 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
178 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
179 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
180 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
181 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
182 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
183 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
184 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
185 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
186 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
187 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
188 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
190 memcpy (&header->dshb_file_creator, buf + 146, 4);
191 memcpy (&header->dshb_file_type, buf + 150, 4);
195 bfd_sym_read_header_v32 (bfd *abfd, bfd_sym_header_block *header)
197 unsigned char buf[154];
198 long ret;
200 ret = bfd_bread (buf, 154, abfd);
201 if (ret != 154)
202 return -1;
204 bfd_sym_parse_header_v32 (buf, 154, header);
206 return 0;
210 bfd_sym_read_header_v34 (bfd *abfd ATTRIBUTE_UNUSED,
211 bfd_sym_header_block *header ATTRIBUTE_UNUSED)
213 abort ();
217 bfd_sym_read_header (bfd *abfd,
218 bfd_sym_header_block *header,
219 bfd_sym_version version)
221 switch (version)
223 case BFD_SYM_VERSION_3_5:
224 case BFD_SYM_VERSION_3_4:
225 return bfd_sym_read_header_v34 (abfd, header);
226 case BFD_SYM_VERSION_3_3:
227 case BFD_SYM_VERSION_3_2:
228 return bfd_sym_read_header_v32 (abfd, header);
229 case BFD_SYM_VERSION_3_1:
230 default:
231 return 0;
236 bfd_sym_read_version (bfd *abfd, bfd_sym_version *version)
238 char version_string[32];
239 long ret;
241 ret = bfd_bread (version_string, sizeof (version_string), abfd);
242 if (ret != sizeof (version_string))
243 return -1;
245 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
246 *version = BFD_SYM_VERSION_3_1;
247 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
248 *version = BFD_SYM_VERSION_3_2;
249 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
250 *version = BFD_SYM_VERSION_3_3;
251 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
252 *version = BFD_SYM_VERSION_3_4;
253 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
254 *version = BFD_SYM_VERSION_3_5;
255 else
256 return -1;
258 return 0;
261 void
262 bfd_sym_display_table_summary (FILE *f,
263 bfd_sym_table_info *dti,
264 const char *name)
266 fprintf (f, "%-6s %13ld %13ld %13ld\n",
267 name,
268 dti->dti_first_page,
269 dti->dti_page_count,
270 dti->dti_object_count);
273 void
274 bfd_sym_display_header (FILE *f, bfd_sym_header_block *dshb)
276 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
277 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
278 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
279 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
280 fprintf (f, " Modification Date: ");
281 fprintf (f, "[unimplemented]");
282 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
284 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
285 dshb->dshb_file_creator, dshb->dshb_file_type);
287 fprintf (f, "Table Name First Page Page Count Object Count\n");
288 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
290 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
291 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
292 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
293 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
294 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
295 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
296 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
297 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
298 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
299 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
300 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
301 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
302 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
304 fprintf (f, "\n");
307 void
308 bfd_sym_parse_resources_table_entry_v32 (unsigned char *buf,
309 size_t len,
310 bfd_sym_resources_table_entry *entry)
312 BFD_ASSERT (len == 18);
314 memcpy (&entry->rte_res_type, buf, 4);
315 entry->rte_res_number = bfd_getb16 (buf + 4);
316 entry->rte_nte_index = bfd_getb32 (buf + 6);
317 entry->rte_mte_first = bfd_getb16 (buf + 10);
318 entry->rte_mte_last = bfd_getb16 (buf + 12);
319 entry->rte_res_size = bfd_getb32 (buf + 14);
322 void
323 bfd_sym_parse_modules_table_entry_v33 (unsigned char *buf,
324 size_t len,
325 bfd_sym_modules_table_entry *entry)
327 BFD_ASSERT (len == 46);
329 entry->mte_rte_index = bfd_getb16 (buf);
330 entry->mte_res_offset = bfd_getb32 (buf + 2);
331 entry->mte_size = bfd_getb32 (buf + 6);
332 entry->mte_kind = buf[10];
333 entry->mte_scope = buf[11];
334 entry->mte_parent = bfd_getb16 (buf + 12);
335 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
336 entry->mte_imp_end = bfd_getb32 (buf + 20);
337 entry->mte_nte_index = bfd_getb32 (buf + 24);
338 entry->mte_cmte_index = bfd_getb16 (buf + 28);
339 entry->mte_cvte_index = bfd_getb32 (buf + 30);
340 entry->mte_clte_index = bfd_getb16 (buf + 34);
341 entry->mte_ctte_index = bfd_getb16 (buf + 36);
342 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
343 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
346 void
347 bfd_sym_parse_file_references_table_entry_v32 (unsigned char *buf,
348 size_t len,
349 bfd_sym_file_references_table_entry *entry)
351 unsigned int type;
353 BFD_ASSERT (len == 10);
355 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
356 type = bfd_getb16 (buf);
358 switch (type)
360 case BFD_SYM_END_OF_LIST_3_2:
361 entry->generic.type = BFD_SYM_END_OF_LIST;
362 break;
364 case BFD_SYM_FILE_NAME_INDEX_3_2:
365 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
366 entry->filename.nte_index = bfd_getb32 (buf + 2);
367 entry->filename.mod_date = bfd_getb32 (buf + 6);
368 break;
370 default:
371 entry->entry.mte_index = type;
372 entry->entry.file_offset = bfd_getb32 (buf + 2);
376 void
377 bfd_sym_parse_contained_modules_table_entry_v32 (unsigned char *buf,
378 size_t len,
379 bfd_sym_contained_modules_table_entry *entry)
381 unsigned int type;
383 BFD_ASSERT (len == 6);
385 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
386 type = bfd_getb16 (buf);
388 switch (type)
390 case BFD_SYM_END_OF_LIST_3_2:
391 entry->generic.type = BFD_SYM_END_OF_LIST;
392 break;
394 default:
395 entry->entry.mte_index = type;
396 entry->entry.nte_index = bfd_getb32 (buf + 2);
397 break;
401 void
402 bfd_sym_parse_contained_variables_table_entry_v32 (unsigned char *buf,
403 size_t len,
404 bfd_sym_contained_variables_table_entry *entry)
406 unsigned int type;
408 BFD_ASSERT (len == 26);
410 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
411 type = bfd_getb16 (buf);
413 switch (type)
415 case BFD_SYM_END_OF_LIST_3_2:
416 entry->generic.type = BFD_SYM_END_OF_LIST;
417 break;
419 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
420 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
421 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
422 break;
424 default:
425 entry->entry.tte_index = type;
426 entry->entry.nte_index = bfd_getb32 (buf + 2);
427 entry->entry.file_delta = bfd_getb16 (buf + 6);
428 entry->entry.scope = buf[8];
429 entry->entry.la_size = buf[9];
431 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
433 entry->entry.address.scstruct.sca_kind = buf[10];
434 entry->entry.address.scstruct.sca_class = buf[11];
435 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
437 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
439 #if BFD_SYM_CVTE_SCA > 0
440 memcpy (&entry->entry.address.lastruct.la, buf + 10,
441 BFD_SYM_CVTE_SCA);
442 #endif
443 entry->entry.address.lastruct.la_kind = buf[23];
445 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
447 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
448 entry->entry.address.biglastruct.big_la_kind = buf[12];
453 void
454 bfd_sym_parse_contained_statements_table_entry_v32 (unsigned char *buf,
455 size_t len,
456 bfd_sym_contained_statements_table_entry *entry)
458 unsigned int type;
460 BFD_ASSERT (len == 8);
462 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
463 type = bfd_getb16 (buf);
465 switch (type)
467 case BFD_SYM_END_OF_LIST_3_2:
468 entry->generic.type = BFD_SYM_END_OF_LIST;
469 break;
471 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
472 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
473 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
474 break;
476 default:
477 entry->entry.mte_index = type;
478 entry->entry.mte_offset = bfd_getb16 (buf + 2);
479 entry->entry.file_delta = bfd_getb32 (buf + 4);
480 break;
484 void
485 bfd_sym_parse_contained_labels_table_entry_v32 (unsigned char *buf,
486 size_t len,
487 bfd_sym_contained_labels_table_entry *entry)
489 unsigned int type;
491 BFD_ASSERT (len == 12);
493 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
494 type = bfd_getb16 (buf);
496 switch (type)
498 case BFD_SYM_END_OF_LIST_3_2:
499 entry->generic.type = BFD_SYM_END_OF_LIST;
500 break;
502 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
503 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
504 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
505 break;
507 default:
508 entry->entry.mte_index = type;
509 entry->entry.mte_offset = bfd_getb16 (buf + 2);
510 entry->entry.nte_index = bfd_getb32 (buf + 4);
511 entry->entry.file_delta = bfd_getb16 (buf + 8);
512 entry->entry.scope = bfd_getb16 (buf + 10);
513 break;
517 void
518 bfd_sym_parse_type_table_entry_v32 (unsigned char *buf,
519 size_t len,
520 bfd_sym_type_table_entry *entry)
522 BFD_ASSERT (len == 4);
524 *entry = bfd_getb32 (buf);
528 bfd_sym_fetch_resources_table_entry (bfd *abfd,
529 bfd_sym_resources_table_entry *entry,
530 unsigned long index)
532 void (*parser) (unsigned char *, size_t, bfd_sym_resources_table_entry *);
533 unsigned long offset;
534 unsigned long entry_size;
535 unsigned char buf[18];
536 bfd_sym_data_struct *sdata = NULL;
538 parser = NULL;
539 BFD_ASSERT (bfd_sym_valid (abfd));
540 sdata = abfd->tdata.sym_data;
542 if (index == 0)
543 return -1;
545 switch (sdata->version)
547 case BFD_SYM_VERSION_3_5:
548 case BFD_SYM_VERSION_3_4:
549 return -1;
551 case BFD_SYM_VERSION_3_3:
552 case BFD_SYM_VERSION_3_2:
553 entry_size = 18;
554 parser = bfd_sym_parse_resources_table_entry_v32;
555 break;
557 case BFD_SYM_VERSION_3_1:
558 default:
559 return -1;
561 if (parser == NULL)
562 return -1;
564 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
565 sdata->header.dshb_page_size,
566 entry_size, index);
568 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
569 return -1;
570 if (bfd_bread (buf, entry_size, abfd) != entry_size)
571 return -1;
573 (*parser) (buf, entry_size, entry);
575 return 0;
579 bfd_sym_fetch_modules_table_entry (bfd *abfd,
580 bfd_sym_modules_table_entry *entry,
581 unsigned long index)
583 void (*parser) (unsigned char *, size_t, bfd_sym_modules_table_entry *);
584 unsigned long offset;
585 unsigned long entry_size;
586 unsigned char buf[46];
587 bfd_sym_data_struct *sdata = NULL;
589 parser = NULL;
590 BFD_ASSERT (bfd_sym_valid (abfd));
591 sdata = abfd->tdata.sym_data;
593 if (index == 0)
594 return -1;
596 switch (sdata->version)
598 case BFD_SYM_VERSION_3_5:
599 case BFD_SYM_VERSION_3_4:
600 return -1;
602 case BFD_SYM_VERSION_3_3:
603 entry_size = 46;
604 parser = bfd_sym_parse_modules_table_entry_v33;
605 break;
607 case BFD_SYM_VERSION_3_2:
608 case BFD_SYM_VERSION_3_1:
609 default:
610 return -1;
612 if (parser == NULL)
613 return -1;
615 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
616 sdata->header.dshb_page_size,
617 entry_size, index);
619 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
620 return -1;
621 if (bfd_bread (buf, entry_size, abfd) != entry_size)
622 return -1;
624 (*parser) (buf, entry_size, entry);
626 return 0;
630 bfd_sym_fetch_file_references_table_entry (bfd *abfd,
631 bfd_sym_file_references_table_entry *entry,
632 unsigned long index)
634 void (*parser) (unsigned char *, size_t, bfd_sym_file_references_table_entry *);
635 unsigned long offset;
636 unsigned long entry_size = 0;
637 unsigned char buf[8];
638 bfd_sym_data_struct *sdata = NULL;
640 parser = NULL;
641 BFD_ASSERT (bfd_sym_valid (abfd));
642 sdata = abfd->tdata.sym_data;
644 if (index == 0)
645 return -1;
647 switch (sdata->version)
649 case BFD_SYM_VERSION_3_3:
650 case BFD_SYM_VERSION_3_2:
651 entry_size = 10;
652 parser = bfd_sym_parse_file_references_table_entry_v32;
653 break;
655 case BFD_SYM_VERSION_3_5:
656 case BFD_SYM_VERSION_3_4:
657 case BFD_SYM_VERSION_3_1:
658 default:
659 break;
662 if (parser == NULL)
663 return -1;
665 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
666 sdata->header.dshb_page_size,
667 entry_size, index);
669 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
670 return -1;
671 if (bfd_bread (buf, entry_size, abfd) != entry_size)
672 return -1;
674 (*parser) (buf, entry_size, entry);
676 return 0;
680 bfd_sym_fetch_contained_modules_table_entry (bfd *abfd,
681 bfd_sym_contained_modules_table_entry *entry,
682 unsigned long index)
684 void (*parser) (unsigned char *, size_t, bfd_sym_contained_modules_table_entry *);
685 unsigned long offset;
686 unsigned long entry_size = 0;
687 unsigned char buf[6];
688 bfd_sym_data_struct *sdata = NULL;
690 parser = NULL;
691 BFD_ASSERT (bfd_sym_valid (abfd));
692 sdata = abfd->tdata.sym_data;
694 if (index == 0)
695 return -1;
697 switch (sdata->version)
699 case BFD_SYM_VERSION_3_3:
700 case BFD_SYM_VERSION_3_2:
701 entry_size = 6;
702 parser = bfd_sym_parse_contained_modules_table_entry_v32;
703 break;
705 case BFD_SYM_VERSION_3_5:
706 case BFD_SYM_VERSION_3_4:
707 case BFD_SYM_VERSION_3_1:
708 default:
709 break;
712 if (parser == NULL)
713 return -1;
715 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
716 sdata->header.dshb_page_size,
717 entry_size, index);
719 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
720 return -1;
721 if (bfd_bread (buf, entry_size, abfd) != entry_size)
722 return -1;
724 (*parser) (buf, entry_size, entry);
726 return 0;
730 bfd_sym_fetch_contained_variables_table_entry (bfd *abfd,
731 bfd_sym_contained_variables_table_entry *entry,
732 unsigned long index)
734 void (*parser) (unsigned char *, size_t, bfd_sym_contained_variables_table_entry *);
735 unsigned long offset;
736 unsigned long entry_size = 0;
737 unsigned char buf[26];
738 bfd_sym_data_struct *sdata = NULL;
740 parser = NULL;
741 BFD_ASSERT (bfd_sym_valid (abfd));
742 sdata = abfd->tdata.sym_data;
744 if (index == 0)
745 return -1;
747 switch (sdata->version)
749 case BFD_SYM_VERSION_3_3:
750 case BFD_SYM_VERSION_3_2:
751 entry_size = 26;
752 parser = bfd_sym_parse_contained_variables_table_entry_v32;
753 break;
755 case BFD_SYM_VERSION_3_5:
756 case BFD_SYM_VERSION_3_4:
757 case BFD_SYM_VERSION_3_1:
758 default:
759 break;
762 if (parser == NULL)
763 return -1;
765 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
766 sdata->header.dshb_page_size,
767 entry_size, index);
769 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
770 return -1;
771 if (bfd_bread (buf, entry_size, abfd) != entry_size)
772 return -1;
774 (*parser) (buf, entry_size, entry);
776 return 0;
780 bfd_sym_fetch_contained_statements_table_entry (bfd *abfd,
781 bfd_sym_contained_statements_table_entry *entry,
782 unsigned long index)
784 void (*parser) (unsigned char *, size_t, bfd_sym_contained_statements_table_entry *);
785 unsigned long offset;
786 unsigned long entry_size = 0;
787 unsigned char buf[8];
788 bfd_sym_data_struct *sdata = NULL;
790 parser = NULL;
791 BFD_ASSERT (bfd_sym_valid (abfd));
792 sdata = abfd->tdata.sym_data;
794 if (index == 0)
795 return -1;
797 switch (sdata->version)
799 case BFD_SYM_VERSION_3_3:
800 case BFD_SYM_VERSION_3_2:
801 entry_size = 8;
802 parser = bfd_sym_parse_contained_statements_table_entry_v32;
803 break;
805 case BFD_SYM_VERSION_3_5:
806 case BFD_SYM_VERSION_3_4:
807 case BFD_SYM_VERSION_3_1:
808 default:
809 break;
812 if (parser == NULL)
813 return -1;
815 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
816 sdata->header.dshb_page_size,
817 entry_size, index);
819 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
820 return -1;
821 if (bfd_bread (buf, entry_size, abfd) != entry_size)
822 return -1;
824 (*parser) (buf, entry_size, entry);
826 return 0;
830 bfd_sym_fetch_contained_labels_table_entry (bfd *abfd,
831 bfd_sym_contained_labels_table_entry *entry,
832 unsigned long index)
834 void (*parser) (unsigned char *, size_t, bfd_sym_contained_labels_table_entry *);
835 unsigned long offset;
836 unsigned long entry_size = 0;
837 unsigned char buf[12];
838 bfd_sym_data_struct *sdata = NULL;
840 parser = NULL;
841 BFD_ASSERT (bfd_sym_valid (abfd));
842 sdata = abfd->tdata.sym_data;
844 if (index == 0)
845 return -1;
847 switch (sdata->version)
849 case BFD_SYM_VERSION_3_3:
850 case BFD_SYM_VERSION_3_2:
851 entry_size = 12;
852 parser = bfd_sym_parse_contained_labels_table_entry_v32;
853 break;
855 case BFD_SYM_VERSION_3_5:
856 case BFD_SYM_VERSION_3_4:
857 case BFD_SYM_VERSION_3_1:
858 default:
859 break;
862 if (parser == NULL)
863 return -1;
865 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
866 sdata->header.dshb_page_size,
867 entry_size, index);
869 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
870 return -1;
871 if (bfd_bread (buf, entry_size, abfd) != entry_size)
872 return -1;
874 (*parser) (buf, entry_size, entry);
876 return 0;
880 bfd_sym_fetch_contained_types_table_entry (bfd *abfd,
881 bfd_sym_contained_types_table_entry *entry,
882 unsigned long index)
884 void (*parser) (unsigned char *, size_t, bfd_sym_contained_types_table_entry *);
885 unsigned long offset;
886 unsigned long entry_size = 0;
887 unsigned char buf[0];
888 bfd_sym_data_struct *sdata = NULL;
890 parser = NULL;
891 BFD_ASSERT (bfd_sym_valid (abfd));
892 sdata = abfd->tdata.sym_data;
894 if (index == 0)
895 return -1;
897 switch (sdata->version)
899 case BFD_SYM_VERSION_3_3:
900 case BFD_SYM_VERSION_3_2:
901 entry_size = 0;
902 parser = NULL;
903 break;
905 case BFD_SYM_VERSION_3_5:
906 case BFD_SYM_VERSION_3_4:
907 case BFD_SYM_VERSION_3_1:
908 default:
909 break;
912 if (parser == NULL)
913 return -1;
915 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
916 sdata->header.dshb_page_size,
917 entry_size, index);
919 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
920 return -1;
921 if (bfd_bread (buf, entry_size, abfd) != entry_size)
922 return -1;
924 (*parser) (buf, entry_size, entry);
926 return 0;
930 bfd_sym_fetch_file_references_index_table_entry (bfd *abfd,
931 bfd_sym_file_references_index_table_entry *entry,
932 unsigned long index)
934 void (*parser) (unsigned char *, size_t, bfd_sym_file_references_index_table_entry *);
935 unsigned long offset;
936 unsigned long entry_size = 0;
937 unsigned char buf[0];
938 bfd_sym_data_struct *sdata = NULL;
940 parser = NULL;
941 BFD_ASSERT (bfd_sym_valid (abfd));
942 sdata = abfd->tdata.sym_data;
944 if (index == 0)
945 return -1;
947 switch (sdata->version)
949 case BFD_SYM_VERSION_3_3:
950 case BFD_SYM_VERSION_3_2:
951 entry_size = 0;
952 parser = NULL;
953 break;
955 case BFD_SYM_VERSION_3_5:
956 case BFD_SYM_VERSION_3_4:
957 case BFD_SYM_VERSION_3_1:
958 default:
959 break;
962 if (parser == NULL)
963 return -1;
965 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
966 sdata->header.dshb_page_size,
967 entry_size, index);
969 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
970 return -1;
971 if (bfd_bread (buf, entry_size, abfd) != entry_size)
972 return -1;
974 (*parser) (buf, entry_size, entry);
976 return 0;
980 bfd_sym_fetch_constant_pool_entry (bfd *abfd,
981 bfd_sym_constant_pool_entry *entry,
982 unsigned long index)
984 void (*parser) (unsigned char *, size_t, bfd_sym_constant_pool_entry *);
985 unsigned long offset;
986 unsigned long entry_size = 0;
987 unsigned char buf[0];
988 bfd_sym_data_struct *sdata = NULL;
990 parser = NULL;
991 BFD_ASSERT (bfd_sym_valid (abfd));
992 sdata = abfd->tdata.sym_data;
994 if (index == 0)
995 return -1;
997 switch (sdata->version)
999 case BFD_SYM_VERSION_3_3:
1000 case BFD_SYM_VERSION_3_2:
1001 entry_size = 0;
1002 parser = NULL;
1003 break;
1005 case BFD_SYM_VERSION_3_5:
1006 case BFD_SYM_VERSION_3_4:
1007 case BFD_SYM_VERSION_3_1:
1008 default:
1009 break;
1012 if (parser == NULL)
1013 return -1;
1015 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1016 sdata->header.dshb_page_size,
1017 entry_size, index);
1019 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1020 return -1;
1021 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1022 return -1;
1024 (*parser) (buf, entry_size, entry);
1026 return 0;
1030 bfd_sym_fetch_type_table_entry (bfd *abfd,
1031 bfd_sym_type_table_entry *entry,
1032 unsigned long index)
1034 void (*parser) (unsigned char *, size_t, bfd_sym_type_table_entry *);
1035 unsigned long offset;
1036 unsigned long entry_size = 0;
1037 unsigned char buf[4];
1038 bfd_sym_data_struct *sdata = NULL;
1040 parser = NULL;
1041 BFD_ASSERT (bfd_sym_valid (abfd));
1042 sdata = abfd->tdata.sym_data;
1044 switch (sdata->version)
1046 case BFD_SYM_VERSION_3_3:
1047 case BFD_SYM_VERSION_3_2:
1048 entry_size = 4;
1049 parser = bfd_sym_parse_type_table_entry_v32;
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_tte.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_information_table_entry (bfd *abfd,
1078 bfd_sym_type_information_table_entry *entry,
1079 unsigned long offset)
1081 unsigned char buf[4];
1082 bfd_sym_data_struct *sdata = NULL;
1084 BFD_ASSERT (bfd_sym_valid (abfd));
1085 sdata = abfd->tdata.sym_data;
1087 if (offset == 0)
1088 return -1;
1090 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1091 return -1;
1093 if (bfd_bread (buf, 4, abfd) != 4)
1094 return -1;
1095 entry->nte_index = bfd_getb32 (buf);
1097 if (bfd_bread (buf, 2, abfd) != 2)
1098 return -1;
1099 entry->physical_size = bfd_getb16 (buf);
1101 if (entry->physical_size & 0x8000)
1103 if (bfd_bread (buf, 4, abfd) != 4)
1104 return -1;
1105 entry->physical_size &= 0x7fff;
1106 entry->logical_size = bfd_getb32 (buf);
1107 entry->offset = offset + 10;
1109 else
1111 if (bfd_bread (buf, 2, abfd) != 2)
1112 return -1;
1113 entry->physical_size &= 0x7fff;
1114 entry->logical_size = bfd_getb16 (buf);
1115 entry->offset = offset + 8;
1118 return 0;
1122 bfd_sym_fetch_type_table_information (bfd *abfd,
1123 bfd_sym_type_information_table_entry *entry,
1124 unsigned long index)
1126 bfd_sym_type_table_entry tindex;
1127 bfd_sym_data_struct *sdata = NULL;
1129 BFD_ASSERT (bfd_sym_valid (abfd));
1130 sdata = abfd->tdata.sym_data;
1132 if (sdata->header.dshb_tte.dti_object_count <= 99)
1133 return -1;
1134 if (index < 100)
1135 return -1;
1137 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
1138 return -1;
1139 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1140 return -1;
1142 return 0;
1145 const unsigned char *
1146 bfd_sym_symbol_name (bfd *abfd, unsigned long index)
1148 bfd_sym_data_struct *sdata = NULL;
1150 BFD_ASSERT (bfd_sym_valid (abfd));
1151 sdata = abfd->tdata.sym_data;
1153 if (index == 0)
1154 return (const unsigned char *) "";
1156 index *= 2;
1157 if ((index / sdata->header.dshb_page_size)
1158 > sdata->header.dshb_nte.dti_page_count)
1159 return (const unsigned char *) "\09[INVALID]";
1161 return (const unsigned char *) sdata->name_table + index;
1164 const unsigned char *
1165 bfd_sym_module_name (bfd *abfd, unsigned long index)
1167 bfd_sym_modules_table_entry entry;
1169 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
1170 return (const unsigned char *) "\09[INVALID]";
1172 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1175 const char *
1176 bfd_sym_unparse_storage_kind (enum bfd_sym_storage_kind kind)
1178 switch (kind)
1180 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1181 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1182 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1183 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1184 default: return "[UNKNOWN]";
1188 const char *
1189 bfd_sym_unparse_storage_class (enum bfd_sym_storage_class kind)
1191 switch (kind)
1193 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1194 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1195 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1196 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1197 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1198 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1199 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1200 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1201 default: return "[UNKNOWN]";
1205 const char *
1206 bfd_sym_unparse_module_kind (enum bfd_sym_module_kind kind)
1208 switch (kind)
1210 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1211 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1212 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1213 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1214 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1215 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1216 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1217 default: return "[UNKNOWN]";
1221 const char *
1222 bfd_sym_unparse_symbol_scope (enum bfd_sym_symbol_scope scope)
1224 switch (scope)
1226 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1227 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1228 default:
1229 return "[UNKNOWN]";
1233 void
1234 bfd_sym_print_file_reference (bfd *abfd,
1235 FILE *f,
1236 bfd_sym_file_reference *entry)
1238 bfd_sym_file_references_table_entry frtentry;
1239 int ret;
1241 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1242 entry->fref_frte_index);
1243 fprintf (f, "FILE ");
1245 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1246 fprintf (f, "[INVALID]");
1247 else
1248 fprintf (f, "\"%.*s\"",
1249 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1250 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1252 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1255 void
1256 bfd_sym_print_resources_table_entry (bfd *abfd,
1257 FILE *f,
1258 bfd_sym_resources_table_entry *entry)
1260 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1261 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1262 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1263 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1264 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1267 void
1268 bfd_sym_print_modules_table_entry (bfd *abfd,
1269 FILE *f,
1270 bfd_sym_modules_table_entry *entry)
1272 fprintf (f, "\"%.*s\" (NTE %lu)",
1273 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1274 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1275 entry->mte_nte_index);
1277 fprintf (f, "\n ");
1279 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1280 fprintf (f, " range %lu -- %lu",
1281 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1283 fprintf (f, "\n ");
1285 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1286 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1288 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1289 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1291 fprintf (f, "\n ");
1293 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1294 entry->mte_cmte_index, entry->mte_cvte_index,
1295 entry->mte_clte_index, entry->mte_ctte_index,
1296 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1298 if (entry->mte_parent != 0)
1299 fprintf (f, ", parent %lu", entry->mte_parent);
1300 else
1301 fprintf (f, ", no parent");
1303 if (entry->mte_cmte_index != 0)
1304 fprintf (f, ", child %lu", entry->mte_cmte_index);
1305 else
1306 fprintf (f, ", no child");
1309 void
1310 bfd_sym_print_file_references_table_entry (bfd *abfd,
1311 FILE *f,
1312 bfd_sym_file_references_table_entry *entry)
1314 switch (entry->generic.type)
1316 case BFD_SYM_FILE_NAME_INDEX:
1317 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1318 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1319 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1320 entry->filename.nte_index);
1322 fprintf (f, "[UNIMPLEMENTED]");
1323 /* printModDate (entry->filename.mod_date); */
1324 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1325 break;
1327 case BFD_SYM_END_OF_LIST:
1328 fprintf (f, "END");
1329 break;
1331 default:
1332 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1333 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1334 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1335 entry->entry.mte_index,
1336 entry->entry.file_offset);
1337 break;
1341 void
1342 bfd_sym_print_contained_modules_table_entry (bfd *abfd,
1343 FILE *f,
1344 bfd_sym_contained_modules_table_entry *entry)
1346 switch (entry->generic.type)
1348 case BFD_SYM_END_OF_LIST:
1349 fprintf (f, "END");
1350 break;
1352 default:
1353 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
1354 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1355 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1356 entry->entry.mte_index,
1357 entry->entry.nte_index);
1358 break;
1362 void
1363 bfd_sym_print_contained_variables_table_entry (bfd *abfd,
1364 FILE *f,
1365 bfd_sym_contained_variables_table_entry *entry)
1367 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1369 fprintf (f, "END");
1370 return;
1373 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1375 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1376 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1377 return;
1380 fprintf (f, "\"%.*s\" (NTE %lu)",
1381 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1382 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1383 entry->entry.nte_index);
1385 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1386 fprintf (f, ", offset %lu", entry->entry.file_delta);
1387 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1389 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1390 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1391 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1392 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1393 entry->entry.address.scstruct.sca_offset);
1394 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1396 unsigned long i;
1398 fprintf (f, ", la [");
1399 for (i = 0; i < entry->entry.la_size; i++)
1400 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1401 fprintf (f, "]");
1403 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1404 fprintf (f, ", bigla %lu, biglakind %u",
1405 entry->entry.address.biglastruct.big_la,
1406 entry->entry.address.biglastruct.big_la_kind);
1408 else
1409 fprintf (f, ", la [INVALID]");
1412 void
1413 bfd_sym_print_contained_statements_table_entry (bfd *abfd,
1414 FILE *f,
1415 bfd_sym_contained_statements_table_entry *entry)
1417 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1419 fprintf (f, "END");
1420 return;
1423 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1425 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1426 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1427 return;
1430 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1431 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1432 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1433 entry->entry.mte_index,
1434 entry->entry.mte_offset,
1435 entry->entry.file_delta);
1438 void
1439 bfd_sym_print_contained_labels_table_entry (bfd *abfd,
1440 FILE *f,
1441 bfd_sym_contained_labels_table_entry *entry)
1443 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1445 fprintf (f, "END");
1446 return;
1449 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1451 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1452 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1453 return;
1456 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1457 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1458 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1459 entry->entry.mte_index,
1460 entry->entry.mte_offset,
1461 entry->entry.file_delta,
1462 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1465 void
1466 bfd_sym_print_contained_types_table_entry (bfd *abfd ATTRIBUTE_UNUSED,
1467 FILE *f,
1468 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED)
1470 fprintf (f, "[UNIMPLEMENTED]");
1473 const char *
1474 bfd_sym_type_operator_name (unsigned char num)
1476 switch (num)
1478 case 1: return "TTE";
1479 case 2: return "PointerTo";
1480 case 3: return "ScalarOf";
1481 case 4: return "ConstantOf";
1482 case 5: return "EnumerationOf";
1483 case 6: return "VectorOf";
1484 case 7: return "RecordOf";
1485 case 8: return "UnionOf";
1486 case 9: return "SubRangeOf";
1487 case 10: return "SetOf";
1488 case 11: return "NamedTypeOf";
1489 case 12: return "ProcOf";
1490 case 13: return "ValueOf";
1491 case 14: return "ArrayOf";
1492 default: return "[UNKNOWN OPERATOR]";
1496 const char *
1497 bfd_sym_type_basic_name (unsigned char num)
1499 switch (num)
1501 case 0: return "void";
1502 case 1: return "pascal string";
1503 case 2: return "unsigned long";
1504 case 3: return "signed long";
1505 case 4: return "extended (10 bytes)";
1506 case 5: return "pascal boolean (1 byte)";
1507 case 6: return "unsigned byte";
1508 case 7: return "signed byte";
1509 case 8: return "character (1 byte)";
1510 case 9: return "wide character (2 bytes)";
1511 case 10: return "unsigned short";
1512 case 11: return "signed short";
1513 case 12: return "singled";
1514 case 13: return "double";
1515 case 14: return "extended (12 bytes)";
1516 case 15: return "computational (8 bytes)";
1517 case 16: return "c string";
1518 case 17: return "as-is string";
1519 default: return "[UNKNOWN BASIC TYPE]";
1524 bfd_sym_fetch_long (unsigned char *buf,
1525 unsigned long len,
1526 unsigned long offset,
1527 unsigned long *offsetptr,
1528 long *value)
1530 int ret;
1532 if (offset >= len)
1534 *value = 0;
1535 offset += 0;
1536 ret = -1;
1538 else if (! (buf[offset] & 0x80))
1540 *value = buf[offset];
1541 offset += 1;
1542 ret = 0;
1544 else if (buf[offset] == 0xc0)
1546 if ((offset + 5) > len)
1548 *value = 0;
1549 offset = len;
1550 ret = -1;
1552 else
1554 *value = bfd_getb32 (buf + offset + 1);
1555 offset += 5;
1556 ret = 0;
1559 else if ((buf[offset] & 0xc0) == 0xc0)
1561 *value = -(buf[offset] & 0x3f);
1562 offset += 1;
1563 ret = 0;
1565 else if ((buf[offset] & 0xc0) == 0x80)
1567 if ((offset + 2) > len)
1569 *value = 0;
1570 offset = len;
1571 ret = -1;
1573 else
1575 *value = bfd_getb16 (buf + offset) & 0x3fff;
1576 offset += 2;
1577 ret = 0;
1580 else
1581 abort ();
1583 if (offsetptr != NULL)
1584 *offsetptr = offset;
1586 return ret;
1589 void
1590 bfd_sym_print_type_information (bfd *abfd,
1591 FILE *f,
1592 unsigned char *buf,
1593 unsigned long len,
1594 unsigned long offset,
1595 unsigned long *offsetptr)
1597 unsigned int type;
1599 if (offset >= len)
1601 fprintf (f, "[NULL]");
1603 if (offsetptr != NULL)
1604 *offsetptr = offset;
1605 return;
1608 type = buf[offset];
1609 offset++;
1611 if (! (type & 0x80))
1613 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1615 if (offsetptr != NULL)
1616 *offsetptr = offset;
1617 return;
1620 if (type & 0x40)
1621 fprintf (f, "[packed ");
1622 else
1623 fprintf (f, "[");
1625 switch (type & 0x3f)
1627 case 1:
1629 long value;
1630 bfd_sym_type_information_table_entry tinfo;
1632 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1633 if (value <= 0)
1634 fprintf (f, "[INVALID]");
1635 else
1637 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1638 fprintf (f, "[INVALID]");
1639 else
1640 fprintf (f, "\"%.*s\"",
1641 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1642 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1644 fprintf (f, " (TTE %lu)", value);
1645 break;
1648 case 2:
1649 fprintf (f, "pointer (0x%x) to ", type);
1650 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1651 break;
1653 case 3:
1655 long value;
1657 fprintf (f, "scalar (0x%x) of ", type);
1658 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1659 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1660 fprintf (f, " (%lu)", (unsigned long) value);
1661 break;
1664 case 5:
1666 long lower, upper, nelem;
1667 int i;
1669 fprintf (f, "enumeration (0x%x) of ", type);
1670 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1671 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1672 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1673 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1674 fprintf (f, " from %lu to %lu with %lu elements: ",
1675 (unsigned long) lower, (unsigned long) upper,
1676 (unsigned long) nelem);
1678 for (i = 0; i < nelem; i++)
1680 fprintf (f, "\n ");
1681 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1683 break;
1686 case 6:
1687 fprintf (f, "vector (0x%x)", type);
1688 fprintf (f, "\n index ");
1689 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1690 fprintf (f, "\n target ");
1691 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1692 break;
1694 case 7:
1695 case 8:
1697 long nrec, eloff, i;
1699 if ((type & 0x3f) == 7)
1700 fprintf (f, "record (0x%x) of ", type);
1701 else
1702 fprintf (f, "union (0x%x) of ", type);
1704 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1705 fprintf (f, "%lu elements: ", nrec);
1707 for (i = 0; i < nrec; i++)
1709 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1710 fprintf (f, "\n ");
1711 fprintf (f, "offset %lu: ", eloff);
1712 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1714 break;
1717 case 9:
1718 fprintf (f, "subrange (0x%x) of ", type);
1719 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1720 fprintf (f, " lower ");
1721 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1722 fprintf (f, " upper ");
1723 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1724 break;
1726 case 11:
1728 long value;
1730 fprintf (f, "named type (0x%x) ", type);
1731 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1732 if (value <= 0)
1733 fprintf (f, "[INVALID]");
1734 else
1735 fprintf (f, "\"%.*s\"",
1736 bfd_sym_symbol_name (abfd, value)[0],
1737 &bfd_sym_symbol_name (abfd, value)[1]);
1739 fprintf (f, " (NTE %lu) with type ", value);
1740 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1741 break;
1744 default:
1745 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1746 break;
1749 if (type == (0x40 | 0x6))
1751 /* Vector. */
1752 long n, width, m;
1753 long l;
1754 long i;
1756 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1757 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1758 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1759 /* fprintf (f, "\n "); */
1760 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1761 for (i = 0; i < m; i++)
1763 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1764 if (i != 0)
1765 fprintf (f, " ");
1766 fprintf (f, "%ld", l);
1769 else if (type & 0x40)
1771 /* Other packed type. */
1772 long msb, lsb;
1774 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1775 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1776 /* fprintf (f, "\n "); */
1777 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1780 fprintf (f, "]");
1782 if (offsetptr != NULL)
1783 *offsetptr = offset;
1786 void
1787 bfd_sym_print_type_information_table_entry (bfd *abfd,
1788 FILE *f,
1789 bfd_sym_type_information_table_entry *entry)
1791 unsigned char *buf;
1792 unsigned long offset;
1793 unsigned int i;
1795 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1796 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1797 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1798 entry->nte_index,
1799 entry->physical_size, entry->offset, entry->logical_size);
1801 fprintf (f, "\n ");
1803 buf = alloca (entry->physical_size);
1804 if (buf == NULL)
1806 fprintf (f, "[ERROR]\n");
1807 return;
1809 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1811 fprintf (f, "[ERROR]\n");
1812 return;
1814 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1816 fprintf (f, "[ERROR]\n");
1817 return;
1820 fprintf (f, "[");
1821 for (i = 0; i < entry->physical_size; i++)
1823 if (i == 0)
1824 fprintf (f, "0x%02x", buf[i]);
1825 else
1826 fprintf (f, " 0x%02x", buf[i]);
1829 fprintf (f, "]");
1830 fprintf (f, "\n ");
1832 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1834 if (offset != entry->physical_size)
1835 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size);
1838 void
1839 bfd_sym_print_file_references_index_table_entry (bfd *abfd ATTRIBUTE_UNUSED,
1840 FILE *f,
1841 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED)
1843 fprintf (f, "[UNIMPLEMENTED]");
1846 void
1847 bfd_sym_print_constant_pool_entry (bfd *abfd ATTRIBUTE_UNUSED,
1848 FILE *f,
1849 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED)
1851 fprintf (f, "[UNIMPLEMENTED]");
1854 unsigned char *
1855 bfd_sym_display_name_table_entry (bfd *abfd,
1856 FILE *f,
1857 unsigned char *entry)
1859 unsigned long index;
1860 unsigned long offset;
1861 bfd_sym_data_struct *sdata = NULL;
1863 BFD_ASSERT (bfd_sym_valid (abfd));
1864 sdata = abfd->tdata.sym_data;
1865 index = (entry - sdata->name_table) / 2;
1867 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1869 unsigned short length = bfd_getb16 (entry + 2);
1870 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
1871 offset = 2 + length + 1;
1873 else
1875 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1876 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
1878 if (sdata->version >= BFD_SYM_VERSION_3_4)
1879 offset = entry[0] + 2;
1880 else
1881 offset = entry[0] + 1;
1884 return (entry + offset + (offset % 2));
1887 void
1888 bfd_sym_display_name_table (bfd *abfd, FILE *f)
1890 unsigned long name_table_len;
1891 unsigned char *name_table, *name_table_end, *cur;
1892 bfd_sym_data_struct *sdata = NULL;
1894 BFD_ASSERT (bfd_sym_valid (abfd));
1895 sdata = abfd->tdata.sym_data;
1897 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1898 name_table = sdata->name_table;
1899 name_table_end = name_table + name_table_len;
1901 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1903 cur = name_table;
1904 for (;;)
1906 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1907 if (cur >= name_table_end)
1908 break;
1912 void
1913 bfd_sym_display_resources_table (bfd *abfd, FILE *f)
1915 unsigned long i;
1916 bfd_sym_resources_table_entry entry;
1917 bfd_sym_data_struct *sdata = NULL;
1919 BFD_ASSERT (bfd_sym_valid (abfd));
1920 sdata = abfd->tdata.sym_data;
1922 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
1923 sdata->header.dshb_rte.dti_object_count);
1925 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
1927 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
1928 fprintf (f, " [%8lu] [INVALID]\n", i);
1929 else
1931 fprintf (f, " [%8lu] ", i);
1932 bfd_sym_print_resources_table_entry (abfd, f, &entry);
1933 fprintf (f, "\n");
1938 void
1939 bfd_sym_display_modules_table (bfd *abfd, FILE *f)
1941 unsigned long i;
1942 bfd_sym_modules_table_entry entry;
1943 bfd_sym_data_struct *sdata = NULL;
1945 BFD_ASSERT (bfd_sym_valid (abfd));
1946 sdata = abfd->tdata.sym_data;
1948 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
1949 sdata->header.dshb_mte.dti_object_count);
1951 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
1953 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
1954 fprintf (f, " [%8lu] [INVALID]\n", i);
1955 else
1957 fprintf (f, " [%8lu] ", i);
1958 bfd_sym_print_modules_table_entry (abfd, f, &entry);
1959 fprintf (f, "\n");
1964 void
1965 bfd_sym_display_file_references_table (bfd *abfd, FILE *f)
1967 unsigned long i;
1968 bfd_sym_file_references_table_entry entry;
1969 bfd_sym_data_struct *sdata = NULL;
1971 BFD_ASSERT (bfd_sym_valid (abfd));
1972 sdata = abfd->tdata.sym_data;
1974 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
1975 sdata->header.dshb_frte.dti_object_count);
1977 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
1979 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
1980 fprintf (f, " [%8lu] [INVALID]\n", i);
1981 else
1983 fprintf (f, " [%8lu] ", i);
1984 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
1985 fprintf (f, "\n");
1990 void
1991 bfd_sym_display_contained_modules_table (bfd *abfd, FILE *f)
1993 unsigned long i;
1994 bfd_sym_contained_modules_table_entry entry;
1995 bfd_sym_data_struct *sdata = NULL;
1997 BFD_ASSERT (bfd_sym_valid (abfd));
1998 sdata = abfd->tdata.sym_data;
2000 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
2001 sdata->header.dshb_cmte.dti_object_count);
2003 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2005 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
2006 fprintf (f, " [%8lu] [INVALID]\n", i);
2007 else
2009 fprintf (f, " [%8lu] ", i);
2010 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
2011 fprintf (f, "\n");
2016 void
2017 bfd_sym_display_contained_variables_table (bfd *abfd, FILE *f)
2019 unsigned long i;
2020 bfd_sym_contained_variables_table_entry entry;
2021 bfd_sym_data_struct *sdata = NULL;
2023 BFD_ASSERT (bfd_sym_valid (abfd));
2024 sdata = abfd->tdata.sym_data;
2026 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2027 sdata->header.dshb_cvte.dti_object_count);
2029 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2031 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2032 fprintf (f, " [%8lu] [INVALID]\n", i);
2033 else
2035 fprintf (f, " [%8lu] ", i);
2036 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2037 fprintf (f, "\n");
2041 fprintf (f, "\n");
2044 void
2045 bfd_sym_display_contained_statements_table (bfd *abfd, FILE *f)
2047 unsigned long i;
2048 bfd_sym_contained_statements_table_entry entry;
2049 bfd_sym_data_struct *sdata = NULL;
2051 BFD_ASSERT (bfd_sym_valid (abfd));
2052 sdata = abfd->tdata.sym_data;
2054 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
2055 sdata->header.dshb_csnte.dti_object_count);
2057 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2059 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
2060 fprintf (f, " [%8lu] [INVALID]\n", i);
2061 else
2063 fprintf (f, " [%8lu] ", i);
2064 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
2065 fprintf (f, "\n");
2070 void
2071 bfd_sym_display_contained_labels_table (bfd *abfd, FILE *f)
2073 unsigned long i;
2074 bfd_sym_contained_labels_table_entry entry;
2075 bfd_sym_data_struct *sdata = NULL;
2077 BFD_ASSERT (bfd_sym_valid (abfd));
2078 sdata = abfd->tdata.sym_data;
2080 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
2081 sdata->header.dshb_clte.dti_object_count);
2083 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2085 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
2086 fprintf (f, " [%8lu] [INVALID]\n", i);
2087 else
2089 fprintf (f, " [%8lu] ", i);
2090 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
2091 fprintf (f, "\n");
2096 void
2097 bfd_sym_display_contained_types_table (bfd *abfd, FILE *f)
2099 unsigned long i;
2100 bfd_sym_contained_types_table_entry entry;
2101 bfd_sym_data_struct *sdata = NULL;
2103 BFD_ASSERT (bfd_sym_valid (abfd));
2104 sdata = abfd->tdata.sym_data;
2106 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
2107 sdata->header.dshb_ctte.dti_object_count);
2109 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2111 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2112 fprintf (f, " [%8lu] [INVALID]\n", i);
2113 else
2115 fprintf (f, " [%8lu] ", i);
2116 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2117 fprintf (f, "\n");
2122 void
2123 bfd_sym_display_file_references_index_table (bfd *abfd, FILE *f)
2125 unsigned long i;
2126 bfd_sym_file_references_index_table_entry entry;
2127 bfd_sym_data_struct *sdata = NULL;
2129 BFD_ASSERT (bfd_sym_valid (abfd));
2130 sdata = abfd->tdata.sym_data;
2132 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
2133 sdata->header.dshb_fite.dti_object_count);
2135 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2137 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2138 fprintf (f, " [%8lu] [INVALID]\n", i);
2139 else
2141 fprintf (f, " [%8lu] ", i);
2142 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2143 fprintf (f, "\n");
2148 void
2149 bfd_sym_display_constant_pool (bfd *abfd, FILE *f)
2151 unsigned long i;
2152 bfd_sym_constant_pool_entry entry;
2153 bfd_sym_data_struct *sdata = NULL;
2155 BFD_ASSERT (bfd_sym_valid (abfd));
2156 sdata = abfd->tdata.sym_data;
2158 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2159 sdata->header.dshb_const.dti_object_count);
2161 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2163 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2164 fprintf (f, " [%8lu] [INVALID]\n", i);
2165 else
2167 fprintf (f, " [%8lu] ", i);
2168 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2169 fprintf (f, "\n");
2174 void
2175 bfd_sym_display_type_information_table (bfd *abfd, FILE *f)
2177 unsigned long i;
2178 bfd_sym_type_table_entry index;
2179 bfd_sym_type_information_table_entry entry;
2180 bfd_sym_data_struct *sdata = NULL;
2182 BFD_ASSERT (bfd_sym_valid (abfd));
2183 sdata = abfd->tdata.sym_data;
2185 if (sdata->header.dshb_tte.dti_object_count > 99)
2186 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2187 sdata->header.dshb_tte.dti_object_count - 99);
2188 else
2190 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2191 return;
2194 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2196 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
2197 fprintf (f, " [%8lu] [INVALID]\n", i);
2198 else
2200 fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
2202 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
2203 fprintf (f, "[INVALID]");
2204 else
2205 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2207 fprintf (f, "\n");
2213 bfd_sym_scan (bfd *abfd, bfd_sym_version version, bfd_sym_data_struct *mdata)
2215 asection *bfdsec;
2216 const char *name = "symbols";
2218 mdata->name_table = 0;
2219 mdata->sbfd = abfd;
2220 mdata->version = version;
2222 bfd_seek (abfd, 0, SEEK_SET);
2223 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2224 return -1;
2226 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2227 if (mdata->name_table == NULL)
2228 return -1;
2230 bfdsec = bfd_make_section_anyway (abfd, name);
2231 if (bfdsec == NULL)
2232 return -1;
2234 bfdsec->vma = 0;
2235 bfdsec->lma = 0;
2236 bfdsec->size = 0;
2237 bfdsec->filepos = 0;
2238 bfdsec->alignment_power = 0;
2240 bfdsec->flags = SEC_HAS_CONTENTS;
2242 abfd->tdata.sym_data = mdata;
2244 return 0;
2247 const bfd_target *
2248 bfd_sym_object_p (bfd *abfd)
2250 struct bfd_preserve preserve;
2251 bfd_sym_version version = -1;
2253 preserve.marker = NULL;
2254 bfd_seek (abfd, 0, SEEK_SET);
2255 if (bfd_sym_read_version (abfd, &version) != 0)
2256 goto wrong;
2258 preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
2259 if (preserve.marker == NULL
2260 || ! bfd_preserve_save (abfd, &preserve))
2261 goto fail;
2263 if (bfd_sym_scan (abfd, version,
2264 (bfd_sym_data_struct *) preserve.marker) != 0)
2265 goto wrong;
2267 bfd_preserve_finish (abfd, &preserve);
2268 return abfd->xvec;
2270 wrong:
2271 bfd_set_error (bfd_error_wrong_format);
2273 fail:
2274 if (preserve.marker != NULL)
2275 bfd_preserve_restore (abfd, &preserve);
2276 return NULL;
2279 asymbol *
2280 bfd_sym_make_empty_symbol (bfd *abfd)
2282 return bfd_alloc (abfd, sizeof (asymbol));
2285 void
2286 bfd_sym_get_symbol_info (bfd *abfd ATTRIBUTE_UNUSED, asymbol *symbol, symbol_info *ret)
2288 bfd_symbol_info (symbol, ret);
2291 long
2292 bfd_sym_get_symtab_upper_bound (bfd *abfd ATTRIBUTE_UNUSED)
2294 return 0;
2297 long
2298 bfd_sym_canonicalize_symtab (bfd *abfd ATTRIBUTE_UNUSED, asymbol **sym ATTRIBUTE_UNUSED)
2300 return 0;
2304 bfd_sym_sizeof_headers (bfd *abfd ATTRIBUTE_UNUSED, bfd_boolean exec ATTRIBUTE_UNUSED)
2306 return 0;
2309 const bfd_target sym_vec =
2311 "sym", /* Name. */
2312 bfd_target_sym_flavour, /* Flavour. */
2313 BFD_ENDIAN_BIG, /* Byteorder. */
2314 BFD_ENDIAN_BIG, /* Header byteorder. */
2315 (HAS_RELOC | EXEC_P | /* Object flags. */
2316 HAS_LINENO | HAS_DEBUG |
2317 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2318 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2319 | SEC_ROM | SEC_HAS_CONTENTS), /* Section_flags. */
2320 0, /* Symbol_leading_char. */
2321 ' ', /* AR_pad_char. */
2322 16, /* AR_max_namelen. */
2323 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2324 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2325 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Data. */
2326 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2327 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2328 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* Hdrs. */
2329 { /* bfd_check_format. */
2330 _bfd_dummy_target,
2331 bfd_sym_object_p, /* bfd_check_format. */
2332 _bfd_dummy_target,
2333 _bfd_dummy_target,
2335 { /* bfd_set_format. */
2336 bfd_false,
2337 bfd_sym_mkobject,
2338 bfd_false,
2339 bfd_false,
2341 { /* bfd_write_contents. */
2342 bfd_false,
2343 bfd_true,
2344 bfd_false,
2345 bfd_false,
2348 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2349 BFD_JUMP_TABLE_COPY (_bfd_generic),
2350 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2351 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2352 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2353 BFD_JUMP_TABLE_RELOCS (bfd_sym),
2354 BFD_JUMP_TABLE_WRITE (bfd_sym),
2355 BFD_JUMP_TABLE_LINK (bfd_sym),
2356 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2358 NULL,
2360 NULL