daily update
[deliverable/binutils-gdb.git] / bfd / xsym.c
1 /* xSYM symbol-file support for BFD.
2 Copyright 1999, 2000, 2001, 2002, 2003
3 Free Software Foundation, Inc.
4
5 This file is part of BFD, the Binary File Descriptor library.
6
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.
11
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.
16
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. */
20
21 #include "xsym.h"
22 #include "bfd.h"
23 #include "sysdep.h"
24 #include "libbfd.h"
25
26 #define bfd_sym_close_and_cleanup _bfd_generic_close_and_cleanup
27 #define bfd_sym_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
28 #define bfd_sym_new_section_hook _bfd_generic_new_section_hook
29 #define bfd_sym_bfd_is_local_label_name bfd_generic_is_local_label_name
30 #define bfd_sym_get_lineno _bfd_nosymbols_get_lineno
31 #define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line
32 #define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
33 #define bfd_sym_read_minisymbols _bfd_generic_read_minisymbols
34 #define bfd_sym_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
35 #define bfd_sym_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
36 #define bfd_sym_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
37 #define bfd_sym_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
38 #define bfd_sym_set_arch_mach _bfd_generic_set_arch_mach
39 #define bfd_sym_get_section_contents _bfd_generic_get_section_contents
40 #define bfd_sym_set_section_contents _bfd_generic_set_section_contents
41 #define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
42 #define bfd_sym_bfd_relax_section bfd_generic_relax_section
43 #define bfd_sym_bfd_gc_sections bfd_generic_gc_sections
44 #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections
45 #define bfd_sym_bfd_discard_group bfd_generic_discard_group
46 #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
47 #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
48 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
49 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
50 #define bfd_sym_bfd_final_link _bfd_generic_final_link
51 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
52 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
53
54 static int pstrcmp PARAMS ((unsigned char *, unsigned char *));
55 static unsigned long compute_offset
56 PARAMS ((unsigned long, unsigned long, unsigned long, unsigned long));
57
58 extern const bfd_target sym_vec;
59
60 static int
61 pstrcmp (a, b)
62 unsigned char *a;
63 unsigned char *b;
64 {
65 unsigned char clen;
66 int ret;
67
68 clen = (a[0] > b[0]) ? a[0] : b[0];
69 ret = memcmp (a + 1, b + 1, clen);
70 if (ret != 0)
71 return ret;
72
73 if (a[0] == b[0])
74 return 0;
75 else if (a[0] < b[0])
76 return -1;
77 else
78 return 0;
79 }
80
81 static unsigned long
82 compute_offset (first_page, page_size, entry_size, index)
83 unsigned long first_page;
84 unsigned long page_size;
85 unsigned long entry_size;
86 unsigned long index;
87 {
88 unsigned long entries_per_page = page_size / entry_size;
89 unsigned long page_number = first_page + (index / entries_per_page);
90 unsigned long page_offset = (index % entries_per_page) * entry_size;
91
92 return (page_number * page_size) + page_offset;
93 }
94
95 bfd_boolean
96 bfd_sym_mkobject (abfd)
97 bfd *abfd ATTRIBUTE_UNUSED;
98 {
99 return 1;
100 }
101
102 void
103 bfd_sym_print_symbol (abfd, afile, symbol, how)
104 bfd *abfd ATTRIBUTE_UNUSED;
105 PTR afile ATTRIBUTE_UNUSED;
106 asymbol *symbol ATTRIBUTE_UNUSED;
107 bfd_print_symbol_type how ATTRIBUTE_UNUSED;
108 {
109 return;
110 }
111
112 bfd_boolean
113 bfd_sym_valid (abfd)
114 bfd *abfd;
115 {
116 if (abfd == NULL || abfd->xvec == NULL)
117 return 0;
118
119 return abfd->xvec == &sym_vec;
120 }
121
122 unsigned char *
123 bfd_sym_read_name_table (abfd, dshb)
124 bfd *abfd;
125 bfd_sym_header_block *dshb;
126 {
127 unsigned char *rstr;
128 long ret;
129 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
130 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
131
132 rstr = (unsigned char *) bfd_alloc (abfd, table_size);
133 if (rstr == NULL)
134 return rstr;
135
136 bfd_seek (abfd, table_offset, SEEK_SET);
137 ret = bfd_bread (rstr, table_size, abfd);
138 if (ret < 0 || (unsigned long) ret != table_size)
139 {
140 bfd_release (abfd, rstr);
141 return NULL;
142 }
143
144 return rstr;
145 }
146
147 void
148 bfd_sym_parse_file_reference_v32 (buf, len, entry)
149 unsigned char *buf;
150 size_t len;
151 bfd_sym_file_reference *entry;
152 {
153 BFD_ASSERT (len == 6);
154
155 entry->fref_frte_index = bfd_getb16 (buf);
156 entry->fref_offset = bfd_getb32 (buf + 2);
157 }
158
159 void
160 bfd_sym_parse_disk_table_v32 (buf, len, table)
161 unsigned char *buf;
162 size_t len;
163 bfd_sym_table_info *table;
164 {
165 BFD_ASSERT (len == 8);
166
167 table->dti_first_page = bfd_getb16 (buf);
168 table->dti_page_count = bfd_getb16 (buf + 2);
169 table->dti_object_count = bfd_getb32 (buf + 4);
170 }
171
172 void
173 bfd_sym_parse_header_v32 (buf, len, header)
174 unsigned char *buf;
175 size_t len;
176 bfd_sym_header_block *header;
177 {
178 BFD_ASSERT (len == 154);
179
180 memcpy (header->dshb_id, buf, 32);
181 header->dshb_page_size = bfd_getb16 (buf + 32);
182 header->dshb_hash_page = bfd_getb16 (buf + 34);
183 header->dshb_root_mte = bfd_getb16 (buf + 36);
184 header->dshb_mod_date = bfd_getb32 (buf + 38);
185
186 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
187 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
188 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
189 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
190 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
191 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
192 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
193 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
194 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
195 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
196 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
197 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
198 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
199
200 memcpy (&header->dshb_file_creator, buf + 146, 4);
201 memcpy (&header->dshb_file_type, buf + 150, 4);
202 }
203
204 int
205 bfd_sym_read_header_v32 (abfd, header)
206 bfd *abfd;
207 bfd_sym_header_block *header;
208 {
209 unsigned char buf[154];
210 long ret;
211
212 ret = bfd_bread (buf, 154, abfd);
213 if (ret != 154)
214 return -1;
215
216 bfd_sym_parse_header_v32 (buf, 154, header);
217
218 return 0;
219 }
220
221 int
222 bfd_sym_read_header_v34 (abfd, header)
223 bfd *abfd ATTRIBUTE_UNUSED;
224 bfd_sym_header_block *header ATTRIBUTE_UNUSED;
225 {
226 abort ();
227 }
228
229 int
230 bfd_sym_read_header (abfd, header, version)
231 bfd *abfd;
232 bfd_sym_header_block *header;
233 bfd_sym_version version;
234 {
235 switch (version)
236 {
237 case BFD_SYM_VERSION_3_5:
238 case BFD_SYM_VERSION_3_4:
239 return bfd_sym_read_header_v34 (abfd, header);
240 case BFD_SYM_VERSION_3_3:
241 case BFD_SYM_VERSION_3_2:
242 return bfd_sym_read_header_v32 (abfd, header);
243 case BFD_SYM_VERSION_3_1:
244 default:
245 return FALSE;
246 }
247 }
248
249 int
250 bfd_sym_read_version (abfd, version)
251 bfd *abfd;
252 bfd_sym_version *version;
253 {
254 unsigned char version_string[32];
255 long ret;
256
257 ret = bfd_bread (version_string, sizeof (version_string), abfd);
258 if (ret != sizeof (version_string))
259 return -1;
260
261 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
262 *version = BFD_SYM_VERSION_3_1;
263 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
264 *version = BFD_SYM_VERSION_3_2;
265 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
266 *version = BFD_SYM_VERSION_3_3;
267 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
268 *version = BFD_SYM_VERSION_3_4;
269 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
270 *version = BFD_SYM_VERSION_3_5;
271 else
272 return -1;
273
274 return 0;
275 }
276
277 void
278 bfd_sym_display_table_summary (f, dti, name)
279 FILE *f;
280 bfd_sym_table_info *dti;
281 const char *name;
282 {
283 fprintf (f, "%-6s %13ld %13ld %13ld\n",
284 name,
285 dti->dti_first_page,
286 dti->dti_page_count,
287 dti->dti_object_count);
288 }
289
290 void
291 bfd_sym_display_header (f, dshb)
292 FILE *f;
293 bfd_sym_header_block *dshb;
294 {
295 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
296 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
297 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
298 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
299 fprintf (f, " Modification Date: ");
300 fprintf (f, "[unimplemented]");
301 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
302
303 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
304 dshb->dshb_file_creator, dshb->dshb_file_type);
305
306 fprintf (f, "Table Name First Page Page Count Object Count\n");
307 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
308
309 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
310 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
311 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
312 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
313 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
314 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
315 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
316 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
317 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
318 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
319 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
320 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
321 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
322
323 fprintf (f, "\n");
324 }
325
326 void
327 bfd_sym_parse_resources_table_entry_v32 (buf, len, entry)
328 unsigned char *buf;
329 size_t len;
330 bfd_sym_resources_table_entry *entry;
331 {
332 BFD_ASSERT (len == 18);
333
334 memcpy (&entry->rte_res_type, buf, 4);
335 entry->rte_res_number = bfd_getb16 (buf + 4);
336 entry->rte_nte_index = bfd_getb32 (buf + 6);
337 entry->rte_mte_first = bfd_getb16 (buf + 10);
338 entry->rte_mte_last = bfd_getb16 (buf + 12);
339 entry->rte_res_size = bfd_getb32 (buf + 14);
340 }
341
342 void
343 bfd_sym_parse_modules_table_entry_v33 (buf, len, entry)
344 unsigned char *buf;
345 size_t len;
346 bfd_sym_modules_table_entry *entry;
347 {
348 BFD_ASSERT (len == 46);
349
350 entry->mte_rte_index = bfd_getb16 (buf);
351 entry->mte_res_offset = bfd_getb32 (buf + 2);
352 entry->mte_size = bfd_getb32 (buf + 6);
353 entry->mte_kind = buf[10];
354 entry->mte_scope = buf[11];
355 entry->mte_parent = bfd_getb16 (buf + 12);
356 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
357 entry->mte_imp_end = bfd_getb32 (buf + 20);
358 entry->mte_nte_index = bfd_getb32 (buf + 24);
359 entry->mte_cmte_index = bfd_getb16 (buf + 28);
360 entry->mte_cvte_index = bfd_getb32 (buf + 30);
361 entry->mte_clte_index = bfd_getb16 (buf + 34);
362 entry->mte_ctte_index = bfd_getb16 (buf + 36);
363 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
364 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
365 }
366
367 void
368 bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry)
369 unsigned char *buf;
370 size_t len;
371 bfd_sym_file_references_table_entry *entry;
372 {
373 unsigned int type;
374
375 BFD_ASSERT (len == 10);
376
377 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
378 type = bfd_getb16 (buf);
379
380 switch (type)
381 {
382 case BFD_SYM_END_OF_LIST_3_2:
383 entry->generic.type = BFD_SYM_END_OF_LIST;
384 break;
385
386 case BFD_SYM_FILE_NAME_INDEX_3_2:
387 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
388 entry->filename.nte_index = bfd_getb32 (buf + 2);
389 entry->filename.mod_date = bfd_getb32 (buf + 6);
390 break;
391
392 default:
393 entry->entry.mte_index = type;
394 entry->entry.file_offset = bfd_getb32 (buf + 2);
395 }
396 }
397
398 void
399 bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry)
400 unsigned char *buf;
401 size_t len;
402 bfd_sym_contained_modules_table_entry *entry;
403 {
404 unsigned int type;
405
406 BFD_ASSERT (len == 6);
407
408 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
409 type = bfd_getb16 (buf);
410
411 switch (type)
412 {
413 case BFD_SYM_END_OF_LIST_3_2:
414 entry->generic.type = BFD_SYM_END_OF_LIST;
415 break;
416
417 default:
418 entry->entry.mte_index = type;
419 entry->entry.nte_index = bfd_getb32 (buf + 2);
420 break;
421 }
422 }
423
424 void
425 bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry)
426 unsigned char *buf;
427 size_t len;
428 bfd_sym_contained_variables_table_entry *entry;
429 {
430 unsigned int type;
431
432 BFD_ASSERT (len == 26);
433
434 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
435 type = bfd_getb16 (buf);
436
437 switch (type)
438 {
439 case BFD_SYM_END_OF_LIST_3_2:
440 entry->generic.type = BFD_SYM_END_OF_LIST;
441 break;
442
443 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
444 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
445 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
446 break;
447
448 default:
449 entry->entry.tte_index = type;
450 entry->entry.nte_index = bfd_getb32 (buf + 2);
451 entry->entry.file_delta = bfd_getb16 (buf + 6);
452 entry->entry.scope = buf[8];
453 entry->entry.la_size = buf[9];
454
455 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
456 {
457 entry->entry.address.scstruct.sca_kind = buf[10];
458 entry->entry.address.scstruct.sca_class = buf[11];
459 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
460 }
461 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
462 {
463 memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA);
464 entry->entry.address.lastruct.la_kind = buf[23];
465 }
466 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
467 {
468 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
469 entry->entry.address.biglastruct.big_la_kind = buf[12];
470 }
471 }
472 }
473
474 void
475 bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
476 unsigned char *buf;
477 size_t len;
478 bfd_sym_contained_statements_table_entry *entry;
479 {
480 unsigned int type;
481
482 BFD_ASSERT (len == 8);
483
484 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
485 type = bfd_getb16 (buf);
486
487 switch (type)
488 {
489 case BFD_SYM_END_OF_LIST_3_2:
490 entry->generic.type = BFD_SYM_END_OF_LIST;
491 break;
492
493 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
494 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
495 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
496 break;
497
498 default:
499 entry->entry.mte_index = type;
500 entry->entry.mte_offset = bfd_getb16 (buf + 2);
501 entry->entry.file_delta = bfd_getb32 (buf + 4);
502 break;
503 }
504 }
505
506 void
507 bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
508 unsigned char *buf;
509 size_t len;
510 bfd_sym_contained_labels_table_entry *entry;
511 {
512 unsigned int type;
513
514 BFD_ASSERT (len == 12);
515
516 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
517 type = bfd_getb16 (buf);
518
519 switch (type)
520 {
521 case BFD_SYM_END_OF_LIST_3_2:
522 entry->generic.type = BFD_SYM_END_OF_LIST;
523 break;
524
525 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
526 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
527 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
528 break;
529
530 default:
531 entry->entry.mte_index = type;
532 entry->entry.mte_offset = bfd_getb16 (buf + 2);
533 entry->entry.nte_index = bfd_getb32 (buf + 4);
534 entry->entry.file_delta = bfd_getb16 (buf + 8);
535 entry->entry.scope = bfd_getb16 (buf + 10);
536 break;
537 }
538 }
539
540 void
541 bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
542 unsigned char *buf;
543 size_t len;
544 bfd_sym_type_table_entry *entry;
545 {
546 BFD_ASSERT (len == 4);
547
548 *entry = bfd_getb32 (buf);
549 }
550
551 int
552 bfd_sym_fetch_resources_table_entry (abfd, entry, index)
553 bfd *abfd;
554 bfd_sym_resources_table_entry *entry;
555 unsigned long index;
556 {
557 void (*parser) PARAMS ((unsigned char *, size_t,
558 bfd_sym_resources_table_entry *));
559 unsigned long offset;
560 unsigned long entry_size;
561 unsigned char buf[18];
562 bfd_sym_data_struct *sdata = NULL;
563
564 parser = NULL;
565 BFD_ASSERT (bfd_sym_valid (abfd));
566 sdata = abfd->tdata.sym_data;
567
568 if (index == 0)
569 return -1;
570
571 switch (sdata->version)
572 {
573 case BFD_SYM_VERSION_3_5:
574 case BFD_SYM_VERSION_3_4:
575 return -1;
576
577 case BFD_SYM_VERSION_3_3:
578 case BFD_SYM_VERSION_3_2:
579 entry_size = 18;
580 parser = bfd_sym_parse_resources_table_entry_v32;
581 break;
582
583 case BFD_SYM_VERSION_3_1:
584 default:
585 return -1;
586 }
587 if (parser == NULL)
588 return -1;
589
590 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
591 sdata->header.dshb_page_size,
592 entry_size, index);
593
594 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
595 return -1;
596 if (bfd_bread (buf, entry_size, abfd) != entry_size)
597 return -1;
598
599 (*parser) (buf, entry_size, entry);
600
601 return 0;
602 }
603
604 int
605 bfd_sym_fetch_modules_table_entry (abfd, entry, index)
606 bfd *abfd;
607 bfd_sym_modules_table_entry *entry;
608 unsigned long index;
609 {
610 void (*parser) PARAMS ((unsigned char *, size_t,
611 bfd_sym_modules_table_entry *));
612 unsigned long offset;
613 unsigned long entry_size;
614 unsigned char buf[46];
615 bfd_sym_data_struct *sdata = NULL;
616
617 parser = NULL;
618 BFD_ASSERT (bfd_sym_valid (abfd));
619 sdata = abfd->tdata.sym_data;
620
621 if (index == 0)
622 return -1;
623
624 switch (sdata->version)
625 {
626 case BFD_SYM_VERSION_3_5:
627 case BFD_SYM_VERSION_3_4:
628 return -1;
629
630 case BFD_SYM_VERSION_3_3:
631 entry_size = 46;
632 parser = bfd_sym_parse_modules_table_entry_v33;
633 break;
634
635 case BFD_SYM_VERSION_3_2:
636 case BFD_SYM_VERSION_3_1:
637 default:
638 return -1;
639 }
640 if (parser == NULL)
641 return -1;
642
643 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
644 sdata->header.dshb_page_size,
645 entry_size, index);
646
647 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
648 return -1;
649 if (bfd_bread (buf, entry_size, abfd) != entry_size)
650 return -1;
651
652 (*parser) (buf, entry_size, entry);
653
654 return 0;
655 }
656
657 int
658 bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
659 bfd *abfd;
660 bfd_sym_file_references_table_entry *entry;
661 unsigned long index;
662 {
663 void (*parser) PARAMS ((unsigned char *, size_t,
664 bfd_sym_file_references_table_entry *));
665 unsigned long offset;
666 unsigned long entry_size = 0;
667 unsigned char buf[8];
668 bfd_sym_data_struct *sdata = NULL;
669
670 parser = NULL;
671 BFD_ASSERT (bfd_sym_valid (abfd));
672 sdata = abfd->tdata.sym_data;
673
674 if (index == 0)
675 return -1;
676
677 switch (sdata->version)
678 {
679 case BFD_SYM_VERSION_3_3:
680 case BFD_SYM_VERSION_3_2:
681 entry_size = 10;
682 parser = bfd_sym_parse_file_references_table_entry_v32;
683 break;
684
685 case BFD_SYM_VERSION_3_5:
686 case BFD_SYM_VERSION_3_4:
687 case BFD_SYM_VERSION_3_1:
688 default:
689 break;
690 }
691
692 if (parser == NULL)
693 return -1;
694
695 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
696 sdata->header.dshb_page_size,
697 entry_size, index);
698
699 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
700 return -1;
701 if (bfd_bread (buf, entry_size, abfd) != entry_size)
702 return -1;
703
704 (*parser) (buf, entry_size, entry);
705
706 return 0;
707 }
708
709 int
710 bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
711 bfd *abfd;
712 bfd_sym_contained_modules_table_entry *entry;
713 unsigned long index;
714 {
715 void (*parser) PARAMS ((unsigned char *, size_t,
716 bfd_sym_contained_modules_table_entry *));
717 unsigned long offset;
718 unsigned long entry_size = 0;
719 unsigned char buf[6];
720 bfd_sym_data_struct *sdata = NULL;
721
722 parser = NULL;
723 BFD_ASSERT (bfd_sym_valid (abfd));
724 sdata = abfd->tdata.sym_data;
725
726 if (index == 0)
727 return -1;
728
729 switch (sdata->version)
730 {
731 case BFD_SYM_VERSION_3_3:
732 case BFD_SYM_VERSION_3_2:
733 entry_size = 6;
734 parser = bfd_sym_parse_contained_modules_table_entry_v32;
735 break;
736
737 case BFD_SYM_VERSION_3_5:
738 case BFD_SYM_VERSION_3_4:
739 case BFD_SYM_VERSION_3_1:
740 default:
741 break;
742 }
743
744 if (parser == NULL)
745 return -1;
746
747 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
748 sdata->header.dshb_page_size,
749 entry_size, index);
750
751 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
752 return -1;
753 if (bfd_bread (buf, entry_size, abfd) != entry_size)
754 return -1;
755
756 (*parser) (buf, entry_size, entry);
757
758 return 0;
759 }
760
761 int
762 bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
763 bfd *abfd;
764 bfd_sym_contained_variables_table_entry *entry;
765 unsigned long index;
766 {
767 void (*parser) PARAMS ((unsigned char *, size_t,
768 bfd_sym_contained_variables_table_entry *));
769 unsigned long offset;
770 unsigned long entry_size = 0;
771 unsigned char buf[26];
772 bfd_sym_data_struct *sdata = NULL;
773
774 parser = NULL;
775 BFD_ASSERT (bfd_sym_valid (abfd));
776 sdata = abfd->tdata.sym_data;
777
778 if (index == 0)
779 return -1;
780
781 switch (sdata->version)
782 {
783 case BFD_SYM_VERSION_3_3:
784 case BFD_SYM_VERSION_3_2:
785 entry_size = 26;
786 parser = bfd_sym_parse_contained_variables_table_entry_v32;
787 break;
788
789 case BFD_SYM_VERSION_3_5:
790 case BFD_SYM_VERSION_3_4:
791 case BFD_SYM_VERSION_3_1:
792 default:
793 break;
794 }
795
796 if (parser == NULL)
797 return -1;
798
799 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
800 sdata->header.dshb_page_size,
801 entry_size, index);
802
803 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
804 return -1;
805 if (bfd_bread (buf, entry_size, abfd) != entry_size)
806 return -1;
807
808 (*parser) (buf, entry_size, entry);
809
810 return 0;
811 }
812
813 int
814 bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
815 bfd *abfd;
816 bfd_sym_contained_statements_table_entry *entry;
817 unsigned long index;
818 {
819 void (*parser) PARAMS ((unsigned char *, size_t,
820 bfd_sym_contained_statements_table_entry *));
821 unsigned long offset;
822 unsigned long entry_size = 0;
823 unsigned char buf[8];
824 bfd_sym_data_struct *sdata = NULL;
825
826 parser = NULL;
827 BFD_ASSERT (bfd_sym_valid (abfd));
828 sdata = abfd->tdata.sym_data;
829
830 if (index == 0)
831 return -1;
832
833 switch (sdata->version)
834 {
835 case BFD_SYM_VERSION_3_3:
836 case BFD_SYM_VERSION_3_2:
837 entry_size = 8;
838 parser = bfd_sym_parse_contained_statements_table_entry_v32;
839 break;
840
841 case BFD_SYM_VERSION_3_5:
842 case BFD_SYM_VERSION_3_4:
843 case BFD_SYM_VERSION_3_1:
844 default:
845 break;
846 }
847
848 if (parser == NULL)
849 return -1;
850
851 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
852 sdata->header.dshb_page_size,
853 entry_size, index);
854
855 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
856 return -1;
857 if (bfd_bread (buf, entry_size, abfd) != entry_size)
858 return -1;
859
860 (*parser) (buf, entry_size, entry);
861
862 return 0;
863 }
864
865 int
866 bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
867 bfd *abfd;
868 bfd_sym_contained_labels_table_entry *entry;
869 unsigned long index;
870 {
871 void (*parser) PARAMS ((unsigned char *, size_t,
872 bfd_sym_contained_labels_table_entry *));
873 unsigned long offset;
874 unsigned long entry_size = 0;
875 unsigned char buf[12];
876 bfd_sym_data_struct *sdata = NULL;
877
878 parser = NULL;
879 BFD_ASSERT (bfd_sym_valid (abfd));
880 sdata = abfd->tdata.sym_data;
881
882 if (index == 0)
883 return -1;
884
885 switch (sdata->version)
886 {
887 case BFD_SYM_VERSION_3_3:
888 case BFD_SYM_VERSION_3_2:
889 entry_size = 12;
890 parser = bfd_sym_parse_contained_labels_table_entry_v32;
891 break;
892
893 case BFD_SYM_VERSION_3_5:
894 case BFD_SYM_VERSION_3_4:
895 case BFD_SYM_VERSION_3_1:
896 default:
897 break;
898 }
899
900 if (parser == NULL)
901 return -1;
902
903 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
904 sdata->header.dshb_page_size,
905 entry_size, index);
906
907 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
908 return -1;
909 if (bfd_bread (buf, entry_size, abfd) != entry_size)
910 return -1;
911
912 (*parser) (buf, entry_size, entry);
913
914 return 0;
915 }
916
917 int
918 bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
919 bfd *abfd;
920 bfd_sym_contained_types_table_entry *entry;
921 unsigned long index;
922 {
923 void (*parser) PARAMS ((unsigned char *, size_t,
924 bfd_sym_contained_types_table_entry *));
925 unsigned long offset;
926 unsigned long entry_size = 0;
927 unsigned char buf[0];
928 bfd_sym_data_struct *sdata = NULL;
929
930 parser = NULL;
931 BFD_ASSERT (bfd_sym_valid (abfd));
932 sdata = abfd->tdata.sym_data;
933
934 if (index == 0)
935 return -1;
936
937 switch (sdata->version)
938 {
939 case BFD_SYM_VERSION_3_3:
940 case BFD_SYM_VERSION_3_2:
941 entry_size = 0;
942 parser = NULL;
943 break;
944
945 case BFD_SYM_VERSION_3_5:
946 case BFD_SYM_VERSION_3_4:
947 case BFD_SYM_VERSION_3_1:
948 default:
949 break;
950 }
951
952 if (parser == NULL)
953 return -1;
954
955 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
956 sdata->header.dshb_page_size,
957 entry_size, index);
958
959 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
960 return -1;
961 if (bfd_bread (buf, entry_size, abfd) != entry_size)
962 return -1;
963
964 (*parser) (buf, entry_size, entry);
965
966 return 0;
967 }
968
969 int
970 bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
971 bfd *abfd;
972 bfd_sym_file_references_index_table_entry *entry;
973 unsigned long index;
974 {
975 void (*parser) PARAMS ((unsigned char *, size_t,
976 bfd_sym_file_references_index_table_entry *));
977 unsigned long offset;
978 unsigned long entry_size = 0;
979 unsigned char buf[0];
980 bfd_sym_data_struct *sdata = NULL;
981
982 parser = NULL;
983 BFD_ASSERT (bfd_sym_valid (abfd));
984 sdata = abfd->tdata.sym_data;
985
986 if (index == 0)
987 return -1;
988
989 switch (sdata->version)
990 {
991 case BFD_SYM_VERSION_3_3:
992 case BFD_SYM_VERSION_3_2:
993 entry_size = 0;
994 parser = NULL;
995 break;
996
997 case BFD_SYM_VERSION_3_5:
998 case BFD_SYM_VERSION_3_4:
999 case BFD_SYM_VERSION_3_1:
1000 default:
1001 break;
1002 }
1003
1004 if (parser == NULL)
1005 return -1;
1006
1007 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1008 sdata->header.dshb_page_size,
1009 entry_size, index);
1010
1011 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1012 return -1;
1013 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1014 return -1;
1015
1016 (*parser) (buf, entry_size, entry);
1017
1018 return 0;
1019 }
1020
1021 int
1022 bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
1023 bfd *abfd;
1024 bfd_sym_constant_pool_entry *entry;
1025 unsigned long index;
1026 {
1027 void (*parser) PARAMS ((unsigned char *, size_t,
1028 bfd_sym_constant_pool_entry *));
1029 unsigned long offset;
1030 unsigned long entry_size = 0;
1031 unsigned char buf[0];
1032 bfd_sym_data_struct *sdata = NULL;
1033
1034 parser = NULL;
1035 BFD_ASSERT (bfd_sym_valid (abfd));
1036 sdata = abfd->tdata.sym_data;
1037
1038 if (index == 0)
1039 return -1;
1040
1041 switch (sdata->version)
1042 {
1043 case BFD_SYM_VERSION_3_3:
1044 case BFD_SYM_VERSION_3_2:
1045 entry_size = 0;
1046 parser = NULL;
1047 break;
1048
1049 case BFD_SYM_VERSION_3_5:
1050 case BFD_SYM_VERSION_3_4:
1051 case BFD_SYM_VERSION_3_1:
1052 default:
1053 break;
1054 }
1055
1056 if (parser == NULL)
1057 return -1;
1058
1059 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
1060 sdata->header.dshb_page_size,
1061 entry_size, index);
1062
1063 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1064 return -1;
1065 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1066 return -1;
1067
1068 (*parser) (buf, entry_size, entry);
1069
1070 return 0;
1071 }
1072
1073 int
1074 bfd_sym_fetch_type_table_entry (abfd, entry, index)
1075 bfd *abfd;
1076 bfd_sym_type_table_entry *entry;
1077 unsigned long index;
1078 {
1079 void (*parser) PARAMS ((unsigned char *, size_t,
1080 bfd_sym_type_table_entry *));
1081 unsigned long offset;
1082 unsigned long entry_size = 0;
1083 unsigned char buf[4];
1084 bfd_sym_data_struct *sdata = NULL;
1085
1086 parser = NULL;
1087 BFD_ASSERT (bfd_sym_valid (abfd));
1088 sdata = abfd->tdata.sym_data;
1089
1090 switch (sdata->version)
1091 {
1092 case BFD_SYM_VERSION_3_3:
1093 case BFD_SYM_VERSION_3_2:
1094 entry_size = 4;
1095 parser = bfd_sym_parse_type_table_entry_v32;
1096 break;
1097
1098 case BFD_SYM_VERSION_3_5:
1099 case BFD_SYM_VERSION_3_4:
1100 case BFD_SYM_VERSION_3_1:
1101 default:
1102 break;
1103 }
1104
1105 if (parser == NULL)
1106 return -1;
1107
1108 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
1109 sdata->header.dshb_page_size,
1110 entry_size, index);
1111
1112 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1113 return -1;
1114 if (bfd_bread (buf, entry_size, abfd) != entry_size)
1115 return -1;
1116
1117 (*parser) (buf, entry_size, entry);
1118
1119 return 0;
1120 }
1121
1122 int
1123 bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
1124 bfd *abfd;
1125 bfd_sym_type_information_table_entry *entry;
1126 unsigned long offset;
1127 {
1128 unsigned char buf[4];
1129 bfd_sym_data_struct *sdata = NULL;
1130
1131 BFD_ASSERT (bfd_sym_valid (abfd));
1132 sdata = abfd->tdata.sym_data;
1133
1134 if (offset == 0)
1135 return -1;
1136
1137 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
1138 return -1;
1139
1140 if (bfd_bread (buf, 4, abfd) != 4)
1141 return -1;
1142 entry->nte_index = bfd_getb32 (buf);
1143
1144 if (bfd_bread (buf, 2, abfd) != 2)
1145 return -1;
1146 entry->physical_size = bfd_getb16 (buf);
1147
1148 if (entry->physical_size & 0x8000)
1149 {
1150 if (bfd_bread (buf, 4, abfd) != 4)
1151 return -1;
1152 entry->physical_size &= 0x7fff;
1153 entry->logical_size = bfd_getb32 (buf);
1154 entry->offset = offset + 10;
1155 }
1156 else
1157 {
1158 if (bfd_bread (buf, 2, abfd) != 2)
1159 return -1;
1160 entry->physical_size &= 0x7fff;
1161 entry->logical_size = bfd_getb16 (buf);
1162 entry->offset = offset + 8;
1163 }
1164
1165 return 0;
1166 }
1167
1168 int
1169 bfd_sym_fetch_type_table_information (abfd, entry, index)
1170 bfd *abfd;
1171 bfd_sym_type_information_table_entry *entry;
1172 unsigned long index;
1173 {
1174 bfd_sym_type_table_entry tindex;
1175 bfd_sym_data_struct *sdata = NULL;
1176
1177 BFD_ASSERT (bfd_sym_valid (abfd));
1178 sdata = abfd->tdata.sym_data;
1179
1180 if (sdata->header.dshb_tte.dti_object_count <= 99)
1181 return -1;
1182 if (index < 100)
1183 return -1;
1184
1185 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
1186 return -1;
1187 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
1188 return -1;
1189
1190 return 0;
1191 }
1192
1193 const unsigned char *
1194 bfd_sym_symbol_name (abfd, index)
1195 bfd *abfd;
1196 unsigned long index;
1197 {
1198 bfd_sym_data_struct *sdata = NULL;
1199
1200 BFD_ASSERT (bfd_sym_valid (abfd));
1201 sdata = abfd->tdata.sym_data;
1202
1203 if (index == 0)
1204 return "";
1205
1206 index *= 2;
1207 if ((index / sdata->header.dshb_page_size)
1208 > sdata->header.dshb_nte.dti_page_count)
1209 return "\009[INVALID]";
1210
1211 return (const unsigned char *) sdata->name_table + index;
1212 }
1213
1214 const unsigned char *
1215 bfd_sym_module_name (abfd, index)
1216 bfd *abfd;
1217 unsigned long index;
1218 {
1219 bfd_sym_modules_table_entry entry;
1220
1221 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
1222 return "\011[INVALID]";
1223
1224 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
1225 }
1226
1227 const char *
1228 bfd_sym_unparse_storage_kind (kind)
1229 enum bfd_sym_storage_kind kind;
1230 {
1231 switch (kind)
1232 {
1233 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
1234 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
1235 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
1236 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
1237 default: return "[UNKNOWN]";
1238 }
1239 }
1240
1241 const char *
1242 bfd_sym_unparse_storage_class (kind)
1243 enum bfd_sym_storage_class kind;
1244 {
1245 switch (kind)
1246 {
1247 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
1248 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
1249 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
1250 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
1251 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
1252 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
1253 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
1254 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
1255 default: return "[UNKNOWN]";
1256 }
1257 }
1258
1259 const char *
1260 bfd_sym_unparse_module_kind (kind)
1261 enum bfd_sym_module_kind kind;
1262 {
1263 switch (kind)
1264 {
1265 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
1266 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
1267 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
1268 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
1269 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
1270 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
1271 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
1272 default: return "[UNKNOWN]";
1273 }
1274 }
1275
1276 const char *
1277 bfd_sym_unparse_symbol_scope (scope)
1278 enum bfd_sym_symbol_scope scope;
1279 {
1280 switch (scope)
1281 {
1282 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
1283 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
1284 default:
1285 return "[UNKNOWN]";
1286 }
1287 }
1288
1289 void
1290 bfd_sym_print_file_reference (abfd, f, entry)
1291 bfd *abfd;
1292 FILE *f;
1293 bfd_sym_file_reference *entry;
1294 {
1295 bfd_sym_file_references_table_entry frtentry;
1296 int ret;
1297
1298 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
1299 entry->fref_frte_index);
1300 fprintf (f, "FILE ");
1301
1302 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
1303 fprintf (f, "[INVALID]");
1304 else
1305 fprintf (f, "\"%.*s\"",
1306 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
1307 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
1308
1309 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
1310 }
1311
1312 void
1313 bfd_sym_print_resources_table_entry (abfd, f, entry)
1314 bfd *abfd;
1315 FILE *f;
1316 bfd_sym_resources_table_entry *entry;
1317 {
1318 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
1319 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
1320 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
1321 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
1322 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
1323 }
1324
1325 void
1326 bfd_sym_print_modules_table_entry (abfd, f, entry)
1327 bfd *abfd;
1328 FILE *f;
1329 bfd_sym_modules_table_entry *entry;
1330 {
1331 fprintf (f, "\"%.*s\" (NTE %lu)",
1332 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
1333 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
1334 entry->mte_nte_index);
1335
1336 fprintf (f, "\n ");
1337
1338 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
1339 fprintf (f, " range %lu -- %lu",
1340 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
1341
1342 fprintf (f, "\n ");
1343
1344 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
1345 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
1346
1347 fprintf (f, ", RTE %lu, offset %lu, size %lu",
1348 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
1349
1350 fprintf (f, "\n ");
1351
1352 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
1353 entry->mte_cmte_index, entry->mte_cvte_index,
1354 entry->mte_clte_index, entry->mte_ctte_index,
1355 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
1356
1357 if (entry->mte_parent != 0)
1358 fprintf (f, ", parent %lu", entry->mte_parent);
1359 else
1360 fprintf (f, ", no parent");
1361
1362 if (entry->mte_cmte_index != 0)
1363 fprintf (f, ", child %lu", entry->mte_cmte_index);
1364 else
1365 fprintf (f, ", no child");
1366
1367 #if 0
1368 {
1369 MTE bfd_sym_modules_table_entry pentry;
1370
1371 ret = bfd_sym_fetch_modules_table_entry (abfd, &pentry, entry->mte_parent);
1372 if (ret < 0)
1373 fprintf (f, " parent MTE %lu [INVALID]\n", entry->mte_parent);
1374 else
1375 fprintf (f, " parent MTE %lu \"%.*s\"\n",
1376 entry->mte_parent,
1377 bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[0],
1378 &bfd_sym_symbol_name (abfd, pentry.mte_nte_index)[1]);
1379 }
1380 #endif
1381 }
1382
1383 void
1384 bfd_sym_print_file_references_table_entry (abfd, f, entry)
1385 bfd *abfd;
1386 FILE *f;
1387 bfd_sym_file_references_table_entry *entry;
1388 {
1389 switch (entry->generic.type)
1390 {
1391 case BFD_SYM_FILE_NAME_INDEX:
1392 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
1393 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
1394 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
1395 entry->filename.nte_index);
1396
1397 fprintf (f, "[UNIMPLEMENTED]");
1398 /* printModDate (entry->filename.mod_date); */
1399 fprintf (f, " (0x%lx)", entry->filename.mod_date);
1400 break;
1401
1402 case BFD_SYM_END_OF_LIST:
1403 fprintf (f, "END");
1404 break;
1405
1406 default:
1407 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
1408 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1409 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1410 entry->entry.mte_index,
1411 entry->entry.file_offset);
1412 break;
1413 }
1414 }
1415
1416 void
1417 bfd_sym_print_contained_modules_table_entry (abfd, f, entry)
1418 bfd *abfd;
1419 FILE *f;
1420 bfd_sym_contained_modules_table_entry *entry;
1421 {
1422 switch (entry->generic.type)
1423 {
1424 case BFD_SYM_END_OF_LIST:
1425 fprintf (f, "END");
1426 break;
1427
1428 default:
1429 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
1430 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1431 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1432 entry->entry.mte_index,
1433 entry->entry.nte_index);
1434 break;
1435 }
1436 }
1437
1438 void
1439 bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
1440 bfd *abfd;
1441 FILE *f;
1442 bfd_sym_contained_variables_table_entry *entry;
1443 {
1444 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1445 {
1446 fprintf (f, "END");
1447 return;
1448 }
1449
1450 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1451 {
1452 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1453 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1454 return;
1455 }
1456
1457 fprintf (f, "\"%.*s\" (NTE %lu)",
1458 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
1459 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
1460 entry->entry.nte_index);
1461
1462 fprintf (f, ", TTE %lu", entry->entry.tte_index);
1463 fprintf (f, ", offset %lu", entry->entry.file_delta);
1464 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
1465
1466 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
1467 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
1468 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
1469 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
1470 entry->entry.address.scstruct.sca_offset);
1471 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
1472 {
1473 unsigned long i;
1474
1475 fprintf (f, ", la [");
1476 for (i = 0; i < entry->entry.la_size; i++)
1477 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
1478 fprintf (f, "]");
1479 }
1480 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
1481 fprintf (f, ", bigla %lu, biglakind %u",
1482 entry->entry.address.biglastruct.big_la,
1483 entry->entry.address.biglastruct.big_la_kind);
1484
1485 else
1486 fprintf (f, ", la [INVALID]");
1487 }
1488
1489 void
1490 bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
1491 bfd *abfd;
1492 FILE *f;
1493 bfd_sym_contained_statements_table_entry *entry;
1494 {
1495 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1496 {
1497 fprintf (f, "END");
1498 return;
1499 }
1500
1501 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1502 {
1503 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1504 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1505 return;
1506 }
1507
1508 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
1509 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1510 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1511 entry->entry.mte_index,
1512 entry->entry.mte_offset,
1513 entry->entry.file_delta);
1514 }
1515
1516 void
1517 bfd_sym_print_contained_labels_table_entry (abfd, f, entry)
1518 bfd *abfd;
1519 FILE *f;
1520 bfd_sym_contained_labels_table_entry *entry;
1521 {
1522 if (entry->generic.type == BFD_SYM_END_OF_LIST)
1523 {
1524 fprintf (f, "END");
1525 return;
1526 }
1527
1528 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
1529 {
1530 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
1531 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
1532 return;
1533 }
1534
1535 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
1536 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
1537 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
1538 entry->entry.mte_index,
1539 entry->entry.mte_offset,
1540 entry->entry.file_delta,
1541 bfd_sym_unparse_symbol_scope (entry->entry.scope));
1542 }
1543
1544 void
1545 bfd_sym_print_contained_types_table_entry (abfd, f, entry)
1546 bfd *abfd ATTRIBUTE_UNUSED;
1547 FILE *f;
1548 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED;
1549 {
1550 fprintf (f, "[UNIMPLEMENTED]");
1551 }
1552
1553 const char *
1554 bfd_sym_type_operator_name (num)
1555 unsigned char num;
1556 {
1557 switch (num)
1558 {
1559 case 1: return "TTE";
1560 case 2: return "PointerTo";
1561 case 3: return "ScalarOf";
1562 case 4: return "ConstantOf";
1563 case 5: return "EnumerationOf";
1564 case 6: return "VectorOf";
1565 case 7: return "RecordOf";
1566 case 8: return "UnionOf";
1567 case 9: return "SubRangeOf";
1568 case 10: return "SetOf";
1569 case 11: return "NamedTypeOf";
1570 case 12: return "ProcOf";
1571 case 13: return "ValueOf";
1572 case 14: return "ArrayOf";
1573 default: return "[UNKNOWN OPERATOR]";
1574 }
1575 }
1576
1577 const char *
1578 bfd_sym_type_basic_name (num)
1579 unsigned char num;
1580 {
1581 switch (num)
1582 {
1583 case 0: return "void";
1584 case 1: return "pascal string";
1585 case 2: return "unsigned long";
1586 case 3: return "signed long";
1587 case 4: return "extended (10 bytes)";
1588 case 5: return "pascal boolean (1 byte)";
1589 case 6: return "unsigned byte";
1590 case 7: return "signed byte";
1591 case 8: return "character (1 byte)";
1592 case 9: return "wide character (2 bytes)";
1593 case 10: return "unsigned short";
1594 case 11: return "signed short";
1595 case 12: return "singled";
1596 case 13: return "double";
1597 case 14: return "extended (12 bytes)";
1598 case 15: return "computational (8 bytes)";
1599 case 16: return "c string";
1600 case 17: return "as-is string";
1601 default: return "[UNKNOWN BASIC TYPE]";
1602 }
1603 }
1604
1605 int
1606 bfd_sym_fetch_long (buf, len, offset, offsetptr, value)
1607 unsigned char *buf;
1608 unsigned long len;
1609 unsigned long offset;
1610 unsigned long *offsetptr;
1611 long *value;
1612 {
1613 int ret;
1614
1615 if (offset >= len)
1616 {
1617 *value = 0;
1618 offset += 0;
1619 ret = -1;
1620 }
1621 else if (! (buf[offset] & 0x80))
1622 {
1623 *value = buf[offset];
1624 offset += 1;
1625 ret = 0;
1626 }
1627 else if (buf[offset] == 0xc0)
1628 {
1629 if ((offset + 5) > len)
1630 {
1631 *value = 0;
1632 offset = len;
1633 ret = -1;
1634 }
1635 else
1636 {
1637 *value = bfd_getb32 (buf + offset + 1);
1638 offset += 5;
1639 ret = 0;
1640 }
1641 }
1642 else if ((buf[offset] & 0xc0) == 0xc0)
1643 {
1644 *value = -(buf[offset] & 0x3f);
1645 offset += 1;
1646 ret = 0;
1647 }
1648 else if ((buf[offset] & 0xc0) == 0x80)
1649 {
1650 if ((offset + 2) > len)
1651 {
1652 *value = 0;
1653 offset = len;
1654 ret = -1;
1655 }
1656 else
1657 {
1658 *value = bfd_getb16 (buf + offset) & 0x3fff;
1659 offset += 2;
1660 ret = 0;
1661 }
1662 }
1663 else
1664 abort ();
1665
1666 if (offsetptr != NULL)
1667 *offsetptr = offset;
1668
1669 return ret;
1670 }
1671
1672 void
1673 bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
1674 bfd *abfd;
1675 FILE *f;
1676 unsigned char *buf;
1677 unsigned long len;
1678 unsigned long offset;
1679 unsigned long *offsetptr;
1680 {
1681 unsigned int type;
1682
1683 if (offset >= len)
1684 {
1685 fprintf (f, "[NULL]");
1686
1687 if (offsetptr != NULL)
1688 *offsetptr = offset;
1689 return;
1690 }
1691
1692 type = buf[offset];
1693 offset++;
1694
1695 if (! (type & 0x80))
1696 {
1697 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
1698
1699 if (offsetptr != NULL)
1700 *offsetptr = offset;
1701 return;
1702 }
1703
1704 if (type & 0x40)
1705 fprintf (f, "[packed ");
1706 else
1707 fprintf (f, "[");
1708
1709 switch (type & 0x3f)
1710 {
1711 case 1:
1712 {
1713 long value;
1714 bfd_sym_type_information_table_entry tinfo;
1715
1716 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1717 if (value <= 0)
1718 fprintf (f, "[INVALID]");
1719 else
1720 {
1721 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
1722 fprintf (f, "[INVALID]");
1723 else
1724 fprintf (f, "\"%.*s\"",
1725 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
1726 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
1727 }
1728 fprintf (f, " (TTE %lu)", value);
1729 break;
1730 }
1731
1732 case 2:
1733 fprintf (f, "pointer (0x%x) to ", type);
1734 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1735 break;
1736
1737 case 3:
1738 {
1739 unsigned long value;
1740
1741 fprintf (f, "scalar (0x%x) of ", type);
1742 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1743 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1744 fprintf (f, " (%lu)", value);
1745 break;
1746 }
1747
1748 case 5:
1749 {
1750 unsigned long lower, upper, nelem;
1751 unsigned long i;
1752
1753 fprintf (f, "enumeration (0x%x) of ", type);
1754 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1755 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
1756 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
1757 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
1758 fprintf (f, " from %lu to %lu with %lu elements: ", lower, upper, nelem);
1759
1760 for (i = 0; i < nelem; i++)
1761 {
1762 fprintf (f, "\n ");
1763 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1764 }
1765 break;
1766 }
1767
1768 case 6:
1769 fprintf (f, "vector (0x%x)", type);
1770 fprintf (f, "\n index ");
1771 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1772 fprintf (f, "\n target ");
1773 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1774 break;
1775
1776 case 7:
1777 case 8:
1778 {
1779 long nrec, eloff, i;
1780
1781 if ((type & 0x3f) == 7)
1782 fprintf (f, "record (0x%x) of ", type);
1783 else
1784 fprintf (f, "union (0x%x) of ", type);
1785
1786 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
1787 fprintf (f, "%lu elements: ", nrec);
1788
1789 for (i = 0; i < nrec; i++)
1790 {
1791 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
1792 fprintf (f, "\n ");
1793 fprintf (f, "offset %lu: ", eloff);
1794 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1795 }
1796 break;
1797 }
1798
1799 case 9:
1800 fprintf (f, "subrange (0x%x) of ", type);
1801 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1802 fprintf (f, " lower ");
1803 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1804 fprintf (f, " upper ");
1805 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1806 break;
1807
1808 case 11:
1809 {
1810 long value;
1811
1812 fprintf (f, "named type (0x%x) ", type);
1813 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
1814 if (value <= 0)
1815 fprintf (f, "[INVALID]");
1816 else
1817 fprintf (f, "\"%.*s\"",
1818 bfd_sym_symbol_name (abfd, value)[0],
1819 &bfd_sym_symbol_name (abfd, value)[1]);
1820
1821 fprintf (f, " (NTE %lu) with type ", value);
1822 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
1823 break;
1824 }
1825
1826 default:
1827 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
1828 break;
1829 }
1830
1831 if (type == (0x40 | 0x6))
1832 {
1833 /* Vector. */
1834 long n, width, m;
1835 long l;
1836 long i;
1837
1838 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
1839 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
1840 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
1841 /* fprintf (f, "\n "); */
1842 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
1843 for (i = 0; i < m; i++)
1844 {
1845 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
1846 if (i != 0)
1847 fprintf (f, " ");
1848 fprintf (f, "%ld", l);
1849 }
1850 }
1851 else if (type & 0x40)
1852 {
1853 /* Other packed type. */
1854 long msb, lsb;
1855
1856 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
1857 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
1858 /* fprintf (f, "\n "); */
1859 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
1860 }
1861
1862 fprintf (f, "]");
1863
1864 if (offsetptr != NULL)
1865 *offsetptr = offset;
1866 }
1867
1868 void
1869 bfd_sym_print_type_information_table_entry (abfd, f, entry)
1870 bfd *abfd;
1871 FILE *f;
1872 bfd_sym_type_information_table_entry *entry;
1873 {
1874 unsigned char *buf;
1875 unsigned long offset;
1876 unsigned int i;
1877
1878 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
1879 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
1880 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
1881 entry->nte_index,
1882 entry->physical_size, entry->offset, entry->logical_size);
1883
1884 fprintf (f, "\n ");
1885
1886 buf = alloca (entry->physical_size);
1887 if (buf == NULL)
1888 {
1889 fprintf (f, "[ERROR]\n");
1890 return;
1891 }
1892 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
1893 {
1894 fprintf (f, "[ERROR]\n");
1895 return;
1896 }
1897 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
1898 {
1899 fprintf (f, "[ERROR]\n");
1900 return;
1901 }
1902
1903 fprintf (f, "[");
1904 for (i = 0; i < entry->physical_size; i++)
1905 {
1906 if (i == 0)
1907 fprintf (f, "0x%02x", buf[i]);
1908 else
1909 fprintf (f, " 0x%02x", buf[i]);
1910 }
1911
1912 fprintf (f, "]");
1913 fprintf (f, "\n ");
1914
1915 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
1916
1917 if (offset != entry->physical_size)
1918 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); }
1919
1920 void
1921 bfd_sym_print_file_references_index_table_entry (abfd, f, entry)
1922 bfd *abfd ATTRIBUTE_UNUSED;
1923 FILE *f;
1924 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED;
1925 {
1926 fprintf (f, "[UNIMPLEMENTED]");
1927 }
1928
1929 void
1930 bfd_sym_print_constant_pool_entry (abfd, f, entry)
1931 bfd *abfd ATTRIBUTE_UNUSED;
1932 FILE *f;
1933 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED;
1934 {
1935 fprintf (f, "[UNIMPLEMENTED]");
1936 }
1937
1938 unsigned char *
1939 bfd_sym_display_name_table_entry (abfd, f, entry)
1940 bfd *abfd;
1941 FILE *f;
1942 unsigned char *entry;
1943 {
1944 unsigned long index;
1945 unsigned long offset;
1946 bfd_sym_data_struct *sdata = NULL;
1947
1948 BFD_ASSERT (bfd_sym_valid (abfd));
1949 sdata = abfd->tdata.sym_data;
1950 index = (entry - sdata->name_table) / 2;
1951
1952 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
1953 {
1954 unsigned short length = bfd_getb16 (entry + 2);
1955 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
1956 offset = 2 + length + 1;
1957 }
1958 else
1959 {
1960 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
1961 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
1962
1963 if (sdata->version >= BFD_SYM_VERSION_3_4)
1964 offset = entry[0] + 2;
1965 else
1966 offset = entry[0] + 1;
1967 }
1968
1969 return (entry + offset + (offset % 2));
1970 }
1971
1972 void
1973 bfd_sym_display_name_table (abfd, f)
1974 bfd *abfd;
1975 FILE *f;
1976 {
1977 unsigned long name_table_len;
1978 unsigned char *name_table, *name_table_end, *cur;
1979 bfd_sym_data_struct *sdata = NULL;
1980
1981 BFD_ASSERT (bfd_sym_valid (abfd));
1982 sdata = abfd->tdata.sym_data;
1983
1984 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
1985 name_table = sdata->name_table;
1986 name_table_end = name_table + name_table_len;
1987
1988 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
1989
1990 cur = name_table;
1991 for (;;)
1992 {
1993 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
1994 if (cur >= name_table_end)
1995 break;
1996 }
1997 }
1998
1999 void
2000 bfd_sym_display_resources_table (abfd, f)
2001 bfd *abfd;
2002 FILE *f;
2003 {
2004 unsigned long i;
2005 bfd_sym_resources_table_entry entry;
2006 bfd_sym_data_struct *sdata = NULL;
2007
2008 BFD_ASSERT (bfd_sym_valid (abfd));
2009 sdata = abfd->tdata.sym_data;
2010
2011 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
2012 sdata->header.dshb_rte.dti_object_count);
2013
2014 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
2015 {
2016 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
2017 fprintf (f, " [%8lu] [INVALID]\n", i);
2018 else
2019 {
2020 fprintf (f, " [%8lu] ", i);
2021 bfd_sym_print_resources_table_entry (abfd, f, &entry);
2022 fprintf (f, "\n");
2023 }
2024 }
2025 }
2026
2027 void
2028 bfd_sym_display_modules_table (abfd, f)
2029 bfd *abfd;
2030 FILE *f;
2031 {
2032 unsigned long i;
2033 bfd_sym_modules_table_entry entry;
2034 bfd_sym_data_struct *sdata = NULL;
2035
2036 BFD_ASSERT (bfd_sym_valid (abfd));
2037 sdata = abfd->tdata.sym_data;
2038
2039 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
2040 sdata->header.dshb_mte.dti_object_count);
2041
2042 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
2043 {
2044 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
2045 fprintf (f, " [%8lu] [INVALID]\n", i);
2046 else
2047 {
2048 fprintf (f, " [%8lu] ", i);
2049 bfd_sym_print_modules_table_entry (abfd, f, &entry);
2050 fprintf (f, "\n");
2051 }
2052 }
2053 }
2054
2055 void
2056 bfd_sym_display_file_references_table (abfd, f)
2057 bfd *abfd;
2058 FILE *f;
2059 {
2060 unsigned long i;
2061 bfd_sym_file_references_table_entry entry;
2062 bfd_sym_data_struct *sdata = NULL;
2063
2064 BFD_ASSERT (bfd_sym_valid (abfd));
2065 sdata = abfd->tdata.sym_data;
2066
2067 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
2068 sdata->header.dshb_frte.dti_object_count);
2069
2070 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
2071 {
2072 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
2073 fprintf (f, " [%8lu] [INVALID]\n", i);
2074 else
2075 {
2076 fprintf (f, " [%8lu] ", i);
2077 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
2078 fprintf (f, "\n");
2079 }
2080 }
2081 }
2082
2083 void
2084 bfd_sym_display_contained_modules_table (abfd, f)
2085 bfd *abfd;
2086 FILE *f;
2087 {
2088 unsigned long i;
2089 bfd_sym_contained_modules_table_entry entry;
2090 bfd_sym_data_struct *sdata = NULL;
2091
2092 BFD_ASSERT (bfd_sym_valid (abfd));
2093 sdata = abfd->tdata.sym_data;
2094
2095 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
2096 sdata->header.dshb_cmte.dti_object_count);
2097
2098 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
2099 {
2100 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
2101 fprintf (f, " [%8lu] [INVALID]\n", i);
2102 else
2103 {
2104 fprintf (f, " [%8lu] ", i);
2105 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
2106 fprintf (f, "\n");
2107 }
2108 }
2109 }
2110
2111 void
2112 bfd_sym_display_contained_variables_table (abfd, f)
2113 bfd *abfd;
2114 FILE *f;
2115 {
2116 unsigned long i;
2117 bfd_sym_contained_variables_table_entry entry;
2118 bfd_sym_data_struct *sdata = NULL;
2119
2120 BFD_ASSERT (bfd_sym_valid (abfd));
2121 sdata = abfd->tdata.sym_data;
2122
2123 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
2124 sdata->header.dshb_cvte.dti_object_count);
2125
2126 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
2127 {
2128 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
2129 fprintf (f, " [%8lu] [INVALID]\n", i);
2130 else
2131 {
2132 fprintf (f, " [%8lu] ", i);
2133 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
2134 fprintf (f, "\n");
2135 }
2136 }
2137
2138 fprintf (f, "\n");
2139 }
2140
2141 void
2142 bfd_sym_display_contained_statements_table (abfd, f)
2143 bfd *abfd;
2144 FILE *f;
2145 {
2146 unsigned long i;
2147 bfd_sym_contained_statements_table_entry entry;
2148 bfd_sym_data_struct *sdata = NULL;
2149
2150 BFD_ASSERT (bfd_sym_valid (abfd));
2151 sdata = abfd->tdata.sym_data;
2152
2153 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
2154 sdata->header.dshb_csnte.dti_object_count);
2155
2156 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
2157 {
2158 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
2159 fprintf (f, " [%8lu] [INVALID]\n", i);
2160 else
2161 {
2162 fprintf (f, " [%8lu] ", i);
2163 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
2164 fprintf (f, "\n");
2165 }
2166 }
2167 }
2168
2169 void
2170 bfd_sym_display_contained_labels_table (abfd, f)
2171 bfd *abfd;
2172 FILE *f;
2173 {
2174 unsigned long i;
2175 bfd_sym_contained_labels_table_entry entry;
2176 bfd_sym_data_struct *sdata = NULL;
2177
2178 BFD_ASSERT (bfd_sym_valid (abfd));
2179 sdata = abfd->tdata.sym_data;
2180
2181 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
2182 sdata->header.dshb_clte.dti_object_count);
2183
2184 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
2185 {
2186 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
2187 fprintf (f, " [%8lu] [INVALID]\n", i);
2188 else
2189 {
2190 fprintf (f, " [%8lu] ", i);
2191 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
2192 fprintf (f, "\n");
2193 }
2194 }
2195 }
2196
2197 void
2198 bfd_sym_display_contained_types_table (abfd, f)
2199 bfd *abfd;
2200 FILE *f;
2201 {
2202 unsigned long i;
2203 bfd_sym_contained_types_table_entry entry;
2204 bfd_sym_data_struct *sdata = NULL;
2205
2206 BFD_ASSERT (bfd_sym_valid (abfd));
2207 sdata = abfd->tdata.sym_data;
2208
2209 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
2210 sdata->header.dshb_ctte.dti_object_count);
2211
2212 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
2213 {
2214 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
2215 fprintf (f, " [%8lu] [INVALID]\n", i);
2216 else
2217 {
2218 fprintf (f, " [%8lu] ", i);
2219 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
2220 fprintf (f, "\n");
2221 }
2222 }
2223 }
2224
2225 void
2226 bfd_sym_display_file_references_index_table (abfd, f)
2227 bfd *abfd;
2228 FILE *f;
2229 {
2230 unsigned long i;
2231 bfd_sym_file_references_index_table_entry entry;
2232 bfd_sym_data_struct *sdata = NULL;
2233
2234 BFD_ASSERT (bfd_sym_valid (abfd));
2235 sdata = abfd->tdata.sym_data;
2236
2237 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
2238 sdata->header.dshb_fite.dti_object_count);
2239
2240 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
2241 {
2242 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
2243 fprintf (f, " [%8lu] [INVALID]\n", i);
2244 else
2245 {
2246 fprintf (f, " [%8lu] ", i);
2247 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
2248 fprintf (f, "\n");
2249 }
2250 }
2251 }
2252
2253 void
2254 bfd_sym_display_constant_pool (abfd, f)
2255 bfd *abfd;
2256 FILE *f;
2257 {
2258 unsigned long i;
2259 bfd_sym_constant_pool_entry entry;
2260 bfd_sym_data_struct *sdata = NULL;
2261
2262 BFD_ASSERT (bfd_sym_valid (abfd));
2263 sdata = abfd->tdata.sym_data;
2264
2265 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
2266 sdata->header.dshb_const.dti_object_count);
2267
2268 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
2269 {
2270 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
2271 fprintf (f, " [%8lu] [INVALID]\n", i);
2272 else
2273 {
2274 fprintf (f, " [%8lu] ", i);
2275 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
2276 fprintf (f, "\n");
2277 }
2278 }
2279 }
2280
2281 void
2282 bfd_sym_display_type_information_table (abfd, f)
2283 bfd *abfd;
2284 FILE *f;
2285 {
2286 unsigned long i;
2287 bfd_sym_type_table_entry index;
2288 bfd_sym_type_information_table_entry entry;
2289 bfd_sym_data_struct *sdata = NULL;
2290
2291 BFD_ASSERT (bfd_sym_valid (abfd));
2292 sdata = abfd->tdata.sym_data;
2293
2294 if (sdata->header.dshb_tte.dti_object_count > 99)
2295 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
2296 sdata->header.dshb_tte.dti_object_count - 99);
2297 else
2298 {
2299 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
2300 return;
2301 }
2302
2303 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
2304 {
2305 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
2306 fprintf (f, " [%8lu] [INVALID]\n", i);
2307 else
2308 {
2309 fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
2310
2311 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
2312 fprintf (f, "[INVALID]");
2313 else
2314 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
2315
2316 fprintf (f, "\n");
2317 }
2318 }
2319 }
2320
2321 int
2322 bfd_sym_scan (abfd, version, mdata)
2323 bfd *abfd;
2324 bfd_sym_version version;
2325 bfd_sym_data_struct *mdata;
2326 {
2327 asection *bfdsec;
2328 const char *name = "symbols";
2329
2330 mdata->name_table = 0;
2331 mdata->sbfd = abfd;
2332 mdata->version = version;
2333
2334 bfd_seek (abfd, 0, SEEK_SET);
2335 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
2336 return -1;
2337
2338 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
2339 if (mdata->name_table == NULL)
2340 return -1;
2341
2342 bfdsec = bfd_make_section_anyway (abfd, name);
2343 if (bfdsec == NULL)
2344 return -1;
2345
2346 bfdsec->vma = 0;
2347 bfdsec->lma = 0;
2348 bfdsec->_raw_size = 0;
2349 bfdsec->filepos = 0;
2350 bfdsec->alignment_power = 0;
2351
2352 bfdsec->flags = SEC_HAS_CONTENTS;
2353
2354 abfd->tdata.sym_data = mdata;
2355
2356 return 0;
2357 }
2358
2359 const bfd_target *
2360 bfd_sym_object_p (abfd)
2361 bfd *abfd;
2362 {
2363 struct bfd_preserve preserve;
2364 bfd_sym_version version = -1;
2365
2366 preserve.marker = NULL;
2367 bfd_seek (abfd, 0, SEEK_SET);
2368 if (bfd_sym_read_version (abfd, &version) != 0)
2369 goto wrong;
2370
2371 preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
2372 if (preserve.marker == NULL
2373 || ! bfd_preserve_save (abfd, &preserve))
2374 goto fail;
2375
2376 if (bfd_sym_scan (abfd, version,
2377 (bfd_sym_data_struct *) preserve.marker) != 0)
2378 goto wrong;
2379
2380 bfd_preserve_finish (abfd, &preserve);
2381 return abfd->xvec;
2382
2383 wrong:
2384 bfd_set_error (bfd_error_wrong_format);
2385
2386 fail:
2387 if (preserve.marker != NULL)
2388 bfd_preserve_restore (abfd, &preserve);
2389 return NULL;
2390 }
2391
2392 asymbol *
2393 bfd_sym_make_empty_symbol (abfd)
2394 bfd *abfd;
2395 {
2396 return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
2397 }
2398
2399 void
2400 bfd_sym_get_symbol_info (abfd, symbol, ret)
2401 bfd *abfd ATTRIBUTE_UNUSED;
2402 asymbol *symbol;
2403 symbol_info *ret;
2404 {
2405 bfd_symbol_info (symbol, ret);
2406 }
2407
2408 long
2409 bfd_sym_get_symtab_upper_bound (abfd)
2410 bfd *abfd ATTRIBUTE_UNUSED;
2411 {
2412 return 0;
2413 }
2414
2415 long
2416 bfd_sym_canonicalize_symtab (abfd, sym)
2417 bfd *abfd ATTRIBUTE_UNUSED;
2418 asymbol **sym ATTRIBUTE_UNUSED;
2419 {
2420 return 0;
2421 }
2422
2423 int
2424 bfd_sym_sizeof_headers (abfd, exec)
2425 bfd *abfd ATTRIBUTE_UNUSED;
2426 bfd_boolean exec ATTRIBUTE_UNUSED;
2427 {
2428 return 0;
2429 }
2430
2431 const bfd_target sym_vec =
2432 {
2433 "sym", /* name */
2434 bfd_target_sym_flavour, /* flavour */
2435 BFD_ENDIAN_BIG, /* byteorder */
2436 BFD_ENDIAN_BIG, /* header_byteorder */
2437 (HAS_RELOC | EXEC_P | /* object flags */
2438 HAS_LINENO | HAS_DEBUG |
2439 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
2440 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
2441 | SEC_ROM | SEC_HAS_CONTENTS), /* section_flags */
2442 0, /* symbol_leading_char */
2443 ' ', /* ar_pad_char */
2444 16, /* ar_max_namelen */
2445 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2446 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2447 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* data */
2448 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
2449 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
2450 bfd_getb16, bfd_getb_signed_16, bfd_putb16, /* hdrs */
2451 { /* bfd_check_format */
2452 _bfd_dummy_target,
2453 bfd_sym_object_p, /* bfd_check_format */
2454 _bfd_dummy_target,
2455 _bfd_dummy_target,
2456 },
2457 { /* bfd_set_format */
2458 bfd_false,
2459 bfd_sym_mkobject,
2460 bfd_false,
2461 bfd_false,
2462 },
2463 { /* bfd_write_contents */
2464 bfd_false,
2465 bfd_true,
2466 bfd_false,
2467 bfd_false,
2468 },
2469
2470 BFD_JUMP_TABLE_GENERIC (bfd_sym),
2471 BFD_JUMP_TABLE_COPY (_bfd_generic),
2472 BFD_JUMP_TABLE_CORE (_bfd_nocore),
2473 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
2474 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
2475 BFD_JUMP_TABLE_RELOCS (bfd_sym),
2476 BFD_JUMP_TABLE_WRITE (bfd_sym),
2477 BFD_JUMP_TABLE_LINK (bfd_sym),
2478 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
2479
2480 NULL,
2481
2482 NULL
2483 };
2484
This page took 0.082895 seconds and 4 git commands to generate.