Remove terminating semicolons from SYSCTL_ADD_* macros. This will allow to
[dragonfly/port-amd64.git] / contrib / gdb-6.2.1 / bfd / xsym.c
blobaa44e971c687a3c28296eadec0bc73f2900aded2
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_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
48 #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
49 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
50 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
51 #define bfd_sym_bfd_final_link _bfd_generic_final_link
52 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
53 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
55 static int pstrcmp PARAMS ((unsigned char *, unsigned char *));
56 static unsigned long compute_offset
57 PARAMS ((unsigned long, unsigned long, unsigned long, unsigned long));
59 extern const bfd_target sym_vec;
61 static int
62 pstrcmp (a, b)
63 unsigned char *a;
64 unsigned char *b;
66 unsigned char clen;
67 int ret;
69 clen = (a[0] > b[0]) ? a[0] : b[0];
70 ret = memcmp (a + 1, b + 1, clen);
71 if (ret != 0)
72 return ret;
74 if (a[0] == b[0])
75 return 0;
76 else if (a[0] < b[0])
77 return -1;
78 else
79 return 0;
82 static unsigned long
83 compute_offset (first_page, page_size, entry_size, index)
84 unsigned long first_page;
85 unsigned long page_size;
86 unsigned long entry_size;
87 unsigned long index;
89 unsigned long entries_per_page = page_size / entry_size;
90 unsigned long page_number = first_page + (index / entries_per_page);
91 unsigned long page_offset = (index % entries_per_page) * entry_size;
93 return (page_number * page_size) + page_offset;
96 bfd_boolean
97 bfd_sym_mkobject (abfd)
98 bfd *abfd ATTRIBUTE_UNUSED;
100 return 1;
103 void
104 bfd_sym_print_symbol (abfd, afile, symbol, how)
105 bfd *abfd ATTRIBUTE_UNUSED;
106 PTR afile ATTRIBUTE_UNUSED;
107 asymbol *symbol ATTRIBUTE_UNUSED;
108 bfd_print_symbol_type how ATTRIBUTE_UNUSED;
110 return;
113 bfd_boolean
114 bfd_sym_valid (abfd)
115 bfd *abfd;
117 if (abfd == NULL || abfd->xvec == NULL)
118 return 0;
120 return abfd->xvec == &sym_vec;
123 unsigned char *
124 bfd_sym_read_name_table (abfd, dshb)
125 bfd *abfd;
126 bfd_sym_header_block *dshb;
128 unsigned char *rstr;
129 long ret;
130 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
131 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
133 rstr = (unsigned char *) bfd_alloc (abfd, table_size);
134 if (rstr == NULL)
135 return rstr;
137 bfd_seek (abfd, table_offset, SEEK_SET);
138 ret = bfd_bread (rstr, table_size, abfd);
139 if (ret < 0 || (unsigned long) ret != table_size)
141 bfd_release (abfd, rstr);
142 return NULL;
145 return rstr;
148 void
149 bfd_sym_parse_file_reference_v32 (buf, len, entry)
150 unsigned char *buf;
151 size_t len;
152 bfd_sym_file_reference *entry;
154 BFD_ASSERT (len == 6);
156 entry->fref_frte_index = bfd_getb16 (buf);
157 entry->fref_offset = bfd_getb32 (buf + 2);
160 void
161 bfd_sym_parse_disk_table_v32 (buf, len, table)
162 unsigned char *buf;
163 size_t len;
164 bfd_sym_table_info *table;
166 BFD_ASSERT (len == 8);
168 table->dti_first_page = bfd_getb16 (buf);
169 table->dti_page_count = bfd_getb16 (buf + 2);
170 table->dti_object_count = bfd_getb32 (buf + 4);
173 void
174 bfd_sym_parse_header_v32 (buf, len, header)
175 unsigned char *buf;
176 size_t len;
177 bfd_sym_header_block *header;
179 BFD_ASSERT (len == 154);
181 memcpy (header->dshb_id, buf, 32);
182 header->dshb_page_size = bfd_getb16 (buf + 32);
183 header->dshb_hash_page = bfd_getb16 (buf + 34);
184 header->dshb_root_mte = bfd_getb16 (buf + 36);
185 header->dshb_mod_date = bfd_getb32 (buf + 38);
187 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
188 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
189 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
190 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
191 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
192 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
193 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
194 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
195 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
196 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
197 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
198 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
199 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
201 memcpy (&header->dshb_file_creator, buf + 146, 4);
202 memcpy (&header->dshb_file_type, buf + 150, 4);
206 bfd_sym_read_header_v32 (abfd, header)
207 bfd *abfd;
208 bfd_sym_header_block *header;
210 unsigned char buf[154];
211 long ret;
213 ret = bfd_bread (buf, 154, abfd);
214 if (ret != 154)
215 return -1;
217 bfd_sym_parse_header_v32 (buf, 154, header);
219 return 0;
223 bfd_sym_read_header_v34 (abfd, header)
224 bfd *abfd ATTRIBUTE_UNUSED;
225 bfd_sym_header_block *header ATTRIBUTE_UNUSED;
227 abort ();
231 bfd_sym_read_header (abfd, header, version)
232 bfd *abfd;
233 bfd_sym_header_block *header;
234 bfd_sym_version version;
236 switch (version)
238 case BFD_SYM_VERSION_3_5:
239 case BFD_SYM_VERSION_3_4:
240 return bfd_sym_read_header_v34 (abfd, header);
241 case BFD_SYM_VERSION_3_3:
242 case BFD_SYM_VERSION_3_2:
243 return bfd_sym_read_header_v32 (abfd, header);
244 case BFD_SYM_VERSION_3_1:
245 default:
246 return FALSE;
251 bfd_sym_read_version (abfd, version)
252 bfd *abfd;
253 bfd_sym_version *version;
255 unsigned char version_string[32];
256 long ret;
258 ret = bfd_bread (version_string, sizeof (version_string), abfd);
259 if (ret != sizeof (version_string))
260 return -1;
262 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
263 *version = BFD_SYM_VERSION_3_1;
264 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
265 *version = BFD_SYM_VERSION_3_2;
266 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
267 *version = BFD_SYM_VERSION_3_3;
268 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
269 *version = BFD_SYM_VERSION_3_4;
270 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
271 *version = BFD_SYM_VERSION_3_5;
272 else
273 return -1;
275 return 0;
278 void
279 bfd_sym_display_table_summary (f, dti, name)
280 FILE *f;
281 bfd_sym_table_info *dti;
282 const char *name;
284 fprintf (f, "%-6s %13ld %13ld %13ld\n",
285 name,
286 dti->dti_first_page,
287 dti->dti_page_count,
288 dti->dti_object_count);
291 void
292 bfd_sym_display_header (f, dshb)
293 FILE *f;
294 bfd_sym_header_block *dshb;
296 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
297 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
298 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
299 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
300 fprintf (f, " Modification Date: ");
301 fprintf (f, "[unimplemented]");
302 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
304 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
305 dshb->dshb_file_creator, dshb->dshb_file_type);
307 fprintf (f, "Table Name First Page Page Count Object Count\n");
308 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
310 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
311 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
312 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
313 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
314 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
315 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
316 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
317 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
318 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
319 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
320 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
321 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
322 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
324 fprintf (f, "\n");
327 void
328 bfd_sym_parse_resources_table_entry_v32 (buf, len, entry)
329 unsigned char *buf;
330 size_t len;
331 bfd_sym_resources_table_entry *entry;
333 BFD_ASSERT (len == 18);
335 memcpy (&entry->rte_res_type, buf, 4);
336 entry->rte_res_number = bfd_getb16 (buf + 4);
337 entry->rte_nte_index = bfd_getb32 (buf + 6);
338 entry->rte_mte_first = bfd_getb16 (buf + 10);
339 entry->rte_mte_last = bfd_getb16 (buf + 12);
340 entry->rte_res_size = bfd_getb32 (buf + 14);
343 void
344 bfd_sym_parse_modules_table_entry_v33 (buf, len, entry)
345 unsigned char *buf;
346 size_t len;
347 bfd_sym_modules_table_entry *entry;
349 BFD_ASSERT (len == 46);
351 entry->mte_rte_index = bfd_getb16 (buf);
352 entry->mte_res_offset = bfd_getb32 (buf + 2);
353 entry->mte_size = bfd_getb32 (buf + 6);
354 entry->mte_kind = buf[10];
355 entry->mte_scope = buf[11];
356 entry->mte_parent = bfd_getb16 (buf + 12);
357 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
358 entry->mte_imp_end = bfd_getb32 (buf + 20);
359 entry->mte_nte_index = bfd_getb32 (buf + 24);
360 entry->mte_cmte_index = bfd_getb16 (buf + 28);
361 entry->mte_cvte_index = bfd_getb32 (buf + 30);
362 entry->mte_clte_index = bfd_getb16 (buf + 34);
363 entry->mte_ctte_index = bfd_getb16 (buf + 36);
364 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
365 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
368 void
369 bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry)
370 unsigned char *buf;
371 size_t len;
372 bfd_sym_file_references_table_entry *entry;
374 unsigned int type;
376 BFD_ASSERT (len == 10);
378 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
379 type = bfd_getb16 (buf);
381 switch (type)
383 case BFD_SYM_END_OF_LIST_3_2:
384 entry->generic.type = BFD_SYM_END_OF_LIST;
385 break;
387 case BFD_SYM_FILE_NAME_INDEX_3_2:
388 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
389 entry->filename.nte_index = bfd_getb32 (buf + 2);
390 entry->filename.mod_date = bfd_getb32 (buf + 6);
391 break;
393 default:
394 entry->entry.mte_index = type;
395 entry->entry.file_offset = bfd_getb32 (buf + 2);
399 void
400 bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry)
401 unsigned char *buf;
402 size_t len;
403 bfd_sym_contained_modules_table_entry *entry;
405 unsigned int type;
407 BFD_ASSERT (len == 6);
409 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
410 type = bfd_getb16 (buf);
412 switch (type)
414 case BFD_SYM_END_OF_LIST_3_2:
415 entry->generic.type = BFD_SYM_END_OF_LIST;
416 break;
418 default:
419 entry->entry.mte_index = type;
420 entry->entry.nte_index = bfd_getb32 (buf + 2);
421 break;
425 void
426 bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry)
427 unsigned char *buf;
428 size_t len;
429 bfd_sym_contained_variables_table_entry *entry;
431 unsigned int type;
433 BFD_ASSERT (len == 26);
435 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
436 type = bfd_getb16 (buf);
438 switch (type)
440 case BFD_SYM_END_OF_LIST_3_2:
441 entry->generic.type = BFD_SYM_END_OF_LIST;
442 break;
444 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
445 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
446 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
447 break;
449 default:
450 entry->entry.tte_index = type;
451 entry->entry.nte_index = bfd_getb32 (buf + 2);
452 entry->entry.file_delta = bfd_getb16 (buf + 6);
453 entry->entry.scope = buf[8];
454 entry->entry.la_size = buf[9];
456 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
458 entry->entry.address.scstruct.sca_kind = buf[10];
459 entry->entry.address.scstruct.sca_class = buf[11];
460 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
462 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
464 memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA);
465 entry->entry.address.lastruct.la_kind = buf[23];
467 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
469 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
470 entry->entry.address.biglastruct.big_la_kind = buf[12];
475 void
476 bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
477 unsigned char *buf;
478 size_t len;
479 bfd_sym_contained_statements_table_entry *entry;
481 unsigned int type;
483 BFD_ASSERT (len == 8);
485 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
486 type = bfd_getb16 (buf);
488 switch (type)
490 case BFD_SYM_END_OF_LIST_3_2:
491 entry->generic.type = BFD_SYM_END_OF_LIST;
492 break;
494 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
495 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
496 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
497 break;
499 default:
500 entry->entry.mte_index = type;
501 entry->entry.mte_offset = bfd_getb16 (buf + 2);
502 entry->entry.file_delta = bfd_getb32 (buf + 4);
503 break;
507 void
508 bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
509 unsigned char *buf;
510 size_t len;
511 bfd_sym_contained_labels_table_entry *entry;
513 unsigned int type;
515 BFD_ASSERT (len == 12);
517 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
518 type = bfd_getb16 (buf);
520 switch (type)
522 case BFD_SYM_END_OF_LIST_3_2:
523 entry->generic.type = BFD_SYM_END_OF_LIST;
524 break;
526 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
527 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
528 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
529 break;
531 default:
532 entry->entry.mte_index = type;
533 entry->entry.mte_offset = bfd_getb16 (buf + 2);
534 entry->entry.nte_index = bfd_getb32 (buf + 4);
535 entry->entry.file_delta = bfd_getb16 (buf + 8);
536 entry->entry.scope = bfd_getb16 (buf + 10);
537 break;
541 void
542 bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
543 unsigned char *buf;
544 size_t len;
545 bfd_sym_type_table_entry *entry;
547 BFD_ASSERT (len == 4);
549 *entry = bfd_getb32 (buf);
553 bfd_sym_fetch_resources_table_entry (abfd, entry, index)
554 bfd *abfd;
555 bfd_sym_resources_table_entry *entry;
556 unsigned long index;
558 void (*parser) PARAMS ((unsigned char *, size_t,
559 bfd_sym_resources_table_entry *));
560 unsigned long offset;
561 unsigned long entry_size;
562 unsigned char buf[18];
563 bfd_sym_data_struct *sdata = NULL;
565 parser = NULL;
566 BFD_ASSERT (bfd_sym_valid (abfd));
567 sdata = abfd->tdata.sym_data;
569 if (index == 0)
570 return -1;
572 switch (sdata->version)
574 case BFD_SYM_VERSION_3_5:
575 case BFD_SYM_VERSION_3_4:
576 return -1;
578 case BFD_SYM_VERSION_3_3:
579 case BFD_SYM_VERSION_3_2:
580 entry_size = 18;
581 parser = bfd_sym_parse_resources_table_entry_v32;
582 break;
584 case BFD_SYM_VERSION_3_1:
585 default:
586 return -1;
588 if (parser == NULL)
589 return -1;
591 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
592 sdata->header.dshb_page_size,
593 entry_size, index);
595 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
596 return -1;
597 if (bfd_bread (buf, entry_size, abfd) != entry_size)
598 return -1;
600 (*parser) (buf, entry_size, entry);
602 return 0;
606 bfd_sym_fetch_modules_table_entry (abfd, entry, index)
607 bfd *abfd;
608 bfd_sym_modules_table_entry *entry;
609 unsigned long index;
611 void (*parser) PARAMS ((unsigned char *, size_t,
612 bfd_sym_modules_table_entry *));
613 unsigned long offset;
614 unsigned long entry_size;
615 unsigned char buf[46];
616 bfd_sym_data_struct *sdata = NULL;
618 parser = NULL;
619 BFD_ASSERT (bfd_sym_valid (abfd));
620 sdata = abfd->tdata.sym_data;
622 if (index == 0)
623 return -1;
625 switch (sdata->version)
627 case BFD_SYM_VERSION_3_5:
628 case BFD_SYM_VERSION_3_4:
629 return -1;
631 case BFD_SYM_VERSION_3_3:
632 entry_size = 46;
633 parser = bfd_sym_parse_modules_table_entry_v33;
634 break;
636 case BFD_SYM_VERSION_3_2:
637 case BFD_SYM_VERSION_3_1:
638 default:
639 return -1;
641 if (parser == NULL)
642 return -1;
644 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
645 sdata->header.dshb_page_size,
646 entry_size, index);
648 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
649 return -1;
650 if (bfd_bread (buf, entry_size, abfd) != entry_size)
651 return -1;
653 (*parser) (buf, entry_size, entry);
655 return 0;
659 bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
660 bfd *abfd;
661 bfd_sym_file_references_table_entry *entry;
662 unsigned long index;
664 void (*parser) PARAMS ((unsigned char *, size_t,
665 bfd_sym_file_references_table_entry *));
666 unsigned long offset;
667 unsigned long entry_size = 0;
668 unsigned char buf[8];
669 bfd_sym_data_struct *sdata = NULL;
671 parser = NULL;
672 BFD_ASSERT (bfd_sym_valid (abfd));
673 sdata = abfd->tdata.sym_data;
675 if (index == 0)
676 return -1;
678 switch (sdata->version)
680 case BFD_SYM_VERSION_3_3:
681 case BFD_SYM_VERSION_3_2:
682 entry_size = 10;
683 parser = bfd_sym_parse_file_references_table_entry_v32;
684 break;
686 case BFD_SYM_VERSION_3_5:
687 case BFD_SYM_VERSION_3_4:
688 case BFD_SYM_VERSION_3_1:
689 default:
690 break;
693 if (parser == NULL)
694 return -1;
696 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
697 sdata->header.dshb_page_size,
698 entry_size, index);
700 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
701 return -1;
702 if (bfd_bread (buf, entry_size, abfd) != entry_size)
703 return -1;
705 (*parser) (buf, entry_size, entry);
707 return 0;
711 bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
712 bfd *abfd;
713 bfd_sym_contained_modules_table_entry *entry;
714 unsigned long index;
716 void (*parser) PARAMS ((unsigned char *, size_t,
717 bfd_sym_contained_modules_table_entry *));
718 unsigned long offset;
719 unsigned long entry_size = 0;
720 unsigned char buf[6];
721 bfd_sym_data_struct *sdata = NULL;
723 parser = NULL;
724 BFD_ASSERT (bfd_sym_valid (abfd));
725 sdata = abfd->tdata.sym_data;
727 if (index == 0)
728 return -1;
730 switch (sdata->version)
732 case BFD_SYM_VERSION_3_3:
733 case BFD_SYM_VERSION_3_2:
734 entry_size = 6;
735 parser = bfd_sym_parse_contained_modules_table_entry_v32;
736 break;
738 case BFD_SYM_VERSION_3_5:
739 case BFD_SYM_VERSION_3_4:
740 case BFD_SYM_VERSION_3_1:
741 default:
742 break;
745 if (parser == NULL)
746 return -1;
748 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
749 sdata->header.dshb_page_size,
750 entry_size, index);
752 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
753 return -1;
754 if (bfd_bread (buf, entry_size, abfd) != entry_size)
755 return -1;
757 (*parser) (buf, entry_size, entry);
759 return 0;
763 bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
764 bfd *abfd;
765 bfd_sym_contained_variables_table_entry *entry;
766 unsigned long index;
768 void (*parser) PARAMS ((unsigned char *, size_t,
769 bfd_sym_contained_variables_table_entry *));
770 unsigned long offset;
771 unsigned long entry_size = 0;
772 unsigned char buf[26];
773 bfd_sym_data_struct *sdata = NULL;
775 parser = NULL;
776 BFD_ASSERT (bfd_sym_valid (abfd));
777 sdata = abfd->tdata.sym_data;
779 if (index == 0)
780 return -1;
782 switch (sdata->version)
784 case BFD_SYM_VERSION_3_3:
785 case BFD_SYM_VERSION_3_2:
786 entry_size = 26;
787 parser = bfd_sym_parse_contained_variables_table_entry_v32;
788 break;
790 case BFD_SYM_VERSION_3_5:
791 case BFD_SYM_VERSION_3_4:
792 case BFD_SYM_VERSION_3_1:
793 default:
794 break;
797 if (parser == NULL)
798 return -1;
800 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
801 sdata->header.dshb_page_size,
802 entry_size, index);
804 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
805 return -1;
806 if (bfd_bread (buf, entry_size, abfd) != entry_size)
807 return -1;
809 (*parser) (buf, entry_size, entry);
811 return 0;
815 bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
816 bfd *abfd;
817 bfd_sym_contained_statements_table_entry *entry;
818 unsigned long index;
820 void (*parser) PARAMS ((unsigned char *, size_t,
821 bfd_sym_contained_statements_table_entry *));
822 unsigned long offset;
823 unsigned long entry_size = 0;
824 unsigned char buf[8];
825 bfd_sym_data_struct *sdata = NULL;
827 parser = NULL;
828 BFD_ASSERT (bfd_sym_valid (abfd));
829 sdata = abfd->tdata.sym_data;
831 if (index == 0)
832 return -1;
834 switch (sdata->version)
836 case BFD_SYM_VERSION_3_3:
837 case BFD_SYM_VERSION_3_2:
838 entry_size = 8;
839 parser = bfd_sym_parse_contained_statements_table_entry_v32;
840 break;
842 case BFD_SYM_VERSION_3_5:
843 case BFD_SYM_VERSION_3_4:
844 case BFD_SYM_VERSION_3_1:
845 default:
846 break;
849 if (parser == NULL)
850 return -1;
852 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
853 sdata->header.dshb_page_size,
854 entry_size, index);
856 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
857 return -1;
858 if (bfd_bread (buf, entry_size, abfd) != entry_size)
859 return -1;
861 (*parser) (buf, entry_size, entry);
863 return 0;
867 bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
868 bfd *abfd;
869 bfd_sym_contained_labels_table_entry *entry;
870 unsigned long index;
872 void (*parser) PARAMS ((unsigned char *, size_t,
873 bfd_sym_contained_labels_table_entry *));
874 unsigned long offset;
875 unsigned long entry_size = 0;
876 unsigned char buf[12];
877 bfd_sym_data_struct *sdata = NULL;
879 parser = NULL;
880 BFD_ASSERT (bfd_sym_valid (abfd));
881 sdata = abfd->tdata.sym_data;
883 if (index == 0)
884 return -1;
886 switch (sdata->version)
888 case BFD_SYM_VERSION_3_3:
889 case BFD_SYM_VERSION_3_2:
890 entry_size = 12;
891 parser = bfd_sym_parse_contained_labels_table_entry_v32;
892 break;
894 case BFD_SYM_VERSION_3_5:
895 case BFD_SYM_VERSION_3_4:
896 case BFD_SYM_VERSION_3_1:
897 default:
898 break;
901 if (parser == NULL)
902 return -1;
904 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
905 sdata->header.dshb_page_size,
906 entry_size, index);
908 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
909 return -1;
910 if (bfd_bread (buf, entry_size, abfd) != entry_size)
911 return -1;
913 (*parser) (buf, entry_size, entry);
915 return 0;
919 bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
920 bfd *abfd;
921 bfd_sym_contained_types_table_entry *entry;
922 unsigned long index;
924 void (*parser) PARAMS ((unsigned char *, size_t,
925 bfd_sym_contained_types_table_entry *));
926 unsigned long offset;
927 unsigned long entry_size = 0;
928 unsigned char buf[0];
929 bfd_sym_data_struct *sdata = NULL;
931 parser = NULL;
932 BFD_ASSERT (bfd_sym_valid (abfd));
933 sdata = abfd->tdata.sym_data;
935 if (index == 0)
936 return -1;
938 switch (sdata->version)
940 case BFD_SYM_VERSION_3_3:
941 case BFD_SYM_VERSION_3_2:
942 entry_size = 0;
943 parser = NULL;
944 break;
946 case BFD_SYM_VERSION_3_5:
947 case BFD_SYM_VERSION_3_4:
948 case BFD_SYM_VERSION_3_1:
949 default:
950 break;
953 if (parser == NULL)
954 return -1;
956 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
957 sdata->header.dshb_page_size,
958 entry_size, index);
960 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
961 return -1;
962 if (bfd_bread (buf, entry_size, abfd) != entry_size)
963 return -1;
965 (*parser) (buf, entry_size, entry);
967 return 0;
971 bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
972 bfd *abfd;
973 bfd_sym_file_references_index_table_entry *entry;
974 unsigned long index;
976 void (*parser) PARAMS ((unsigned char *, size_t,
977 bfd_sym_file_references_index_table_entry *));
978 unsigned long offset;
979 unsigned long entry_size = 0;
980 unsigned char buf[0];
981 bfd_sym_data_struct *sdata = NULL;
983 parser = NULL;
984 BFD_ASSERT (bfd_sym_valid (abfd));
985 sdata = abfd->tdata.sym_data;
987 if (index == 0)
988 return -1;
990 switch (sdata->version)
992 case BFD_SYM_VERSION_3_3:
993 case BFD_SYM_VERSION_3_2:
994 entry_size = 0;
995 parser = NULL;
996 break;
998 case BFD_SYM_VERSION_3_5:
999 case BFD_SYM_VERSION_3_4:
1000 case BFD_SYM_VERSION_3_1:
1001 default:
1002 break;
1005 if (parser == NULL)
1006 return -1;
1008 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1009 sdata->header.dshb_page_size,
1010 entry_size, index);
1012 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1013 return -1;
1014 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1015 return -1;
1017 (*parser) (buf, entry_size, entry);
1019 return 0;
1023 bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
1024 bfd *abfd;
1025 bfd_sym_constant_pool_entry *entry;
1026 unsigned long index;
1028 void (*parser) PARAMS ((unsigned char *, size_t,
1029 bfd_sym_constant_pool_entry *));
1030 unsigned long offset;
1031 unsigned long entry_size = 0;
1032 unsigned char buf[0];
1033 bfd_sym_data_struct *sdata = NULL;
1035 parser = NULL;
1036 BFD_ASSERT (bfd_sym_valid (abfd));
1037 sdata = abfd->tdata.sym_data;
1039 if (index == 0)
1040 return -1;
1042 switch (sdata->version)
1044 case BFD_SYM_VERSION_3_3:
1045 case BFD_SYM_VERSION_3_2:
1046 entry_size = 0;
1047 parser = NULL;
1048 break;
1050 case BFD_SYM_VERSION_3_5:
1051 case BFD_SYM_VERSION_3_4:
1052 case BFD_SYM_VERSION_3_1:
1053 default:
1054 break;
1057 if (parser == NULL)
1058 return -1;
1060 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1061 sdata->header.dshb_page_size,
1062 entry_size, index);
1064 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1065 return -1;
1066 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1067 return -1;
1069 (*parser) (buf, entry_size, entry);
1071 return 0;
1075 bfd_sym_fetch_type_table_entry (abfd, entry, index)
1076 bfd *abfd;
1077 bfd_sym_type_table_entry *entry;
1078 unsigned long index;
1080 void (*parser) PARAMS ((unsigned char *, size_t,
1081 bfd_sym_type_table_entry *));
1082 unsigned long offset;
1083 unsigned long entry_size = 0;
1084 unsigned char buf[4];
1085 bfd_sym_data_struct *sdata = NULL;
1087 parser = NULL;
1088 BFD_ASSERT (bfd_sym_valid (abfd));
1089 sdata = abfd->tdata.sym_data;
1091 switch (sdata->version)
1093 case BFD_SYM_VERSION_3_3:
1094 case BFD_SYM_VERSION_3_2:
1095 entry_size = 4;
1096 parser = bfd_sym_parse_type_table_entry_v32;
1097 break;
1099 case BFD_SYM_VERSION_3_5:
1100 case BFD_SYM_VERSION_3_4:
1101 case BFD_SYM_VERSION_3_1:
1102 default:
1103 break;
1106 if (parser == NULL)
1107 return -1;
1109 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1110 sdata->header.dshb_page_size,
1111 entry_size, index);
1113 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1114 return -1;
1115 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1116 return -1;
1118 (*parser) (buf, entry_size, entry);
1120 return 0;
1124 bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
1125 bfd *abfd;
1126 bfd_sym_type_information_table_entry *entry;
1127 unsigned long offset;
1129 unsigned char buf[4];
1130 bfd_sym_data_struct *sdata = NULL;
1132 BFD_ASSERT (bfd_sym_valid (abfd));
1133 sdata = abfd->tdata.sym_data;
1135 if (offset == 0)
1136 return -1;
1138 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1139 return -1;
1141 if (bfd_bread (buf, 4, abfd) != 4)
1142 return -1;
1143 entry->nte_index = bfd_getb32 (buf);
1145 if (bfd_bread (buf, 2, abfd) != 2)
1146 return -1;
1147 entry->physical_size = bfd_getb16 (buf);
1149 if (entry->physical_size & 0x8000)
1151 if (bfd_bread (buf, 4, abfd) != 4)
1152 return -1;
1153 entry->physical_size &= 0x7fff;
1154 entry->logical_size = bfd_getb32 (buf);
1155 entry->offset = offset + 10;
1157 else
1159 if (bfd_bread (buf, 2, abfd) != 2)
1160 return -1;
1161 entry->physical_size &= 0x7fff;
1162 entry->logical_size = bfd_getb16 (buf);
1163 entry->offset = offset + 8;
1166 return 0;
1170 bfd_sym_fetch_type_table_information (abfd, entry, index)
1171 bfd *abfd;
1172 bfd_sym_type_information_table_entry *entry;
1173 unsigned long index;
1175 bfd_sym_type_table_entry tindex;
1176 bfd_sym_data_struct *sdata = NULL;
1178 BFD_ASSERT (bfd_sym_valid (abfd));
1179 sdata = abfd->tdata.sym_data;
1181 if (sdata->header.dshb_tte.dti_object_count <= 99)
1182 return -1;
1183 if (index < 100)
1184 return -1;
1186 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
1187 return -1;
1188 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1189 return -1;
1191 return 0;
1194 const unsigned char *
1195 bfd_sym_symbol_name (abfd, index)
1196 bfd *abfd;
1197 unsigned long index;
1199 bfd_sym_data_struct *sdata = NULL;
1201 BFD_ASSERT (bfd_sym_valid (abfd));
1202 sdata = abfd->tdata.sym_data;
1204 if (index == 0)
1205 return "";
1207 index *= 2;
1208 if ((index / sdata->header.dshb_page_size)
1209 > sdata->header.dshb_nte.dti_page_count)
1210 return "\009[INVALID]";
1212 return (const unsigned char *) sdata->name_table + index;
1215 const unsigned char *
1216 bfd_sym_module_name (abfd, index)
1217 bfd *abfd;
1218 unsigned long index;
1220 bfd_sym_modules_table_entry entry;
1222 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
1223 return "\011[INVALID]";
1225 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1228 const char *
1229 bfd_sym_unparse_storage_kind (kind)
1230 enum bfd_sym_storage_kind kind;
1232 switch (kind)
1234 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1235 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1236 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1237 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1238 default: return "[UNKNOWN]";
1242 const char *
1243 bfd_sym_unparse_storage_class (kind)
1244 enum bfd_sym_storage_class kind;
1246 switch (kind)
1248 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1249 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1250 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1251 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1252 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1253 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1254 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1255 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1256 default: return "[UNKNOWN]";
1260 const char *
1261 bfd_sym_unparse_module_kind (kind)
1262 enum bfd_sym_module_kind kind;
1264 switch (kind)
1266 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1267 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1268 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1269 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1270 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1271 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1272 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1273 default: return "[UNKNOWN]";
1277 const char *
1278 bfd_sym_unparse_symbol_scope (scope)
1279 enum bfd_sym_symbol_scope scope;
1281 switch (scope)
1283 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1284 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1285 default:
1286 return "[UNKNOWN]";
1290 void
1291 bfd_sym_print_file_reference (abfd, f, entry)
1292 bfd *abfd;
1293 FILE *f;
1294 bfd_sym_file_reference *entry;
1296 bfd_sym_file_references_table_entry frtentry;
1297 int ret;
1299 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1300 entry->fref_frte_index);
1301 fprintf (f, "FILE ");
1303 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1304 fprintf (f, "[INVALID]");
1305 else
1306 fprintf (f, "\"%.*s\"",
1307 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1308 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1310 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1313 void
1314 bfd_sym_print_resources_table_entry (abfd, f, entry)
1315 bfd *abfd;
1316 FILE *f;
1317 bfd_sym_resources_table_entry *entry;
1319 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1320 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1321 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1322 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1323 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1326 void
1327 bfd_sym_print_modules_table_entry (abfd, f, entry)
1328 bfd *abfd;
1329 FILE *f;
1330 bfd_sym_modules_table_entry *entry;
1332 fprintf (f, "\"%.*s\" (NTE %lu)",
1333 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1334 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1335 entry->mte_nte_index);
1337 fprintf (f, "\n ");
1339 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1340 fprintf (f, " range %lu -- %lu",
1341 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1343 fprintf (f, "\n ");
1345 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1346 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1348 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1349 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1351 fprintf (f, "\n ");
1353 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1354 entry->mte_cmte_index, entry->mte_cvte_index,
1355 entry->mte_clte_index, entry->mte_ctte_index,
1356 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1358 if (entry->mte_parent != 0)
1359 fprintf (f, ", parent %lu", entry->mte_parent);
1360 else
1361 fprintf (f, ", no parent");
1363 if (entry->mte_cmte_index != 0)
1364 fprintf (f, ", child %lu", entry->mte_cmte_index);
1365 else
1366 fprintf (f, ", no child");
1368 #if 0
1370 MTE bfd_sym_modules_table_entry pentry;
1372 ret = bfd_sym_fetch_modules_table_entry (abfd, &pentry, entry->mte_parent);
1373 if (ret < 0)
1374 fprintf (f, " parent MTE %lu [INVALID]\n", entry->mte_parent);
1375 else
1376 fprintf (f, " parent MTE %lu \"%.*s\"\n",
1377 entry->mte_parent,
1378 bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[0],
1379 &bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[1]);
1381 #endif
1384 void
1385 bfd_sym_print_file_references_table_entry (abfd, f, entry)
1386 bfd *abfd;
1387 FILE *f;
1388 bfd_sym_file_references_table_entry *entry;
1390 switch (entry->generic.type)
1392 case BFD_SYM_FILE_NAME_INDEX:
1393 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1394 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1395 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1396 entry->filename.nte_index);
1398 fprintf (f, "[UNIMPLEMENTED]");
1399 /* printModDate (entry->filename.mod_date); */
1400 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1401 break;
1403 case BFD_SYM_END_OF_LIST:
1404 fprintf (f, "END");
1405 break;
1407 default:
1408 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1409 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1410 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1411 entry->entry.mte_index,
1412 entry->entry.file_offset);
1413 break;
1417 void
1418 bfd_sym_print_contained_modules_table_entry (abfd, f, entry)
1419 bfd *abfd;
1420 FILE *f;
1421 bfd_sym_contained_modules_table_entry *entry;
1423 switch (entry->generic.type)
1425 case BFD_SYM_END_OF_LIST:
1426 fprintf (f, "END");
1427 break;
1429 default:
1430 fprintf (f, "\"%.*s\" (MTE %lu, NTE %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.nte_index);
1435 break;
1439 void
1440 bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
1441 bfd *abfd;
1442 FILE *f;
1443 bfd_sym_contained_variables_table_entry *entry;
1445 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1447 fprintf (f, "END");
1448 return;
1451 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1453 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1454 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1455 return;
1458 fprintf (f, "\"%.*s\" (NTE %lu)",
1459 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1460 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1461 entry->entry.nte_index);
1463 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1464 fprintf (f, ", offset %lu", entry->entry.file_delta);
1465 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1467 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1468 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1469 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1470 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1471 entry->entry.address.scstruct.sca_offset);
1472 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1474 unsigned long i;
1476 fprintf (f, ", la [");
1477 for (i = 0; i < entry->entry.la_size; i++)
1478 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1479 fprintf (f, "]");
1481 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1482 fprintf (f, ", bigla %lu, biglakind %u",
1483 entry->entry.address.biglastruct.big_la,
1484 entry->entry.address.biglastruct.big_la_kind);
1486 else
1487 fprintf (f, ", la [INVALID]");
1490 void
1491 bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
1492 bfd *abfd;
1493 FILE *f;
1494 bfd_sym_contained_statements_table_entry *entry;
1496 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1498 fprintf (f, "END");
1499 return;
1502 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1504 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1505 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1506 return;
1509 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1510 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1511 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1512 entry->entry.mte_index,
1513 entry->entry.mte_offset,
1514 entry->entry.file_delta);
1517 void
1518 bfd_sym_print_contained_labels_table_entry (abfd, f, entry)
1519 bfd *abfd;
1520 FILE *f;
1521 bfd_sym_contained_labels_table_entry *entry;
1523 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1525 fprintf (f, "END");
1526 return;
1529 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1531 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1532 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1533 return;
1536 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1537 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1538 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1539 entry->entry.mte_index,
1540 entry->entry.mte_offset,
1541 entry->entry.file_delta,
1542 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1545 void
1546 bfd_sym_print_contained_types_table_entry (abfd, f, entry)
1547 bfd *abfd ATTRIBUTE_UNUSED;
1548 FILE *f;
1549 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED;
1551 fprintf (f, "[UNIMPLEMENTED]");
1554 const char *
1555 bfd_sym_type_operator_name (num)
1556 unsigned char num;
1558 switch (num)
1560 case 1: return "TTE";
1561 case 2: return "PointerTo";
1562 case 3: return "ScalarOf";
1563 case 4: return "ConstantOf";
1564 case 5: return "EnumerationOf";
1565 case 6: return "VectorOf";
1566 case 7: return "RecordOf";
1567 case 8: return "UnionOf";
1568 case 9: return "SubRangeOf";
1569 case 10: return "SetOf";
1570 case 11: return "NamedTypeOf";
1571 case 12: return "ProcOf";
1572 case 13: return "ValueOf";
1573 case 14: return "ArrayOf";
1574 default: return "[UNKNOWN OPERATOR]";
1578 const char *
1579 bfd_sym_type_basic_name (num)
1580 unsigned char num;
1582 switch (num)
1584 case 0: return "void";
1585 case 1: return "pascal string";
1586 case 2: return "unsigned long";
1587 case 3: return "signed long";
1588 case 4: return "extended (10 bytes)";
1589 case 5: return "pascal boolean (1 byte)";
1590 case 6: return "unsigned byte";
1591 case 7: return "signed byte";
1592 case 8: return "character (1 byte)";
1593 case 9: return "wide character (2 bytes)";
1594 case 10: return "unsigned short";
1595 case 11: return "signed short";
1596 case 12: return "singled";
1597 case 13: return "double";
1598 case 14: return "extended (12 bytes)";
1599 case 15: return "computational (8 bytes)";
1600 case 16: return "c string";
1601 case 17: return "as-is string";
1602 default: return "[UNKNOWN BASIC TYPE]";
1607 bfd_sym_fetch_long (buf, len, offset, offsetptr, value)
1608 unsigned char *buf;
1609 unsigned long len;
1610 unsigned long offset;
1611 unsigned long *offsetptr;
1612 long *value;
1614 int ret;
1616 if (offset >= len)
1618 *value = 0;
1619 offset += 0;
1620 ret = -1;
1622 else if (! (buf[offset] & 0x80))
1624 *value = buf[offset];
1625 offset += 1;
1626 ret = 0;
1628 else if (buf[offset] == 0xc0)
1630 if ((offset + 5) > len)
1632 *value = 0;
1633 offset = len;
1634 ret = -1;
1636 else
1638 *value = bfd_getb32 (buf + offset + 1);
1639 offset += 5;
1640 ret = 0;
1643 else if ((buf[offset] & 0xc0) == 0xc0)
1645 *value = -(buf[offset] & 0x3f);
1646 offset += 1;
1647 ret = 0;
1649 else if ((buf[offset] & 0xc0) == 0x80)
1651 if ((offset + 2) > len)
1653 *value = 0;
1654 offset = len;
1655 ret = -1;
1657 else
1659 *value = bfd_getb16 (buf + offset) & 0x3fff;
1660 offset += 2;
1661 ret = 0;
1664 else
1665 abort ();
1667 if (offsetptr != NULL)
1668 *offsetptr = offset;
1670 return ret;
1673 void
1674 bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
1675 bfd *abfd;
1676 FILE *f;
1677 unsigned char *buf;
1678 unsigned long len;
1679 unsigned long offset;
1680 unsigned long *offsetptr;
1682 unsigned int type;
1684 if (offset >= len)
1686 fprintf (f, "[NULL]");
1688 if (offsetptr != NULL)
1689 *offsetptr = offset;
1690 return;
1693 type = buf[offset];
1694 offset++;
1696 if (! (type & 0x80))
1698 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1700 if (offsetptr != NULL)
1701 *offsetptr = offset;
1702 return;
1705 if (type & 0x40)
1706 fprintf (f, "[packed ");
1707 else
1708 fprintf (f, "[");
1710 switch (type & 0x3f)
1712 case 1:
1714 long value;
1715 bfd_sym_type_information_table_entry tinfo;
1717 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1718 if (value <= 0)
1719 fprintf (f, "[INVALID]");
1720 else
1722 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1723 fprintf (f, "[INVALID]");
1724 else
1725 fprintf (f, "\"%.*s\"",
1726 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1727 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1729 fprintf (f, " (TTE %lu)", value);
1730 break;
1733 case 2:
1734 fprintf (f, "pointer (0x%x) to ", type);
1735 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1736 break;
1738 case 3:
1740 unsigned long value;
1742 fprintf (f, "scalar (0x%x) of ", type);
1743 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1744 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1745 fprintf (f, " (%lu)", value);
1746 break;
1749 case 5:
1751 unsigned long lower, upper, nelem;
1752 unsigned long i;
1754 fprintf (f, "enumeration (0x%x) of ", type);
1755 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1756 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1757 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1758 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1759 fprintf (f, " from %lu to %lu with %lu elements: ", lower, upper, nelem);
1761 for (i = 0; i < nelem; i++)
1763 fprintf (f, "\n ");
1764 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1766 break;
1769 case 6:
1770 fprintf (f, "vector (0x%x)", type);
1771 fprintf (f, "\n index ");
1772 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1773 fprintf (f, "\n target ");
1774 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1775 break;
1777 case 7:
1778 case 8:
1780 long nrec, eloff, i;
1782 if ((type & 0x3f) == 7)
1783 fprintf (f, "record (0x%x) of ", type);
1784 else
1785 fprintf (f, "union (0x%x) of ", type);
1787 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1788 fprintf (f, "%lu elements: ", nrec);
1790 for (i = 0; i < nrec; i++)
1792 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1793 fprintf (f, "\n ");
1794 fprintf (f, "offset %lu: ", eloff);
1795 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1797 break;
1800 case 9:
1801 fprintf (f, "subrange (0x%x) of ", type);
1802 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1803 fprintf (f, " lower ");
1804 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1805 fprintf (f, " upper ");
1806 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1807 break;
1809 case 11:
1811 long value;
1813 fprintf (f, "named type (0x%x) ", type);
1814 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1815 if (value <= 0)
1816 fprintf (f, "[INVALID]");
1817 else
1818 fprintf (f, "\"%.*s\"",
1819 bfd_sym_symbol_name (abfd, value)[0],
1820 &bfd_sym_symbol_name (abfd, value)[1]);
1822 fprintf (f, " (NTE %lu) with type ", value);
1823 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1824 break;
1827 default:
1828 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1829 break;
1832 if (type == (0x40 | 0x6))
1834 /* Vector. */
1835 long n, width, m;
1836 long l;
1837 long i;
1839 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1840 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1841 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1842 /* fprintf (f, "\n "); */
1843 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1844 for (i = 0; i < m; i++)
1846 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1847 if (i != 0)
1848 fprintf (f, " ");
1849 fprintf (f, "%ld", l);
1852 else if (type & 0x40)
1854 /* Other packed type. */
1855 long msb, lsb;
1857 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1858 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1859 /* fprintf (f, "\n "); */
1860 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1863 fprintf (f, "]");
1865 if (offsetptr != NULL)
1866 *offsetptr = offset;
1869 void
1870 bfd_sym_print_type_information_table_entry (abfd, f, entry)
1871 bfd *abfd;
1872 FILE *f;
1873 bfd_sym_type_information_table_entry *entry;
1875 unsigned char *buf;
1876 unsigned long offset;
1877 unsigned int i;
1879 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1880 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1881 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1882 entry->nte_index,
1883 entry->physical_size, entry->offset, entry->logical_size);
1885 fprintf (f, "\n ");
1887 buf = alloca (entry->physical_size);
1888 if (buf == NULL)
1890 fprintf (f, "[ERROR]\n");
1891 return;
1893 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1895 fprintf (f, "[ERROR]\n");
1896 return;
1898 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1900 fprintf (f, "[ERROR]\n");
1901 return;
1904 fprintf (f, "[");
1905 for (i = 0; i < entry->physical_size; i++)
1907 if (i == 0)
1908 fprintf (f, "0x%02x", buf[i]);
1909 else
1910 fprintf (f, " 0x%02x", buf[i]);
1913 fprintf (f, "]");
1914 fprintf (f, "\n ");
1916 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1918 if (offset != entry->physical_size)
1919 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); }
1921 void
1922 bfd_sym_print_file_references_index_table_entry (abfd, f, entry)
1923 bfd *abfd ATTRIBUTE_UNUSED;
1924 FILE *f;
1925 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED;
1927 fprintf (f, "[UNIMPLEMENTED]");
1930 void
1931 bfd_sym_print_constant_pool_entry (abfd, f, entry)
1932 bfd *abfd ATTRIBUTE_UNUSED;
1933 FILE *f;
1934 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED;
1936 fprintf (f, "[UNIMPLEMENTED]");
1939 unsigned char *
1940 bfd_sym_display_name_table_entry (abfd, f, entry)
1941 bfd *abfd;
1942 FILE *f;
1943 unsigned char *entry;
1945 unsigned long index;
1946 unsigned long offset;
1947 bfd_sym_data_struct *sdata = NULL;
1949 BFD_ASSERT (bfd_sym_valid (abfd));
1950 sdata = abfd->tdata.sym_data;
1951 index = (entry - sdata->name_table) / 2;
1953 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1955 unsigned short length = bfd_getb16 (entry + 2);
1956 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
1957 offset = 2 + length + 1;
1959 else
1961 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1962 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
1964 if (sdata->version >= BFD_SYM_VERSION_3_4)
1965 offset = entry[0] + 2;
1966 else
1967 offset = entry[0] + 1;
1970 return (entry + offset + (offset % 2));
1973 void
1974 bfd_sym_display_name_table (abfd, f)
1975 bfd *abfd;
1976 FILE *f;
1978 unsigned long name_table_len;
1979 unsigned char *name_table, *name_table_end, *cur;
1980 bfd_sym_data_struct *sdata = NULL;
1982 BFD_ASSERT (bfd_sym_valid (abfd));
1983 sdata = abfd->tdata.sym_data;
1985 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1986 name_table = sdata->name_table;
1987 name_table_end = name_table + name_table_len;
1989 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1991 cur = name_table;
1992 for (;;)
1994 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1995 if (cur >= name_table_end)
1996 break;
2000 void
2001 bfd_sym_display_resources_table (abfd, f)
2002 bfd *abfd;
2003 FILE *f;
2005 unsigned long i;
2006 bfd_sym_resources_table_entry entry;
2007 bfd_sym_data_struct *sdata = NULL;
2009 BFD_ASSERT (bfd_sym_valid (abfd));
2010 sdata = abfd->tdata.sym_data;
2012 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
2013 sdata->header.dshb_rte.dti_object_count);
2015 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
2017 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
2018 fprintf (f, " [%8lu] [INVALID]\n", i);
2019 else
2021 fprintf (f, " [%8lu] ", i);
2022 bfd_sym_print_resources_table_entry (abfd, f, &entry);
2023 fprintf (f, "\n");
2028 void
2029 bfd_sym_display_modules_table (abfd, f)
2030 bfd *abfd;
2031 FILE *f;
2033 unsigned long i;
2034 bfd_sym_modules_table_entry entry;
2035 bfd_sym_data_struct *sdata = NULL;
2037 BFD_ASSERT (bfd_sym_valid (abfd));
2038 sdata = abfd->tdata.sym_data;
2040 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
2041 sdata->header.dshb_mte.dti_object_count);
2043 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
2045 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
2046 fprintf (f, " [%8lu] [INVALID]\n", i);
2047 else
2049 fprintf (f, " [%8lu] ", i);
2050 bfd_sym_print_modules_table_entry (abfd, f, &entry);
2051 fprintf (f, "\n");
2056 void
2057 bfd_sym_display_file_references_table (abfd, f)
2058 bfd *abfd;
2059 FILE *f;
2061 unsigned long i;
2062 bfd_sym_file_references_table_entry entry;
2063 bfd_sym_data_struct *sdata = NULL;
2065 BFD_ASSERT (bfd_sym_valid (abfd));
2066 sdata = abfd->tdata.sym_data;
2068 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
2069 sdata->header.dshb_frte.dti_object_count);
2071 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
2073 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
2074 fprintf (f, " [%8lu] [INVALID]\n", i);
2075 else
2077 fprintf (f, " [%8lu] ", i);
2078 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
2079 fprintf (f, "\n");
2084 void
2085 bfd_sym_display_contained_modules_table (abfd, f)
2086 bfd *abfd;
2087 FILE *f;
2089 unsigned long i;
2090 bfd_sym_contained_modules_table_entry entry;
2091 bfd_sym_data_struct *sdata = NULL;
2093 BFD_ASSERT (bfd_sym_valid (abfd));
2094 sdata = abfd->tdata.sym_data;
2096 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
2097 sdata->header.dshb_cmte.dti_object_count);
2099 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2101 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
2102 fprintf (f, " [%8lu] [INVALID]\n", i);
2103 else
2105 fprintf (f, " [%8lu] ", i);
2106 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
2107 fprintf (f, "\n");
2112 void
2113 bfd_sym_display_contained_variables_table (abfd, f)
2114 bfd *abfd;
2115 FILE *f;
2117 unsigned long i;
2118 bfd_sym_contained_variables_table_entry entry;
2119 bfd_sym_data_struct *sdata = NULL;
2121 BFD_ASSERT (bfd_sym_valid (abfd));
2122 sdata = abfd->tdata.sym_data;
2124 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2125 sdata->header.dshb_cvte.dti_object_count);
2127 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2129 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2130 fprintf (f, " [%8lu] [INVALID]\n", i);
2131 else
2133 fprintf (f, " [%8lu] ", i);
2134 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2135 fprintf (f, "\n");
2139 fprintf (f, "\n");
2142 void
2143 bfd_sym_display_contained_statements_table (abfd, f)
2144 bfd *abfd;
2145 FILE *f;
2147 unsigned long i;
2148 bfd_sym_contained_statements_table_entry entry;
2149 bfd_sym_data_struct *sdata = NULL;
2151 BFD_ASSERT (bfd_sym_valid (abfd));
2152 sdata = abfd->tdata.sym_data;
2154 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
2155 sdata->header.dshb_csnte.dti_object_count);
2157 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2159 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
2160 fprintf (f, " [%8lu] [INVALID]\n", i);
2161 else
2163 fprintf (f, " [%8lu] ", i);
2164 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
2165 fprintf (f, "\n");
2170 void
2171 bfd_sym_display_contained_labels_table (abfd, f)
2172 bfd *abfd;
2173 FILE *f;
2175 unsigned long i;
2176 bfd_sym_contained_labels_table_entry entry;
2177 bfd_sym_data_struct *sdata = NULL;
2179 BFD_ASSERT (bfd_sym_valid (abfd));
2180 sdata = abfd->tdata.sym_data;
2182 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
2183 sdata->header.dshb_clte.dti_object_count);
2185 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2187 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
2188 fprintf (f, " [%8lu] [INVALID]\n", i);
2189 else
2191 fprintf (f, " [%8lu] ", i);
2192 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
2193 fprintf (f, "\n");
2198 void
2199 bfd_sym_display_contained_types_table (abfd, f)
2200 bfd *abfd;
2201 FILE *f;
2203 unsigned long i;
2204 bfd_sym_contained_types_table_entry entry;
2205 bfd_sym_data_struct *sdata = NULL;
2207 BFD_ASSERT (bfd_sym_valid (abfd));
2208 sdata = abfd->tdata.sym_data;
2210 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
2211 sdata->header.dshb_ctte.dti_object_count);
2213 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2215 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2216 fprintf (f, " [%8lu] [INVALID]\n", i);
2217 else
2219 fprintf (f, " [%8lu] ", i);
2220 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2221 fprintf (f, "\n");
2226 void
2227 bfd_sym_display_file_references_index_table (abfd, f)
2228 bfd *abfd;
2229 FILE *f;
2231 unsigned long i;
2232 bfd_sym_file_references_index_table_entry entry;
2233 bfd_sym_data_struct *sdata = NULL;
2235 BFD_ASSERT (bfd_sym_valid (abfd));
2236 sdata = abfd->tdata.sym_data;
2238 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
2239 sdata->header.dshb_fite.dti_object_count);
2241 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2243 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2244 fprintf (f, " [%8lu] [INVALID]\n", i);
2245 else
2247 fprintf (f, " [%8lu] ", i);
2248 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2249 fprintf (f, "\n");
2254 void
2255 bfd_sym_display_constant_pool (abfd, f)
2256 bfd *abfd;
2257 FILE *f;
2259 unsigned long i;
2260 bfd_sym_constant_pool_entry entry;
2261 bfd_sym_data_struct *sdata = NULL;
2263 BFD_ASSERT (bfd_sym_valid (abfd));
2264 sdata = abfd->tdata.sym_data;
2266 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2267 sdata->header.dshb_const.dti_object_count);
2269 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2271 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2272 fprintf (f, " [%8lu] [INVALID]\n", i);
2273 else
2275 fprintf (f, " [%8lu] ", i);
2276 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2277 fprintf (f, "\n");
2282 void
2283 bfd_sym_display_type_information_table (abfd, f)
2284 bfd *abfd;
2285 FILE *f;
2287 unsigned long i;
2288 bfd_sym_type_table_entry index;
2289 bfd_sym_type_information_table_entry entry;
2290 bfd_sym_data_struct *sdata = NULL;
2292 BFD_ASSERT (bfd_sym_valid (abfd));
2293 sdata = abfd->tdata.sym_data;
2295 if (sdata->header.dshb_tte.dti_object_count > 99)
2296 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2297 sdata->header.dshb_tte.dti_object_count - 99);
2298 else
2300 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2301 return;
2304 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2306 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
2307 fprintf (f, " [%8lu] [INVALID]\n", i);
2308 else
2310 fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
2312 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
2313 fprintf (f, "[INVALID]");
2314 else
2315 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2317 fprintf (f, "\n");
2323 bfd_sym_scan (abfd, version, mdata)
2324 bfd *abfd;
2325 bfd_sym_version version;
2326 bfd_sym_data_struct *mdata;
2328 asection *bfdsec;
2329 const char *name = "symbols";
2331 mdata->name_table = 0;
2332 mdata->sbfd = abfd;
2333 mdata->version = version;
2335 bfd_seek (abfd, 0, SEEK_SET);
2336 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2337 return -1;
2339 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2340 if (mdata->name_table == NULL)
2341 return -1;
2343 bfdsec = bfd_make_section_anyway (abfd, name);
2344 if (bfdsec == NULL)
2345 return -1;
2347 bfdsec->vma = 0;
2348 bfdsec->lma = 0;
2349 bfdsec->size = 0;
2350 bfdsec->filepos = 0;
2351 bfdsec->alignment_power = 0;
2353 bfdsec->flags = SEC_HAS_CONTENTS;
2355 abfd->tdata.sym_data = mdata;
2357 return 0;
2360 const bfd_target *
2361 bfd_sym_object_p (abfd)
2362 bfd *abfd;
2364 struct bfd_preserve preserve;
2365 bfd_sym_version version = -1;
2367 preserve.marker = NULL;
2368 bfd_seek (abfd, 0, SEEK_SET);
2369 if (bfd_sym_read_version (abfd, &version) != 0)
2370 goto wrong;
2372 preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
2373 if (preserve.marker == NULL
2374 || ! bfd_preserve_save (abfd, &preserve))
2375 goto fail;
2377 if (bfd_sym_scan (abfd, version,
2378 (bfd_sym_data_struct *) preserve.marker) != 0)
2379 goto wrong;
2381 bfd_preserve_finish (abfd, &preserve);
2382 return abfd->xvec;
2384 wrong:
2385 bfd_set_error (bfd_error_wrong_format);
2387 fail:
2388 if (preserve.marker != NULL)
2389 bfd_preserve_restore (abfd, &preserve);
2390 return NULL;
2393 asymbol *
2394 bfd_sym_make_empty_symbol (abfd)
2395 bfd *abfd;
2397 return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
2400 void
2401 bfd_sym_get_symbol_info (abfd, symbol, ret)
2402 bfd *abfd ATTRIBUTE_UNUSED;
2403 asymbol *symbol;
2404 symbol_info *ret;
2406 bfd_symbol_info (symbol, ret);
2409 long
2410 bfd_sym_get_symtab_upper_bound (abfd)
2411 bfd *abfd ATTRIBUTE_UNUSED;
2413 return 0;
2416 long
2417 bfd_sym_canonicalize_symtab (abfd, sym)
2418 bfd *abfd ATTRIBUTE_UNUSED;
2419 asymbol **sym ATTRIBUTE_UNUSED;
2421 return 0;
2425 bfd_sym_sizeof_headers (abfd, exec)
2426 bfd *abfd ATTRIBUTE_UNUSED;
2427 bfd_boolean exec ATTRIBUTE_UNUSED;
2429 return 0;
2432 const bfd_target sym_vec =
2434 "sym", /* name */
2435 bfd_target_sym_flavour, /* flavour */
2436 BFD_ENDIAN_BIG, /* byteorder */
2437 BFD_ENDIAN_BIG, /* header_byteorder */
2438 (HAS_RELOC | EXEC_P | /* object flags */
2439 HAS_LINENO | HAS_DEBUG |
2440 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2441 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2442 | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
2443 0, /* symbol_leading_char */
2444 ' ', /* ar_pad_char */
2445 16, /* ar_max_namelen */
2446 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2447 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2448 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
2449 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2450 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2451 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
2452 { /* bfd_check_format */
2453 _bfd_dummy_target,
2454 bfd_sym_object_p, /* bfd_check_format */
2455 _bfd_dummy_target,
2456 _bfd_dummy_target,
2458 { /* bfd_set_format */
2459 bfd_false,
2460 bfd_sym_mkobject,
2461 bfd_false,
2462 bfd_false,
2464 { /* bfd_write_contents */
2465 bfd_false,
2466 bfd_true,
2467 bfd_false,
2468 bfd_false,
2471 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2472 BFD_JUMP_TABLE_COPY (_bfd_generic),
2473 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2474 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2475 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2476 BFD_JUMP_TABLE_RELOCS (bfd_sym),
2477 BFD_JUMP_TABLE_WRITE (bfd_sym),
2478 BFD_JUMP_TABLE_LINK (bfd_sym),
2479 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2481 NULL,
2483 NULL