00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "xsym.h"
00026 #include "bfd.h"
00027 #include "sysdep.h"
00028 #include "libbfd.h"
00029
00030 #define bfd_sym_close_and_cleanup _bfd_generic_close_and_cleanup
00031 #define bfd_sym_bfd_free_cached_info _bfd_generic_bfd_free_cached_info
00032 #define bfd_sym_new_section_hook _bfd_generic_new_section_hook
00033 #define bfd_sym_bfd_is_local_label_name bfd_generic_is_local_label_name
00034 #define bfd_sym_bfd_is_target_special_symbol ((bfd_boolean (*) (bfd *, asymbol *)) bfd_false)
00035 #define bfd_sym_get_lineno _bfd_nosymbols_get_lineno
00036 #define bfd_sym_find_nearest_line _bfd_nosymbols_find_nearest_line
00037 #define bfd_sym_bfd_make_debug_symbol _bfd_nosymbols_bfd_make_debug_symbol
00038 #define bfd_sym_read_minisymbols _bfd_generic_read_minisymbols
00039 #define bfd_sym_minisymbol_to_symbol _bfd_generic_minisymbol_to_symbol
00040 #define bfd_sym_get_reloc_upper_bound _bfd_norelocs_get_reloc_upper_bound
00041 #define bfd_sym_canonicalize_reloc _bfd_norelocs_canonicalize_reloc
00042 #define bfd_sym_bfd_reloc_type_lookup _bfd_norelocs_bfd_reloc_type_lookup
00043 #define bfd_sym_set_arch_mach _bfd_generic_set_arch_mach
00044 #define bfd_sym_get_section_contents _bfd_generic_get_section_contents
00045 #define bfd_sym_set_section_contents _bfd_generic_set_section_contents
00046 #define bfd_sym_bfd_get_relocated_section_contents bfd_generic_get_relocated_section_contents
00047 #define bfd_sym_bfd_relax_section bfd_generic_relax_section
00048 #define bfd_sym_bfd_gc_sections bfd_generic_gc_sections
00049 #define bfd_sym_bfd_merge_sections bfd_generic_merge_sections
00050 #define bfd_sym_bfd_is_group_section bfd_generic_is_group_section
00051 #define bfd_sym_bfd_discard_group bfd_generic_discard_group
00052 #define bfd_sym_section_already_linked \
00053 _bfd_generic_section_already_linked
00054 #define bfd_sym_bfd_link_hash_table_create _bfd_generic_link_hash_table_create
00055 #define bfd_sym_bfd_link_hash_table_free _bfd_generic_link_hash_table_free
00056 #define bfd_sym_bfd_link_add_symbols _bfd_generic_link_add_symbols
00057 #define bfd_sym_bfd_link_just_syms _bfd_generic_link_just_syms
00058 #define bfd_sym_bfd_final_link _bfd_generic_final_link
00059 #define bfd_sym_bfd_link_split_section _bfd_generic_link_split_section
00060 #define bfd_sym_get_section_contents_in_window _bfd_generic_get_section_contents_in_window
00061
00062 static unsigned long compute_offset
00063 PARAMS ((unsigned long, unsigned long, unsigned long, unsigned long));
00064
00065 extern const bfd_target sym_vec;
00066
00067 static int
00068 pstrcmp (const char *as, const char *bs)
00069 {
00070 const unsigned char *a = (const unsigned char *) as;
00071 const unsigned char *b = (const unsigned char *) bs;
00072 unsigned char clen;
00073 int ret;
00074
00075 clen = (a[0] > b[0]) ? b[0] : a[0];
00076 ret = memcmp (a + 1, b + 1, clen);
00077 if (ret != 0)
00078 return ret;
00079
00080 if (a[0] == b[0])
00081 return 0;
00082 else if (a[0] < b[0])
00083 return -1;
00084 else
00085 return 1;
00086 }
00087
00088 static unsigned long
00089 compute_offset (first_page, page_size, entry_size, index)
00090 unsigned long first_page;
00091 unsigned long page_size;
00092 unsigned long entry_size;
00093 unsigned long index;
00094 {
00095 unsigned long entries_per_page = page_size / entry_size;
00096 unsigned long page_number = first_page + (index / entries_per_page);
00097 unsigned long page_offset = (index % entries_per_page) * entry_size;
00098
00099 return (page_number * page_size) + page_offset;
00100 }
00101
00102 bfd_boolean
00103 bfd_sym_mkobject (abfd)
00104 bfd *abfd ATTRIBUTE_UNUSED;
00105 {
00106 return 1;
00107 }
00108
00109 void
00110 bfd_sym_print_symbol (abfd, afile, symbol, how)
00111 bfd *abfd ATTRIBUTE_UNUSED;
00112 PTR afile ATTRIBUTE_UNUSED;
00113 asymbol *symbol ATTRIBUTE_UNUSED;
00114 bfd_print_symbol_type how ATTRIBUTE_UNUSED;
00115 {
00116 return;
00117 }
00118
00119 bfd_boolean
00120 bfd_sym_valid (abfd)
00121 bfd *abfd;
00122 {
00123 if (abfd == NULL || abfd->xvec == NULL)
00124 return 0;
00125
00126 return abfd->xvec == &sym_vec;
00127 }
00128
00129 unsigned char *
00130 bfd_sym_read_name_table (abfd, dshb)
00131 bfd *abfd;
00132 bfd_sym_header_block *dshb;
00133 {
00134 unsigned char *rstr;
00135 long ret;
00136 size_t table_size = dshb->dshb_nte.dti_page_count * dshb->dshb_page_size;
00137 size_t table_offset = dshb->dshb_nte.dti_first_page * dshb->dshb_page_size;
00138
00139 rstr = (unsigned char *) bfd_alloc (abfd, table_size);
00140 if (rstr == NULL)
00141 return rstr;
00142
00143 bfd_seek (abfd, table_offset, SEEK_SET);
00144 ret = bfd_bread (rstr, table_size, abfd);
00145 if (ret < 0 || (unsigned long) ret != table_size)
00146 {
00147 bfd_release (abfd, rstr);
00148 return NULL;
00149 }
00150
00151 return rstr;
00152 }
00153
00154 void
00155 bfd_sym_parse_file_reference_v32 (buf, len, entry)
00156 unsigned char *buf;
00157 size_t len;
00158 bfd_sym_file_reference *entry;
00159 {
00160 BFD_ASSERT (len == 6);
00161
00162 entry->fref_frte_index = bfd_getb16 (buf);
00163 entry->fref_offset = bfd_getb32 (buf + 2);
00164 }
00165
00166 void
00167 bfd_sym_parse_disk_table_v32 (buf, len, table)
00168 unsigned char *buf;
00169 size_t len;
00170 bfd_sym_table_info *table;
00171 {
00172 BFD_ASSERT (len == 8);
00173
00174 table->dti_first_page = bfd_getb16 (buf);
00175 table->dti_page_count = bfd_getb16 (buf + 2);
00176 table->dti_object_count = bfd_getb32 (buf + 4);
00177 }
00178
00179 void
00180 bfd_sym_parse_header_v32 (buf, len, header)
00181 unsigned char *buf;
00182 size_t len;
00183 bfd_sym_header_block *header;
00184 {
00185 BFD_ASSERT (len == 154);
00186
00187 memcpy (header->dshb_id, buf, 32);
00188 header->dshb_page_size = bfd_getb16 (buf + 32);
00189 header->dshb_hash_page = bfd_getb16 (buf + 34);
00190 header->dshb_root_mte = bfd_getb16 (buf + 36);
00191 header->dshb_mod_date = bfd_getb32 (buf + 38);
00192
00193 bfd_sym_parse_disk_table_v32 (buf + 42, 8, &header->dshb_frte);
00194 bfd_sym_parse_disk_table_v32 (buf + 50, 8, &header->dshb_rte);
00195 bfd_sym_parse_disk_table_v32 (buf + 58, 8, &header->dshb_mte);
00196 bfd_sym_parse_disk_table_v32 (buf + 66, 8, &header->dshb_cmte);
00197 bfd_sym_parse_disk_table_v32 (buf + 74, 8, &header->dshb_cvte);
00198 bfd_sym_parse_disk_table_v32 (buf + 82, 8, &header->dshb_csnte);
00199 bfd_sym_parse_disk_table_v32 (buf + 90, 8, &header->dshb_clte);
00200 bfd_sym_parse_disk_table_v32 (buf + 98, 8, &header->dshb_ctte);
00201 bfd_sym_parse_disk_table_v32 (buf + 106, 8, &header->dshb_tte);
00202 bfd_sym_parse_disk_table_v32 (buf + 114, 8, &header->dshb_nte);
00203 bfd_sym_parse_disk_table_v32 (buf + 122, 8, &header->dshb_tinfo);
00204 bfd_sym_parse_disk_table_v32 (buf + 130, 8, &header->dshb_fite);
00205 bfd_sym_parse_disk_table_v32 (buf + 138, 8, &header->dshb_const);
00206
00207 memcpy (&header->dshb_file_creator, buf + 146, 4);
00208 memcpy (&header->dshb_file_type, buf + 150, 4);
00209 }
00210
00211 int
00212 bfd_sym_read_header_v32 (abfd, header)
00213 bfd *abfd;
00214 bfd_sym_header_block *header;
00215 {
00216 unsigned char buf[154];
00217 long ret;
00218
00219 ret = bfd_bread (buf, 154, abfd);
00220 if (ret != 154)
00221 return -1;
00222
00223 bfd_sym_parse_header_v32 (buf, 154, header);
00224
00225 return 0;
00226 }
00227
00228 int
00229 bfd_sym_read_header_v34 (abfd, header)
00230 bfd *abfd ATTRIBUTE_UNUSED;
00231 bfd_sym_header_block *header ATTRIBUTE_UNUSED;
00232 {
00233 abort ();
00234 }
00235
00236 int
00237 bfd_sym_read_header (abfd, header, version)
00238 bfd *abfd;
00239 bfd_sym_header_block *header;
00240 bfd_sym_version version;
00241 {
00242 switch (version)
00243 {
00244 case BFD_SYM_VERSION_3_5:
00245 case BFD_SYM_VERSION_3_4:
00246 return bfd_sym_read_header_v34 (abfd, header);
00247 case BFD_SYM_VERSION_3_3:
00248 case BFD_SYM_VERSION_3_2:
00249 return bfd_sym_read_header_v32 (abfd, header);
00250 case BFD_SYM_VERSION_3_1:
00251 default:
00252 return FALSE;
00253 }
00254 }
00255
00256 int
00257 bfd_sym_read_version (abfd, version)
00258 bfd *abfd;
00259 bfd_sym_version *version;
00260 {
00261 char version_string[32];
00262 long ret;
00263
00264 ret = bfd_bread (version_string, sizeof (version_string), abfd);
00265 if (ret != sizeof (version_string))
00266 return -1;
00267
00268 if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_1) == 0)
00269 *version = BFD_SYM_VERSION_3_1;
00270 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_2) == 0)
00271 *version = BFD_SYM_VERSION_3_2;
00272 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_3) == 0)
00273 *version = BFD_SYM_VERSION_3_3;
00274 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_4) == 0)
00275 *version = BFD_SYM_VERSION_3_4;
00276 else if (pstrcmp (version_string, BFD_SYM_VERSION_STR_3_5) == 0)
00277 *version = BFD_SYM_VERSION_3_5;
00278 else
00279 return -1;
00280
00281 return 0;
00282 }
00283
00284 void
00285 bfd_sym_display_table_summary (f, dti, name)
00286 FILE *f;
00287 bfd_sym_table_info *dti;
00288 const char *name;
00289 {
00290 fprintf (f, "%-6s %13ld %13ld %13ld\n",
00291 name,
00292 dti->dti_first_page,
00293 dti->dti_page_count,
00294 dti->dti_object_count);
00295 }
00296
00297 void
00298 bfd_sym_display_header (f, dshb)
00299 FILE *f;
00300 bfd_sym_header_block *dshb;
00301 {
00302 fprintf (f, " Version: %.*s\n", dshb->dshb_id[0], dshb->dshb_id + 1);
00303 fprintf (f, " Page Size: 0x%x\n", dshb->dshb_page_size);
00304 fprintf (f, " Hash Page: %lu\n", dshb->dshb_hash_page);
00305 fprintf (f, " Root MTE: %lu\n", dshb->dshb_root_mte);
00306 fprintf (f, " Modification Date: ");
00307 fprintf (f, "[unimplemented]");
00308 fprintf (f, " (0x%lx)\n", dshb->dshb_mod_date);
00309
00310 fprintf (f, " File Creator: %.4s Type: %.4s\n\n",
00311 dshb->dshb_file_creator, dshb->dshb_file_type);
00312
00313 fprintf (f, "Table Name First Page Page Count Object Count\n");
00314 fprintf (f, "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n");
00315
00316 bfd_sym_display_table_summary (f, &dshb->dshb_nte, "NTE");
00317 bfd_sym_display_table_summary (f, &dshb->dshb_rte, "RTE");
00318 bfd_sym_display_table_summary (f, &dshb->dshb_mte, "MTE");
00319 bfd_sym_display_table_summary (f, &dshb->dshb_frte, "FRTE");
00320 bfd_sym_display_table_summary (f, &dshb->dshb_cmte, "CMTE");
00321 bfd_sym_display_table_summary (f, &dshb->dshb_cvte, "CVTE");
00322 bfd_sym_display_table_summary (f, &dshb->dshb_csnte, "CSNTE");
00323 bfd_sym_display_table_summary (f, &dshb->dshb_clte, "CLTE");
00324 bfd_sym_display_table_summary (f, &dshb->dshb_ctte, "CTTE");
00325 bfd_sym_display_table_summary (f, &dshb->dshb_tte, "TTE");
00326 bfd_sym_display_table_summary (f, &dshb->dshb_tinfo, "TINFO");
00327 bfd_sym_display_table_summary (f, &dshb->dshb_fite, "FITE");
00328 bfd_sym_display_table_summary (f, &dshb->dshb_const, "CONST");
00329
00330 fprintf (f, "\n");
00331 }
00332
00333 void
00334 bfd_sym_parse_resources_table_entry_v32 (buf, len, entry)
00335 unsigned char *buf;
00336 size_t len;
00337 bfd_sym_resources_table_entry *entry;
00338 {
00339 BFD_ASSERT (len == 18);
00340
00341 memcpy (&entry->rte_res_type, buf, 4);
00342 entry->rte_res_number = bfd_getb16 (buf + 4);
00343 entry->rte_nte_index = bfd_getb32 (buf + 6);
00344 entry->rte_mte_first = bfd_getb16 (buf + 10);
00345 entry->rte_mte_last = bfd_getb16 (buf + 12);
00346 entry->rte_res_size = bfd_getb32 (buf + 14);
00347 }
00348
00349 void
00350 bfd_sym_parse_modules_table_entry_v33 (buf, len, entry)
00351 unsigned char *buf;
00352 size_t len;
00353 bfd_sym_modules_table_entry *entry;
00354 {
00355 BFD_ASSERT (len == 46);
00356
00357 entry->mte_rte_index = bfd_getb16 (buf);
00358 entry->mte_res_offset = bfd_getb32 (buf + 2);
00359 entry->mte_size = bfd_getb32 (buf + 6);
00360 entry->mte_kind = buf[10];
00361 entry->mte_scope = buf[11];
00362 entry->mte_parent = bfd_getb16 (buf + 12);
00363 bfd_sym_parse_file_reference_v32 (buf + 14, 6, &entry->mte_imp_fref);
00364 entry->mte_imp_end = bfd_getb32 (buf + 20);
00365 entry->mte_nte_index = bfd_getb32 (buf + 24);
00366 entry->mte_cmte_index = bfd_getb16 (buf + 28);
00367 entry->mte_cvte_index = bfd_getb32 (buf + 30);
00368 entry->mte_clte_index = bfd_getb16 (buf + 34);
00369 entry->mte_ctte_index = bfd_getb16 (buf + 36);
00370 entry->mte_csnte_idx_1 = bfd_getb32 (buf + 38);
00371 entry->mte_csnte_idx_2 = bfd_getb32 (buf + 42);
00372 }
00373
00374 void
00375 bfd_sym_parse_file_references_table_entry_v32 (buf, len, entry)
00376 unsigned char *buf;
00377 size_t len;
00378 bfd_sym_file_references_table_entry *entry;
00379 {
00380 unsigned int type;
00381
00382 BFD_ASSERT (len == 10);
00383
00384 memset (entry, 0, sizeof (bfd_sym_file_references_table_entry));
00385 type = bfd_getb16 (buf);
00386
00387 switch (type)
00388 {
00389 case BFD_SYM_END_OF_LIST_3_2:
00390 entry->generic.type = BFD_SYM_END_OF_LIST;
00391 break;
00392
00393 case BFD_SYM_FILE_NAME_INDEX_3_2:
00394 entry->filename.type = BFD_SYM_FILE_NAME_INDEX;
00395 entry->filename.nte_index = bfd_getb32 (buf + 2);
00396 entry->filename.mod_date = bfd_getb32 (buf + 6);
00397 break;
00398
00399 default:
00400 entry->entry.mte_index = type;
00401 entry->entry.file_offset = bfd_getb32 (buf + 2);
00402 }
00403 }
00404
00405 void
00406 bfd_sym_parse_contained_modules_table_entry_v32 (buf, len, entry)
00407 unsigned char *buf;
00408 size_t len;
00409 bfd_sym_contained_modules_table_entry *entry;
00410 {
00411 unsigned int type;
00412
00413 BFD_ASSERT (len == 6);
00414
00415 memset (entry, 0, sizeof (bfd_sym_contained_modules_table_entry));
00416 type = bfd_getb16 (buf);
00417
00418 switch (type)
00419 {
00420 case BFD_SYM_END_OF_LIST_3_2:
00421 entry->generic.type = BFD_SYM_END_OF_LIST;
00422 break;
00423
00424 default:
00425 entry->entry.mte_index = type;
00426 entry->entry.nte_index = bfd_getb32 (buf + 2);
00427 break;
00428 }
00429 }
00430
00431 void
00432 bfd_sym_parse_contained_variables_table_entry_v32 (buf, len, entry)
00433 unsigned char *buf;
00434 size_t len;
00435 bfd_sym_contained_variables_table_entry *entry;
00436 {
00437 unsigned int type;
00438
00439 BFD_ASSERT (len == 26);
00440
00441 memset (entry, 0, sizeof (bfd_sym_contained_variables_table_entry));
00442 type = bfd_getb16 (buf);
00443
00444 switch (type)
00445 {
00446 case BFD_SYM_END_OF_LIST_3_2:
00447 entry->generic.type = BFD_SYM_END_OF_LIST;
00448 break;
00449
00450 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
00451 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
00452 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
00453 break;
00454
00455 default:
00456 entry->entry.tte_index = type;
00457 entry->entry.nte_index = bfd_getb32 (buf + 2);
00458 entry->entry.file_delta = bfd_getb16 (buf + 6);
00459 entry->entry.scope = buf[8];
00460 entry->entry.la_size = buf[9];
00461
00462 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
00463 {
00464 entry->entry.address.scstruct.sca_kind = buf[10];
00465 entry->entry.address.scstruct.sca_class = buf[11];
00466 entry->entry.address.scstruct.sca_offset = bfd_getb32 (buf + 12);
00467 }
00468 else if (entry->entry.la_size <= BFD_SYM_CVTE_SCA)
00469 {
00470 #if BFD_SYM_CVTE_SCA > 0
00471 memcpy (&entry->entry.address.lastruct.la, buf + 10, BFD_SYM_CVTE_SCA);
00472 #endif
00473 entry->entry.address.lastruct.la_kind = buf[23];
00474 }
00475 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
00476 {
00477 entry->entry.address.biglastruct.big_la = bfd_getb32 (buf + 10);
00478 entry->entry.address.biglastruct.big_la_kind = buf[12];
00479 }
00480 }
00481 }
00482
00483 void
00484 bfd_sym_parse_contained_statements_table_entry_v32 (buf, len, entry)
00485 unsigned char *buf;
00486 size_t len;
00487 bfd_sym_contained_statements_table_entry *entry;
00488 {
00489 unsigned int type;
00490
00491 BFD_ASSERT (len == 8);
00492
00493 memset (entry, 0, sizeof (bfd_sym_contained_statements_table_entry));
00494 type = bfd_getb16 (buf);
00495
00496 switch (type)
00497 {
00498 case BFD_SYM_END_OF_LIST_3_2:
00499 entry->generic.type = BFD_SYM_END_OF_LIST;
00500 break;
00501
00502 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
00503 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
00504 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
00505 break;
00506
00507 default:
00508 entry->entry.mte_index = type;
00509 entry->entry.mte_offset = bfd_getb16 (buf + 2);
00510 entry->entry.file_delta = bfd_getb32 (buf + 4);
00511 break;
00512 }
00513 }
00514
00515 void
00516 bfd_sym_parse_contained_labels_table_entry_v32 (buf, len, entry)
00517 unsigned char *buf;
00518 size_t len;
00519 bfd_sym_contained_labels_table_entry *entry;
00520 {
00521 unsigned int type;
00522
00523 BFD_ASSERT (len == 12);
00524
00525 memset (entry, 0, sizeof (bfd_sym_contained_labels_table_entry));
00526 type = bfd_getb16 (buf);
00527
00528 switch (type)
00529 {
00530 case BFD_SYM_END_OF_LIST_3_2:
00531 entry->generic.type = BFD_SYM_END_OF_LIST;
00532 break;
00533
00534 case BFD_SYM_SOURCE_FILE_CHANGE_3_2:
00535 entry->file.type = BFD_SYM_SOURCE_FILE_CHANGE;
00536 bfd_sym_parse_file_reference_v32 (buf + 2, 6, &entry->file.fref);
00537 break;
00538
00539 default:
00540 entry->entry.mte_index = type;
00541 entry->entry.mte_offset = bfd_getb16 (buf + 2);
00542 entry->entry.nte_index = bfd_getb32 (buf + 4);
00543 entry->entry.file_delta = bfd_getb16 (buf + 8);
00544 entry->entry.scope = bfd_getb16 (buf + 10);
00545 break;
00546 }
00547 }
00548
00549 void
00550 bfd_sym_parse_type_table_entry_v32 (buf, len, entry)
00551 unsigned char *buf;
00552 size_t len;
00553 bfd_sym_type_table_entry *entry;
00554 {
00555 BFD_ASSERT (len == 4);
00556
00557 *entry = bfd_getb32 (buf);
00558 }
00559
00560 int
00561 bfd_sym_fetch_resources_table_entry (abfd, entry, index)
00562 bfd *abfd;
00563 bfd_sym_resources_table_entry *entry;
00564 unsigned long index;
00565 {
00566 void (*parser) PARAMS ((unsigned char *, size_t,
00567 bfd_sym_resources_table_entry *));
00568 unsigned long offset;
00569 unsigned long entry_size;
00570 unsigned char buf[18];
00571 bfd_sym_data_struct *sdata = NULL;
00572
00573 parser = NULL;
00574 BFD_ASSERT (bfd_sym_valid (abfd));
00575 sdata = abfd->tdata.sym_data;
00576
00577 if (index == 0)
00578 return -1;
00579
00580 switch (sdata->version)
00581 {
00582 case BFD_SYM_VERSION_3_5:
00583 case BFD_SYM_VERSION_3_4:
00584 return -1;
00585
00586 case BFD_SYM_VERSION_3_3:
00587 case BFD_SYM_VERSION_3_2:
00588 entry_size = 18;
00589 parser = bfd_sym_parse_resources_table_entry_v32;
00590 break;
00591
00592 case BFD_SYM_VERSION_3_1:
00593 default:
00594 return -1;
00595 }
00596 if (parser == NULL)
00597 return -1;
00598
00599 offset = compute_offset (sdata->header.dshb_rte.dti_first_page,
00600 sdata->header.dshb_page_size,
00601 entry_size, index);
00602
00603 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
00604 return -1;
00605 if (bfd_bread (buf, entry_size, abfd) != entry_size)
00606 return -1;
00607
00608 (*parser) (buf, entry_size, entry);
00609
00610 return 0;
00611 }
00612
00613 int
00614 bfd_sym_fetch_modules_table_entry (abfd, entry, index)
00615 bfd *abfd;
00616 bfd_sym_modules_table_entry *entry;
00617 unsigned long index;
00618 {
00619 void (*parser) PARAMS ((unsigned char *, size_t,
00620 bfd_sym_modules_table_entry *));
00621 unsigned long offset;
00622 unsigned long entry_size;
00623 unsigned char buf[46];
00624 bfd_sym_data_struct *sdata = NULL;
00625
00626 parser = NULL;
00627 BFD_ASSERT (bfd_sym_valid (abfd));
00628 sdata = abfd->tdata.sym_data;
00629
00630 if (index == 0)
00631 return -1;
00632
00633 switch (sdata->version)
00634 {
00635 case BFD_SYM_VERSION_3_5:
00636 case BFD_SYM_VERSION_3_4:
00637 return -1;
00638
00639 case BFD_SYM_VERSION_3_3:
00640 entry_size = 46;
00641 parser = bfd_sym_parse_modules_table_entry_v33;
00642 break;
00643
00644 case BFD_SYM_VERSION_3_2:
00645 case BFD_SYM_VERSION_3_1:
00646 default:
00647 return -1;
00648 }
00649 if (parser == NULL)
00650 return -1;
00651
00652 offset = compute_offset (sdata->header.dshb_mte.dti_first_page,
00653 sdata->header.dshb_page_size,
00654 entry_size, index);
00655
00656 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
00657 return -1;
00658 if (bfd_bread (buf, entry_size, abfd) != entry_size)
00659 return -1;
00660
00661 (*parser) (buf, entry_size, entry);
00662
00663 return 0;
00664 }
00665
00666 int
00667 bfd_sym_fetch_file_references_table_entry (abfd, entry, index)
00668 bfd *abfd;
00669 bfd_sym_file_references_table_entry *entry;
00670 unsigned long index;
00671 {
00672 void (*parser) PARAMS ((unsigned char *, size_t,
00673 bfd_sym_file_references_table_entry *));
00674 unsigned long offset;
00675 unsigned long entry_size = 0;
00676 unsigned char buf[8];
00677 bfd_sym_data_struct *sdata = NULL;
00678
00679 parser = NULL;
00680 BFD_ASSERT (bfd_sym_valid (abfd));
00681 sdata = abfd->tdata.sym_data;
00682
00683 if (index == 0)
00684 return -1;
00685
00686 switch (sdata->version)
00687 {
00688 case BFD_SYM_VERSION_3_3:
00689 case BFD_SYM_VERSION_3_2:
00690 entry_size = 10;
00691 parser = bfd_sym_parse_file_references_table_entry_v32;
00692 break;
00693
00694 case BFD_SYM_VERSION_3_5:
00695 case BFD_SYM_VERSION_3_4:
00696 case BFD_SYM_VERSION_3_1:
00697 default:
00698 break;
00699 }
00700
00701 if (parser == NULL)
00702 return -1;
00703
00704 offset = compute_offset (sdata->header.dshb_frte.dti_first_page,
00705 sdata->header.dshb_page_size,
00706 entry_size, index);
00707
00708 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
00709 return -1;
00710 if (bfd_bread (buf, entry_size, abfd) != entry_size)
00711 return -1;
00712
00713 (*parser) (buf, entry_size, entry);
00714
00715 return 0;
00716 }
00717
00718 int
00719 bfd_sym_fetch_contained_modules_table_entry (abfd, entry, index)
00720 bfd *abfd;
00721 bfd_sym_contained_modules_table_entry *entry;
00722 unsigned long index;
00723 {
00724 void (*parser) PARAMS ((unsigned char *, size_t,
00725 bfd_sym_contained_modules_table_entry *));
00726 unsigned long offset;
00727 unsigned long entry_size = 0;
00728 unsigned char buf[6];
00729 bfd_sym_data_struct *sdata = NULL;
00730
00731 parser = NULL;
00732 BFD_ASSERT (bfd_sym_valid (abfd));
00733 sdata = abfd->tdata.sym_data;
00734
00735 if (index == 0)
00736 return -1;
00737
00738 switch (sdata->version)
00739 {
00740 case BFD_SYM_VERSION_3_3:
00741 case BFD_SYM_VERSION_3_2:
00742 entry_size = 6;
00743 parser = bfd_sym_parse_contained_modules_table_entry_v32;
00744 break;
00745
00746 case BFD_SYM_VERSION_3_5:
00747 case BFD_SYM_VERSION_3_4:
00748 case BFD_SYM_VERSION_3_1:
00749 default:
00750 break;
00751 }
00752
00753 if (parser == NULL)
00754 return -1;
00755
00756 offset = compute_offset (sdata->header.dshb_cmte.dti_first_page,
00757 sdata->header.dshb_page_size,
00758 entry_size, index);
00759
00760 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
00761 return -1;
00762 if (bfd_bread (buf, entry_size, abfd) != entry_size)
00763 return -1;
00764
00765 (*parser) (buf, entry_size, entry);
00766
00767 return 0;
00768 }
00769
00770 int
00771 bfd_sym_fetch_contained_variables_table_entry (abfd, entry, index)
00772 bfd *abfd;
00773 bfd_sym_contained_variables_table_entry *entry;
00774 unsigned long index;
00775 {
00776 void (*parser) PARAMS ((unsigned char *, size_t,
00777 bfd_sym_contained_variables_table_entry *));
00778 unsigned long offset;
00779 unsigned long entry_size = 0;
00780 unsigned char buf[26];
00781 bfd_sym_data_struct *sdata = NULL;
00782
00783 parser = NULL;
00784 BFD_ASSERT (bfd_sym_valid (abfd));
00785 sdata = abfd->tdata.sym_data;
00786
00787 if (index == 0)
00788 return -1;
00789
00790 switch (sdata->version)
00791 {
00792 case BFD_SYM_VERSION_3_3:
00793 case BFD_SYM_VERSION_3_2:
00794 entry_size = 26;
00795 parser = bfd_sym_parse_contained_variables_table_entry_v32;
00796 break;
00797
00798 case BFD_SYM_VERSION_3_5:
00799 case BFD_SYM_VERSION_3_4:
00800 case BFD_SYM_VERSION_3_1:
00801 default:
00802 break;
00803 }
00804
00805 if (parser == NULL)
00806 return -1;
00807
00808 offset = compute_offset (sdata->header.dshb_cvte.dti_first_page,
00809 sdata->header.dshb_page_size,
00810 entry_size, index);
00811
00812 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
00813 return -1;
00814 if (bfd_bread (buf, entry_size, abfd) != entry_size)
00815 return -1;
00816
00817 (*parser) (buf, entry_size, entry);
00818
00819 return 0;
00820 }
00821
00822 int
00823 bfd_sym_fetch_contained_statements_table_entry (abfd, entry, index)
00824 bfd *abfd;
00825 bfd_sym_contained_statements_table_entry *entry;
00826 unsigned long index;
00827 {
00828 void (*parser) PARAMS ((unsigned char *, size_t,
00829 bfd_sym_contained_statements_table_entry *));
00830 unsigned long offset;
00831 unsigned long entry_size = 0;
00832 unsigned char buf[8];
00833 bfd_sym_data_struct *sdata = NULL;
00834
00835 parser = NULL;
00836 BFD_ASSERT (bfd_sym_valid (abfd));
00837 sdata = abfd->tdata.sym_data;
00838
00839 if (index == 0)
00840 return -1;
00841
00842 switch (sdata->version)
00843 {
00844 case BFD_SYM_VERSION_3_3:
00845 case BFD_SYM_VERSION_3_2:
00846 entry_size = 8;
00847 parser = bfd_sym_parse_contained_statements_table_entry_v32;
00848 break;
00849
00850 case BFD_SYM_VERSION_3_5:
00851 case BFD_SYM_VERSION_3_4:
00852 case BFD_SYM_VERSION_3_1:
00853 default:
00854 break;
00855 }
00856
00857 if (parser == NULL)
00858 return -1;
00859
00860 offset = compute_offset (sdata->header.dshb_csnte.dti_first_page,
00861 sdata->header.dshb_page_size,
00862 entry_size, index);
00863
00864 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
00865 return -1;
00866 if (bfd_bread (buf, entry_size, abfd) != entry_size)
00867 return -1;
00868
00869 (*parser) (buf, entry_size, entry);
00870
00871 return 0;
00872 }
00873
00874 int
00875 bfd_sym_fetch_contained_labels_table_entry (abfd, entry, index)
00876 bfd *abfd;
00877 bfd_sym_contained_labels_table_entry *entry;
00878 unsigned long index;
00879 {
00880 void (*parser) PARAMS ((unsigned char *, size_t,
00881 bfd_sym_contained_labels_table_entry *));
00882 unsigned long offset;
00883 unsigned long entry_size = 0;
00884 unsigned char buf[12];
00885 bfd_sym_data_struct *sdata = NULL;
00886
00887 parser = NULL;
00888 BFD_ASSERT (bfd_sym_valid (abfd));
00889 sdata = abfd->tdata.sym_data;
00890
00891 if (index == 0)
00892 return -1;
00893
00894 switch (sdata->version)
00895 {
00896 case BFD_SYM_VERSION_3_3:
00897 case BFD_SYM_VERSION_3_2:
00898 entry_size = 12;
00899 parser = bfd_sym_parse_contained_labels_table_entry_v32;
00900 break;
00901
00902 case BFD_SYM_VERSION_3_5:
00903 case BFD_SYM_VERSION_3_4:
00904 case BFD_SYM_VERSION_3_1:
00905 default:
00906 break;
00907 }
00908
00909 if (parser == NULL)
00910 return -1;
00911
00912 offset = compute_offset (sdata->header.dshb_clte.dti_first_page,
00913 sdata->header.dshb_page_size,
00914 entry_size, index);
00915
00916 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
00917 return -1;
00918 if (bfd_bread (buf, entry_size, abfd) != entry_size)
00919 return -1;
00920
00921 (*parser) (buf, entry_size, entry);
00922
00923 return 0;
00924 }
00925
00926 int
00927 bfd_sym_fetch_contained_types_table_entry (abfd, entry, index)
00928 bfd *abfd;
00929 bfd_sym_contained_types_table_entry *entry;
00930 unsigned long index;
00931 {
00932 void (*parser) PARAMS ((unsigned char *, size_t,
00933 bfd_sym_contained_types_table_entry *));
00934 unsigned long offset;
00935 unsigned long entry_size = 0;
00936 unsigned char buf[0];
00937 bfd_sym_data_struct *sdata = NULL;
00938
00939 parser = NULL;
00940 BFD_ASSERT (bfd_sym_valid (abfd));
00941 sdata = abfd->tdata.sym_data;
00942
00943 if (index == 0)
00944 return -1;
00945
00946 switch (sdata->version)
00947 {
00948 case BFD_SYM_VERSION_3_3:
00949 case BFD_SYM_VERSION_3_2:
00950 entry_size = 0;
00951 parser = NULL;
00952 break;
00953
00954 case BFD_SYM_VERSION_3_5:
00955 case BFD_SYM_VERSION_3_4:
00956 case BFD_SYM_VERSION_3_1:
00957 default:
00958 break;
00959 }
00960
00961 if (parser == NULL)
00962 return -1;
00963
00964 offset = compute_offset (sdata->header.dshb_ctte.dti_first_page,
00965 sdata->header.dshb_page_size,
00966 entry_size, index);
00967
00968 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
00969 return -1;
00970 if (bfd_bread (buf, entry_size, abfd) != entry_size)
00971 return -1;
00972
00973 (*parser) (buf, entry_size, entry);
00974
00975 return 0;
00976 }
00977
00978 int
00979 bfd_sym_fetch_file_references_index_table_entry (abfd, entry, index)
00980 bfd *abfd;
00981 bfd_sym_file_references_index_table_entry *entry;
00982 unsigned long index;
00983 {
00984 void (*parser) PARAMS ((unsigned char *, size_t,
00985 bfd_sym_file_references_index_table_entry *));
00986 unsigned long offset;
00987 unsigned long entry_size = 0;
00988 unsigned char buf[0];
00989 bfd_sym_data_struct *sdata = NULL;
00990
00991 parser = NULL;
00992 BFD_ASSERT (bfd_sym_valid (abfd));
00993 sdata = abfd->tdata.sym_data;
00994
00995 if (index == 0)
00996 return -1;
00997
00998 switch (sdata->version)
00999 {
01000 case BFD_SYM_VERSION_3_3:
01001 case BFD_SYM_VERSION_3_2:
01002 entry_size = 0;
01003 parser = NULL;
01004 break;
01005
01006 case BFD_SYM_VERSION_3_5:
01007 case BFD_SYM_VERSION_3_4:
01008 case BFD_SYM_VERSION_3_1:
01009 default:
01010 break;
01011 }
01012
01013 if (parser == NULL)
01014 return -1;
01015
01016 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
01017 sdata->header.dshb_page_size,
01018 entry_size, index);
01019
01020 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
01021 return -1;
01022 if (bfd_bread (buf, entry_size, abfd) != entry_size)
01023 return -1;
01024
01025 (*parser) (buf, entry_size, entry);
01026
01027 return 0;
01028 }
01029
01030 int
01031 bfd_sym_fetch_constant_pool_entry (abfd, entry, index)
01032 bfd *abfd;
01033 bfd_sym_constant_pool_entry *entry;
01034 unsigned long index;
01035 {
01036 void (*parser) PARAMS ((unsigned char *, size_t,
01037 bfd_sym_constant_pool_entry *));
01038 unsigned long offset;
01039 unsigned long entry_size = 0;
01040 unsigned char buf[0];
01041 bfd_sym_data_struct *sdata = NULL;
01042
01043 parser = NULL;
01044 BFD_ASSERT (bfd_sym_valid (abfd));
01045 sdata = abfd->tdata.sym_data;
01046
01047 if (index == 0)
01048 return -1;
01049
01050 switch (sdata->version)
01051 {
01052 case BFD_SYM_VERSION_3_3:
01053 case BFD_SYM_VERSION_3_2:
01054 entry_size = 0;
01055 parser = NULL;
01056 break;
01057
01058 case BFD_SYM_VERSION_3_5:
01059 case BFD_SYM_VERSION_3_4:
01060 case BFD_SYM_VERSION_3_1:
01061 default:
01062 break;
01063 }
01064
01065 if (parser == NULL)
01066 return -1;
01067
01068 offset = compute_offset (sdata->header.dshb_fite.dti_first_page,
01069 sdata->header.dshb_page_size,
01070 entry_size, index);
01071
01072 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
01073 return -1;
01074 if (bfd_bread (buf, entry_size, abfd) != entry_size)
01075 return -1;
01076
01077 (*parser) (buf, entry_size, entry);
01078
01079 return 0;
01080 }
01081
01082 int
01083 bfd_sym_fetch_type_table_entry (abfd, entry, index)
01084 bfd *abfd;
01085 bfd_sym_type_table_entry *entry;
01086 unsigned long index;
01087 {
01088 void (*parser) PARAMS ((unsigned char *, size_t,
01089 bfd_sym_type_table_entry *));
01090 unsigned long offset;
01091 unsigned long entry_size = 0;
01092 unsigned char buf[4];
01093 bfd_sym_data_struct *sdata = NULL;
01094
01095 parser = NULL;
01096 BFD_ASSERT (bfd_sym_valid (abfd));
01097 sdata = abfd->tdata.sym_data;
01098
01099 switch (sdata->version)
01100 {
01101 case BFD_SYM_VERSION_3_3:
01102 case BFD_SYM_VERSION_3_2:
01103 entry_size = 4;
01104 parser = bfd_sym_parse_type_table_entry_v32;
01105 break;
01106
01107 case BFD_SYM_VERSION_3_5:
01108 case BFD_SYM_VERSION_3_4:
01109 case BFD_SYM_VERSION_3_1:
01110 default:
01111 break;
01112 }
01113
01114 if (parser == NULL)
01115 return -1;
01116
01117 offset = compute_offset (sdata->header.dshb_tte.dti_first_page,
01118 sdata->header.dshb_page_size,
01119 entry_size, index);
01120
01121 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
01122 return -1;
01123 if (bfd_bread (buf, entry_size, abfd) != entry_size)
01124 return -1;
01125
01126 (*parser) (buf, entry_size, entry);
01127
01128 return 0;
01129 }
01130
01131 int
01132 bfd_sym_fetch_type_information_table_entry (abfd, entry, offset)
01133 bfd *abfd;
01134 bfd_sym_type_information_table_entry *entry;
01135 unsigned long offset;
01136 {
01137 unsigned char buf[4];
01138 bfd_sym_data_struct *sdata = NULL;
01139
01140 BFD_ASSERT (bfd_sym_valid (abfd));
01141 sdata = abfd->tdata.sym_data;
01142
01143 if (offset == 0)
01144 return -1;
01145
01146 if (bfd_seek (abfd, offset, SEEK_SET) < 0)
01147 return -1;
01148
01149 if (bfd_bread (buf, 4, abfd) != 4)
01150 return -1;
01151 entry->nte_index = bfd_getb32 (buf);
01152
01153 if (bfd_bread (buf, 2, abfd) != 2)
01154 return -1;
01155 entry->physical_size = bfd_getb16 (buf);
01156
01157 if (entry->physical_size & 0x8000)
01158 {
01159 if (bfd_bread (buf, 4, abfd) != 4)
01160 return -1;
01161 entry->physical_size &= 0x7fff;
01162 entry->logical_size = bfd_getb32 (buf);
01163 entry->offset = offset + 10;
01164 }
01165 else
01166 {
01167 if (bfd_bread (buf, 2, abfd) != 2)
01168 return -1;
01169 entry->physical_size &= 0x7fff;
01170 entry->logical_size = bfd_getb16 (buf);
01171 entry->offset = offset + 8;
01172 }
01173
01174 return 0;
01175 }
01176
01177 int
01178 bfd_sym_fetch_type_table_information (abfd, entry, index)
01179 bfd *abfd;
01180 bfd_sym_type_information_table_entry *entry;
01181 unsigned long index;
01182 {
01183 bfd_sym_type_table_entry tindex;
01184 bfd_sym_data_struct *sdata = NULL;
01185
01186 BFD_ASSERT (bfd_sym_valid (abfd));
01187 sdata = abfd->tdata.sym_data;
01188
01189 if (sdata->header.dshb_tte.dti_object_count <= 99)
01190 return -1;
01191 if (index < 100)
01192 return -1;
01193
01194 if (bfd_sym_fetch_type_table_entry (abfd, &tindex, index - 100) < 0)
01195 return -1;
01196 if (bfd_sym_fetch_type_information_table_entry (abfd, entry, tindex) < 0)
01197 return -1;
01198
01199 return 0;
01200 }
01201
01202 const unsigned char *
01203 bfd_sym_symbol_name (abfd, index)
01204 bfd *abfd;
01205 unsigned long index;
01206 {
01207 bfd_sym_data_struct *sdata = NULL;
01208
01209 BFD_ASSERT (bfd_sym_valid (abfd));
01210 sdata = abfd->tdata.sym_data;
01211
01212 if (index == 0)
01213 return (const unsigned char *) "";
01214
01215 index *= 2;
01216 if ((index / sdata->header.dshb_page_size)
01217 > sdata->header.dshb_nte.dti_page_count)
01218 return (const unsigned char *) "\09[INVALID]";
01219
01220 return (const unsigned char *) sdata->name_table + index;
01221 }
01222
01223 const unsigned char *
01224 bfd_sym_module_name (abfd, index)
01225 bfd *abfd;
01226 unsigned long index;
01227 {
01228 bfd_sym_modules_table_entry entry;
01229
01230 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, index) < 0)
01231 return (const unsigned char *) "\09[INVALID]";
01232
01233 return bfd_sym_symbol_name (abfd, entry.mte_nte_index);
01234 }
01235
01236 const char *
01237 bfd_sym_unparse_storage_kind (kind)
01238 enum bfd_sym_storage_kind kind;
01239 {
01240 switch (kind)
01241 {
01242 case BFD_SYM_STORAGE_KIND_LOCAL: return "LOCAL";
01243 case BFD_SYM_STORAGE_KIND_VALUE: return "VALUE";
01244 case BFD_SYM_STORAGE_KIND_REFERENCE: return "REFERENCE";
01245 case BFD_SYM_STORAGE_KIND_WITH: return "WITH";
01246 default: return "[UNKNOWN]";
01247 }
01248 }
01249
01250 const char *
01251 bfd_sym_unparse_storage_class (kind)
01252 enum bfd_sym_storage_class kind;
01253 {
01254 switch (kind)
01255 {
01256 case BFD_SYM_STORAGE_CLASS_REGISTER: return "REGISTER";
01257 case BFD_SYM_STORAGE_CLASS_GLOBAL: return "GLOBAL";
01258 case BFD_SYM_STORAGE_CLASS_FRAME_RELATIVE: return "FRAME_RELATIVE";
01259 case BFD_SYM_STORAGE_CLASS_STACK_RELATIVE: return "STACK_RELATIVE";
01260 case BFD_SYM_STORAGE_CLASS_ABSOLUTE: return "ABSOLUTE";
01261 case BFD_SYM_STORAGE_CLASS_CONSTANT: return "CONSTANT";
01262 case BFD_SYM_STORAGE_CLASS_RESOURCE: return "RESOURCE";
01263 case BFD_SYM_STORAGE_CLASS_BIGCONSTANT: return "BIGCONSTANT";
01264 default: return "[UNKNOWN]";
01265 }
01266 }
01267
01268 const char *
01269 bfd_sym_unparse_module_kind (kind)
01270 enum bfd_sym_module_kind kind;
01271 {
01272 switch (kind)
01273 {
01274 case BFD_SYM_MODULE_KIND_NONE: return "NONE";
01275 case BFD_SYM_MODULE_KIND_PROGRAM: return "PROGRAM";
01276 case BFD_SYM_MODULE_KIND_UNIT: return "UNIT";
01277 case BFD_SYM_MODULE_KIND_PROCEDURE: return "PROCEDURE";
01278 case BFD_SYM_MODULE_KIND_FUNCTION: return "FUNCTION";
01279 case BFD_SYM_MODULE_KIND_DATA: return "DATA";
01280 case BFD_SYM_MODULE_KIND_BLOCK: return "BLOCK";
01281 default: return "[UNKNOWN]";
01282 }
01283 }
01284
01285 const char *
01286 bfd_sym_unparse_symbol_scope (scope)
01287 enum bfd_sym_symbol_scope scope;
01288 {
01289 switch (scope)
01290 {
01291 case BFD_SYM_SYMBOL_SCOPE_LOCAL: return "LOCAL";
01292 case BFD_SYM_SYMBOL_SCOPE_GLOBAL: return "GLOBAL";
01293 default:
01294 return "[UNKNOWN]";
01295 }
01296 }
01297
01298 void
01299 bfd_sym_print_file_reference (abfd, f, entry)
01300 bfd *abfd;
01301 FILE *f;
01302 bfd_sym_file_reference *entry;
01303 {
01304 bfd_sym_file_references_table_entry frtentry;
01305 int ret;
01306
01307 ret = bfd_sym_fetch_file_references_table_entry (abfd, &frtentry,
01308 entry->fref_frte_index);
01309 fprintf (f, "FILE ");
01310
01311 if ((ret < 0) || (frtentry.generic.type != BFD_SYM_FILE_NAME_INDEX))
01312 fprintf (f, "[INVALID]");
01313 else
01314 fprintf (f, "\"%.*s\"",
01315 bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[0],
01316 &bfd_sym_symbol_name (abfd, frtentry.filename.nte_index)[1]);
01317
01318 fprintf (f, " (FRTE %lu)", entry->fref_frte_index);
01319 }
01320
01321 void
01322 bfd_sym_print_resources_table_entry (abfd, f, entry)
01323 bfd *abfd;
01324 FILE *f;
01325 bfd_sym_resources_table_entry *entry;
01326 {
01327 fprintf (f, " \"%.*s\" (NTE %lu), type \"%.4s\", num %u, size %lu, MTE %lu -- %lu",
01328 bfd_sym_symbol_name (abfd, entry->rte_nte_index)[0],
01329 &bfd_sym_symbol_name (abfd, entry->rte_nte_index)[1],
01330 entry->rte_nte_index, entry->rte_res_type, entry->rte_res_number,
01331 entry->rte_res_size, entry->rte_mte_first, entry->rte_mte_last);
01332 }
01333
01334 void
01335 bfd_sym_print_modules_table_entry (abfd, f, entry)
01336 bfd *abfd;
01337 FILE *f;
01338 bfd_sym_modules_table_entry *entry;
01339 {
01340 fprintf (f, "\"%.*s\" (NTE %lu)",
01341 bfd_sym_symbol_name (abfd, entry->mte_nte_index)[0],
01342 &bfd_sym_symbol_name (abfd, entry->mte_nte_index)[1],
01343 entry->mte_nte_index);
01344
01345 fprintf (f, "\n ");
01346
01347 bfd_sym_print_file_reference (abfd, f, &entry->mte_imp_fref);
01348 fprintf (f, " range %lu -- %lu",
01349 entry->mte_imp_fref.fref_offset, entry->mte_imp_end);
01350
01351 fprintf (f, "\n ");
01352
01353 fprintf (f, "kind %s", bfd_sym_unparse_module_kind (entry->mte_kind));
01354 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->mte_scope));
01355
01356 fprintf (f, ", RTE %lu, offset %lu, size %lu",
01357 entry->mte_rte_index, entry->mte_res_offset, entry->mte_size);
01358
01359 fprintf (f, "\n ");
01360
01361 fprintf (f, "CMTE %lu, CVTE %lu, CLTE %lu, CTTE %lu, CSNTE1 %lu, CSNTE2 %lu",
01362 entry->mte_cmte_index, entry->mte_cvte_index,
01363 entry->mte_clte_index, entry->mte_ctte_index,
01364 entry->mte_csnte_idx_1, entry->mte_csnte_idx_2);
01365
01366 if (entry->mte_parent != 0)
01367 fprintf (f, ", parent %lu", entry->mte_parent);
01368 else
01369 fprintf (f, ", no parent");
01370
01371 if (entry->mte_cmte_index != 0)
01372 fprintf (f, ", child %lu", entry->mte_cmte_index);
01373 else
01374 fprintf (f, ", no child");
01375 }
01376
01377 void
01378 bfd_sym_print_file_references_table_entry (abfd, f, entry)
01379 bfd *abfd;
01380 FILE *f;
01381 bfd_sym_file_references_table_entry *entry;
01382 {
01383 switch (entry->generic.type)
01384 {
01385 case BFD_SYM_FILE_NAME_INDEX:
01386 fprintf (f, "FILE \"%.*s\" (NTE %lu), modtime ",
01387 bfd_sym_symbol_name (abfd, entry->filename.nte_index)[0],
01388 &bfd_sym_symbol_name (abfd, entry->filename.nte_index)[1],
01389 entry->filename.nte_index);
01390
01391 fprintf (f, "[UNIMPLEMENTED]");
01392
01393 fprintf (f, " (0x%lx)", entry->filename.mod_date);
01394 break;
01395
01396 case BFD_SYM_END_OF_LIST:
01397 fprintf (f, "END");
01398 break;
01399
01400 default:
01401 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu",
01402 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
01403 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
01404 entry->entry.mte_index,
01405 entry->entry.file_offset);
01406 break;
01407 }
01408 }
01409
01410 void
01411 bfd_sym_print_contained_modules_table_entry (abfd, f, entry)
01412 bfd *abfd;
01413 FILE *f;
01414 bfd_sym_contained_modules_table_entry *entry;
01415 {
01416 switch (entry->generic.type)
01417 {
01418 case BFD_SYM_END_OF_LIST:
01419 fprintf (f, "END");
01420 break;
01421
01422 default:
01423 fprintf (f, "\"%.*s\" (MTE %lu, NTE %lu)",
01424 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
01425 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
01426 entry->entry.mte_index,
01427 entry->entry.nte_index);
01428 break;
01429 }
01430 }
01431
01432 void
01433 bfd_sym_print_contained_variables_table_entry (abfd, f, entry)
01434 bfd *abfd;
01435 FILE *f;
01436 bfd_sym_contained_variables_table_entry *entry;
01437 {
01438 if (entry->generic.type == BFD_SYM_END_OF_LIST)
01439 {
01440 fprintf (f, "END");
01441 return;
01442 }
01443
01444 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
01445 {
01446 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
01447 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
01448 return;
01449 }
01450
01451 fprintf (f, "\"%.*s\" (NTE %lu)",
01452 bfd_sym_symbol_name (abfd, entry->entry.nte_index)[0],
01453 &bfd_sym_symbol_name (abfd, entry->entry.nte_index)[1],
01454 entry->entry.nte_index);
01455
01456 fprintf (f, ", TTE %lu", entry->entry.tte_index);
01457 fprintf (f, ", offset %lu", entry->entry.file_delta);
01458 fprintf (f, ", scope %s", bfd_sym_unparse_symbol_scope (entry->entry.scope));
01459
01460 if (entry->entry.la_size == BFD_SYM_CVTE_SCA)
01461 fprintf (f, ", latype %s, laclass %s, laoffset %lu",
01462 bfd_sym_unparse_storage_kind (entry->entry.address.scstruct.sca_kind),
01463 bfd_sym_unparse_storage_class (entry->entry.address.scstruct.sca_class),
01464 entry->entry.address.scstruct.sca_offset);
01465 else if (entry->entry.la_size <= BFD_SYM_CVTE_LA_MAX_SIZE)
01466 {
01467 unsigned long i;
01468
01469 fprintf (f, ", la [");
01470 for (i = 0; i < entry->entry.la_size; i++)
01471 fprintf (f, "0x%02x ", entry->entry.address.lastruct.la[i]);
01472 fprintf (f, "]");
01473 }
01474 else if (entry->entry.la_size == BFD_SYM_CVTE_BIG_LA)
01475 fprintf (f, ", bigla %lu, biglakind %u",
01476 entry->entry.address.biglastruct.big_la,
01477 entry->entry.address.biglastruct.big_la_kind);
01478
01479 else
01480 fprintf (f, ", la [INVALID]");
01481 }
01482
01483 void
01484 bfd_sym_print_contained_statements_table_entry (abfd, f, entry)
01485 bfd *abfd;
01486 FILE *f;
01487 bfd_sym_contained_statements_table_entry *entry;
01488 {
01489 if (entry->generic.type == BFD_SYM_END_OF_LIST)
01490 {
01491 fprintf (f, "END");
01492 return;
01493 }
01494
01495 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
01496 {
01497 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
01498 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
01499 return;
01500 }
01501
01502 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu",
01503 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
01504 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
01505 entry->entry.mte_index,
01506 entry->entry.mte_offset,
01507 entry->entry.file_delta);
01508 }
01509
01510 void
01511 bfd_sym_print_contained_labels_table_entry (abfd, f, entry)
01512 bfd *abfd;
01513 FILE *f;
01514 bfd_sym_contained_labels_table_entry *entry;
01515 {
01516 if (entry->generic.type == BFD_SYM_END_OF_LIST)
01517 {
01518 fprintf (f, "END");
01519 return;
01520 }
01521
01522 if (entry->generic.type == BFD_SYM_SOURCE_FILE_CHANGE)
01523 {
01524 bfd_sym_print_file_reference (abfd, f, &entry->file.fref);
01525 fprintf (f, " offset %lu", entry->file.fref.fref_offset);
01526 return;
01527 }
01528
01529 fprintf (f, "\"%.*s\" (MTE %lu), offset %lu, delta %lu, scope %s",
01530 bfd_sym_module_name (abfd, entry->entry.mte_index)[0],
01531 &bfd_sym_module_name (abfd, entry->entry.mte_index)[1],
01532 entry->entry.mte_index,
01533 entry->entry.mte_offset,
01534 entry->entry.file_delta,
01535 bfd_sym_unparse_symbol_scope (entry->entry.scope));
01536 }
01537
01538 void
01539 bfd_sym_print_contained_types_table_entry (abfd, f, entry)
01540 bfd *abfd ATTRIBUTE_UNUSED;
01541 FILE *f;
01542 bfd_sym_contained_types_table_entry *entry ATTRIBUTE_UNUSED;
01543 {
01544 fprintf (f, "[UNIMPLEMENTED]");
01545 }
01546
01547 const char *
01548 bfd_sym_type_operator_name (num)
01549 unsigned char num;
01550 {
01551 switch (num)
01552 {
01553 case 1: return "TTE";
01554 case 2: return "PointerTo";
01555 case 3: return "ScalarOf";
01556 case 4: return "ConstantOf";
01557 case 5: return "EnumerationOf";
01558 case 6: return "VectorOf";
01559 case 7: return "RecordOf";
01560 case 8: return "UnionOf";
01561 case 9: return "SubRangeOf";
01562 case 10: return "SetOf";
01563 case 11: return "NamedTypeOf";
01564 case 12: return "ProcOf";
01565 case 13: return "ValueOf";
01566 case 14: return "ArrayOf";
01567 default: return "[UNKNOWN OPERATOR]";
01568 }
01569 }
01570
01571 const char *
01572 bfd_sym_type_basic_name (num)
01573 unsigned char num;
01574 {
01575 switch (num)
01576 {
01577 case 0: return "void";
01578 case 1: return "pascal string";
01579 case 2: return "unsigned long";
01580 case 3: return "signed long";
01581 case 4: return "extended (10 bytes)";
01582 case 5: return "pascal boolean (1 byte)";
01583 case 6: return "unsigned byte";
01584 case 7: return "signed byte";
01585 case 8: return "character (1 byte)";
01586 case 9: return "wide character (2 bytes)";
01587 case 10: return "unsigned short";
01588 case 11: return "signed short";
01589 case 12: return "singled";
01590 case 13: return "double";
01591 case 14: return "extended (12 bytes)";
01592 case 15: return "computational (8 bytes)";
01593 case 16: return "c string";
01594 case 17: return "as-is string";
01595 default: return "[UNKNOWN BASIC TYPE]";
01596 }
01597 }
01598
01599 int
01600 bfd_sym_fetch_long (buf, len, offset, offsetptr, value)
01601 unsigned char *buf;
01602 unsigned long len;
01603 unsigned long offset;
01604 unsigned long *offsetptr;
01605 long *value;
01606 {
01607 int ret;
01608
01609 if (offset >= len)
01610 {
01611 *value = 0;
01612 offset += 0;
01613 ret = -1;
01614 }
01615 else if (! (buf[offset] & 0x80))
01616 {
01617 *value = buf[offset];
01618 offset += 1;
01619 ret = 0;
01620 }
01621 else if (buf[offset] == 0xc0)
01622 {
01623 if ((offset + 5) > len)
01624 {
01625 *value = 0;
01626 offset = len;
01627 ret = -1;
01628 }
01629 else
01630 {
01631 *value = bfd_getb32 (buf + offset + 1);
01632 offset += 5;
01633 ret = 0;
01634 }
01635 }
01636 else if ((buf[offset] & 0xc0) == 0xc0)
01637 {
01638 *value = -(buf[offset] & 0x3f);
01639 offset += 1;
01640 ret = 0;
01641 }
01642 else if ((buf[offset] & 0xc0) == 0x80)
01643 {
01644 if ((offset + 2) > len)
01645 {
01646 *value = 0;
01647 offset = len;
01648 ret = -1;
01649 }
01650 else
01651 {
01652 *value = bfd_getb16 (buf + offset) & 0x3fff;
01653 offset += 2;
01654 ret = 0;
01655 }
01656 }
01657 else
01658 abort ();
01659
01660 if (offsetptr != NULL)
01661 *offsetptr = offset;
01662
01663 return ret;
01664 }
01665
01666 void
01667 bfd_sym_print_type_information (abfd, f, buf, len, offset, offsetptr)
01668 bfd *abfd;
01669 FILE *f;
01670 unsigned char *buf;
01671 unsigned long len;
01672 unsigned long offset;
01673 unsigned long *offsetptr;
01674 {
01675 unsigned int type;
01676
01677 if (offset >= len)
01678 {
01679 fprintf (f, "[NULL]");
01680
01681 if (offsetptr != NULL)
01682 *offsetptr = offset;
01683 return;
01684 }
01685
01686 type = buf[offset];
01687 offset++;
01688
01689 if (! (type & 0x80))
01690 {
01691 fprintf (f, "[%s] (0x%x)", bfd_sym_type_basic_name (type & 0x7f), type);
01692
01693 if (offsetptr != NULL)
01694 *offsetptr = offset;
01695 return;
01696 }
01697
01698 if (type & 0x40)
01699 fprintf (f, "[packed ");
01700 else
01701 fprintf (f, "[");
01702
01703 switch (type & 0x3f)
01704 {
01705 case 1:
01706 {
01707 long value;
01708 bfd_sym_type_information_table_entry tinfo;
01709
01710 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
01711 if (value <= 0)
01712 fprintf (f, "[INVALID]");
01713 else
01714 {
01715 if (bfd_sym_fetch_type_table_information (abfd, &tinfo, value) < 0)
01716 fprintf (f, "[INVALID]");
01717 else
01718 fprintf (f, "\"%.*s\"",
01719 bfd_sym_symbol_name (abfd, tinfo.nte_index)[0],
01720 &bfd_sym_symbol_name (abfd, tinfo.nte_index)[1]);
01721 }
01722 fprintf (f, " (TTE %lu)", value);
01723 break;
01724 }
01725
01726 case 2:
01727 fprintf (f, "pointer (0x%x) to ", type);
01728 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01729 break;
01730
01731 case 3:
01732 {
01733 long value;
01734
01735 fprintf (f, "scalar (0x%x) of ", type);
01736 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01737 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
01738 fprintf (f, " (%lu)", (unsigned long) value);
01739 break;
01740 }
01741
01742 case 5:
01743 {
01744 long lower, upper, nelem;
01745 int i;
01746
01747 fprintf (f, "enumeration (0x%x) of ", type);
01748 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01749 bfd_sym_fetch_long (buf, len, offset, &offset, &lower);
01750 bfd_sym_fetch_long (buf, len, offset, &offset, &upper);
01751 bfd_sym_fetch_long (buf, len, offset, &offset, &nelem);
01752 fprintf (f, " from %lu to %lu with %lu elements: ",
01753 (unsigned long) lower, (unsigned long) upper,
01754 (unsigned long) nelem);
01755
01756 for (i = 0; i < nelem; i++)
01757 {
01758 fprintf (f, "\n ");
01759 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01760 }
01761 break;
01762 }
01763
01764 case 6:
01765 fprintf (f, "vector (0x%x)", type);
01766 fprintf (f, "\n index ");
01767 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01768 fprintf (f, "\n target ");
01769 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01770 break;
01771
01772 case 7:
01773 case 8:
01774 {
01775 long nrec, eloff, i;
01776
01777 if ((type & 0x3f) == 7)
01778 fprintf (f, "record (0x%x) of ", type);
01779 else
01780 fprintf (f, "union (0x%x) of ", type);
01781
01782 bfd_sym_fetch_long (buf, len, offset, &offset, &nrec);
01783 fprintf (f, "%lu elements: ", nrec);
01784
01785 for (i = 0; i < nrec; i++)
01786 {
01787 bfd_sym_fetch_long (buf, len, offset, &offset, &eloff);
01788 fprintf (f, "\n ");
01789 fprintf (f, "offset %lu: ", eloff);
01790 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01791 }
01792 break;
01793 }
01794
01795 case 9:
01796 fprintf (f, "subrange (0x%x) of ", type);
01797 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01798 fprintf (f, " lower ");
01799 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01800 fprintf (f, " upper ");
01801 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01802 break;
01803
01804 case 11:
01805 {
01806 long value;
01807
01808 fprintf (f, "named type (0x%x) ", type);
01809 bfd_sym_fetch_long (buf, len, offset, &offset, &value);
01810 if (value <= 0)
01811 fprintf (f, "[INVALID]");
01812 else
01813 fprintf (f, "\"%.*s\"",
01814 bfd_sym_symbol_name (abfd, value)[0],
01815 &bfd_sym_symbol_name (abfd, value)[1]);
01816
01817 fprintf (f, " (NTE %lu) with type ", value);
01818 bfd_sym_print_type_information (abfd, f, buf, len, offset, &offset);
01819 break;
01820 }
01821
01822 default:
01823 fprintf (f, "%s (0x%x)", bfd_sym_type_operator_name (type), type);
01824 break;
01825 }
01826
01827 if (type == (0x40 | 0x6))
01828 {
01829
01830 long n, width, m;
01831 long l;
01832 long i;
01833
01834 bfd_sym_fetch_long (buf, len, offset, &offset, &n);
01835 bfd_sym_fetch_long (buf, len, offset, &offset, &width);
01836 bfd_sym_fetch_long (buf, len, offset, &offset, &m);
01837
01838 fprintf (f, " N %ld, width %ld, M %ld, ", n, width, m);
01839 for (i = 0; i < m; i++)
01840 {
01841 bfd_sym_fetch_long (buf, len, offset, &offset, &l);
01842 if (i != 0)
01843 fprintf (f, " ");
01844 fprintf (f, "%ld", l);
01845 }
01846 }
01847 else if (type & 0x40)
01848 {
01849
01850 long msb, lsb;
01851
01852 bfd_sym_fetch_long (buf, len, offset, &offset, &msb);
01853 bfd_sym_fetch_long (buf, len, offset, &offset, &lsb);
01854
01855 fprintf (f, " msb %ld, lsb %ld", msb, lsb);
01856 }
01857
01858 fprintf (f, "]");
01859
01860 if (offsetptr != NULL)
01861 *offsetptr = offset;
01862 }
01863
01864 void
01865 bfd_sym_print_type_information_table_entry (abfd, f, entry)
01866 bfd *abfd;
01867 FILE *f;
01868 bfd_sym_type_information_table_entry *entry;
01869 {
01870 unsigned char *buf;
01871 unsigned long offset;
01872 unsigned int i;
01873
01874 fprintf (f, "\"%.*s\" (NTE %lu), %lu bytes at %lu, logical size %lu",
01875 bfd_sym_symbol_name (abfd, entry->nte_index)[0],
01876 &bfd_sym_symbol_name (abfd, entry->nte_index)[1],
01877 entry->nte_index,
01878 entry->physical_size, entry->offset, entry->logical_size);
01879
01880 fprintf (f, "\n ");
01881
01882 buf = alloca (entry->physical_size);
01883 if (buf == NULL)
01884 {
01885 fprintf (f, "[ERROR]\n");
01886 return;
01887 }
01888 if (bfd_seek (abfd, entry->offset, SEEK_SET) < 0)
01889 {
01890 fprintf (f, "[ERROR]\n");
01891 return;
01892 }
01893 if (bfd_bread (buf, entry->physical_size, abfd) != entry->physical_size)
01894 {
01895 fprintf (f, "[ERROR]\n");
01896 return;
01897 }
01898
01899 fprintf (f, "[");
01900 for (i = 0; i < entry->physical_size; i++)
01901 {
01902 if (i == 0)
01903 fprintf (f, "0x%02x", buf[i]);
01904 else
01905 fprintf (f, " 0x%02x", buf[i]);
01906 }
01907
01908 fprintf (f, "]");
01909 fprintf (f, "\n ");
01910
01911 bfd_sym_print_type_information (abfd, f, buf, entry->physical_size, 0, &offset);
01912
01913 if (offset != entry->physical_size)
01914 fprintf (f, "\n [parser used %lu bytes instead of %lu]", offset, entry->physical_size); }
01915
01916 void
01917 bfd_sym_print_file_references_index_table_entry (abfd, f, entry)
01918 bfd *abfd ATTRIBUTE_UNUSED;
01919 FILE *f;
01920 bfd_sym_file_references_index_table_entry *entry ATTRIBUTE_UNUSED;
01921 {
01922 fprintf (f, "[UNIMPLEMENTED]");
01923 }
01924
01925 void
01926 bfd_sym_print_constant_pool_entry (abfd, f, entry)
01927 bfd *abfd ATTRIBUTE_UNUSED;
01928 FILE *f;
01929 bfd_sym_constant_pool_entry *entry ATTRIBUTE_UNUSED;
01930 {
01931 fprintf (f, "[UNIMPLEMENTED]");
01932 }
01933
01934 unsigned char *
01935 bfd_sym_display_name_table_entry (abfd, f, entry)
01936 bfd *abfd;
01937 FILE *f;
01938 unsigned char *entry;
01939 {
01940 unsigned long index;
01941 unsigned long offset;
01942 bfd_sym_data_struct *sdata = NULL;
01943
01944 BFD_ASSERT (bfd_sym_valid (abfd));
01945 sdata = abfd->tdata.sym_data;
01946 index = (entry - sdata->name_table) / 2;
01947
01948 if (sdata->version >= BFD_SYM_VERSION_3_4 && entry[0] == 255 && entry[1] == 0)
01949 {
01950 unsigned short length = bfd_getb16 (entry + 2);
01951 fprintf (f, "[%8lu] \"%.*s\"\n", index, length, entry + 4);
01952 offset = 2 + length + 1;
01953 }
01954 else
01955 {
01956 if (! (entry[0] == 0 || (entry[0] == 1 && entry[1] == '\0')))
01957 fprintf (f, "[%8lu] \"%.*s\"\n", index, entry[0], entry + 1);
01958
01959 if (sdata->version >= BFD_SYM_VERSION_3_4)
01960 offset = entry[0] + 2;
01961 else
01962 offset = entry[0] + 1;
01963 }
01964
01965 return (entry + offset + (offset % 2));
01966 }
01967
01968 void
01969 bfd_sym_display_name_table (abfd, f)
01970 bfd *abfd;
01971 FILE *f;
01972 {
01973 unsigned long name_table_len;
01974 unsigned char *name_table, *name_table_end, *cur;
01975 bfd_sym_data_struct *sdata = NULL;
01976
01977 BFD_ASSERT (bfd_sym_valid (abfd));
01978 sdata = abfd->tdata.sym_data;
01979
01980 name_table_len = sdata->header.dshb_nte.dti_page_count * sdata->header.dshb_page_size;
01981 name_table = sdata->name_table;
01982 name_table_end = name_table + name_table_len;
01983
01984 fprintf (f, "name table (NTE) contains %lu bytes:\n\n", name_table_len);
01985
01986 cur = name_table;
01987 for (;;)
01988 {
01989 cur = bfd_sym_display_name_table_entry (abfd, f, cur);
01990 if (cur >= name_table_end)
01991 break;
01992 }
01993 }
01994
01995 void
01996 bfd_sym_display_resources_table (abfd, f)
01997 bfd *abfd;
01998 FILE *f;
01999 {
02000 unsigned long i;
02001 bfd_sym_resources_table_entry entry;
02002 bfd_sym_data_struct *sdata = NULL;
02003
02004 BFD_ASSERT (bfd_sym_valid (abfd));
02005 sdata = abfd->tdata.sym_data;
02006
02007 fprintf (f, "resource table (RTE) contains %lu objects:\n\n",
02008 sdata->header.dshb_rte.dti_object_count);
02009
02010 for (i = 1; i <= sdata->header.dshb_rte.dti_object_count; i++)
02011 {
02012 if (bfd_sym_fetch_resources_table_entry (abfd, &entry, i) < 0)
02013 fprintf (f, " [%8lu] [INVALID]\n", i);
02014 else
02015 {
02016 fprintf (f, " [%8lu] ", i);
02017 bfd_sym_print_resources_table_entry (abfd, f, &entry);
02018 fprintf (f, "\n");
02019 }
02020 }
02021 }
02022
02023 void
02024 bfd_sym_display_modules_table (abfd, f)
02025 bfd *abfd;
02026 FILE *f;
02027 {
02028 unsigned long i;
02029 bfd_sym_modules_table_entry entry;
02030 bfd_sym_data_struct *sdata = NULL;
02031
02032 BFD_ASSERT (bfd_sym_valid (abfd));
02033 sdata = abfd->tdata.sym_data;
02034
02035 fprintf (f, "module table (MTE) contains %lu objects:\n\n",
02036 sdata->header.dshb_mte.dti_object_count);
02037
02038 for (i = 1; i <= sdata->header.dshb_mte.dti_object_count; i++)
02039 {
02040 if (bfd_sym_fetch_modules_table_entry (abfd, &entry, i) < 0)
02041 fprintf (f, " [%8lu] [INVALID]\n", i);
02042 else
02043 {
02044 fprintf (f, " [%8lu] ", i);
02045 bfd_sym_print_modules_table_entry (abfd, f, &entry);
02046 fprintf (f, "\n");
02047 }
02048 }
02049 }
02050
02051 void
02052 bfd_sym_display_file_references_table (abfd, f)
02053 bfd *abfd;
02054 FILE *f;
02055 {
02056 unsigned long i;
02057 bfd_sym_file_references_table_entry entry;
02058 bfd_sym_data_struct *sdata = NULL;
02059
02060 BFD_ASSERT (bfd_sym_valid (abfd));
02061 sdata = abfd->tdata.sym_data;
02062
02063 fprintf (f, "file reference table (FRTE) contains %lu objects:\n\n",
02064 sdata->header.dshb_frte.dti_object_count);
02065
02066 for (i = 1; i <= sdata->header.dshb_frte.dti_object_count; i++)
02067 {
02068 if (bfd_sym_fetch_file_references_table_entry (abfd, &entry, i) < 0)
02069 fprintf (f, " [%8lu] [INVALID]\n", i);
02070 else
02071 {
02072 fprintf (f, " [%8lu] ", i);
02073 bfd_sym_print_file_references_table_entry (abfd, f, &entry);
02074 fprintf (f, "\n");
02075 }
02076 }
02077 }
02078
02079 void
02080 bfd_sym_display_contained_modules_table (abfd, f)
02081 bfd *abfd;
02082 FILE *f;
02083 {
02084 unsigned long i;
02085 bfd_sym_contained_modules_table_entry entry;
02086 bfd_sym_data_struct *sdata = NULL;
02087
02088 BFD_ASSERT (bfd_sym_valid (abfd));
02089 sdata = abfd->tdata.sym_data;
02090
02091 fprintf (f, "contained modules table (CMTE) contains %lu objects:\n\n",
02092 sdata->header.dshb_cmte.dti_object_count);
02093
02094 for (i = 1; i <= sdata->header.dshb_cmte.dti_object_count; i++)
02095 {
02096 if (bfd_sym_fetch_contained_modules_table_entry (abfd, &entry, i) < 0)
02097 fprintf (f, " [%8lu] [INVALID]\n", i);
02098 else
02099 {
02100 fprintf (f, " [%8lu] ", i);
02101 bfd_sym_print_contained_modules_table_entry (abfd, f, &entry);
02102 fprintf (f, "\n");
02103 }
02104 }
02105 }
02106
02107 void
02108 bfd_sym_display_contained_variables_table (abfd, f)
02109 bfd *abfd;
02110 FILE *f;
02111 {
02112 unsigned long i;
02113 bfd_sym_contained_variables_table_entry entry;
02114 bfd_sym_data_struct *sdata = NULL;
02115
02116 BFD_ASSERT (bfd_sym_valid (abfd));
02117 sdata = abfd->tdata.sym_data;
02118
02119 fprintf (f, "contained variables table (CVTE) contains %lu objects:\n\n",
02120 sdata->header.dshb_cvte.dti_object_count);
02121
02122 for (i = 1; i <= sdata->header.dshb_cvte.dti_object_count; i++)
02123 {
02124 if (bfd_sym_fetch_contained_variables_table_entry (abfd, &entry, i) < 0)
02125 fprintf (f, " [%8lu] [INVALID]\n", i);
02126 else
02127 {
02128 fprintf (f, " [%8lu] ", i);
02129 bfd_sym_print_contained_variables_table_entry (abfd, f, &entry);
02130 fprintf (f, "\n");
02131 }
02132 }
02133
02134 fprintf (f, "\n");
02135 }
02136
02137 void
02138 bfd_sym_display_contained_statements_table (abfd, f)
02139 bfd *abfd;
02140 FILE *f;
02141 {
02142 unsigned long i;
02143 bfd_sym_contained_statements_table_entry entry;
02144 bfd_sym_data_struct *sdata = NULL;
02145
02146 BFD_ASSERT (bfd_sym_valid (abfd));
02147 sdata = abfd->tdata.sym_data;
02148
02149 fprintf (f, "contained statements table (CSNTE) contains %lu objects:\n\n",
02150 sdata->header.dshb_csnte.dti_object_count);
02151
02152 for (i = 1; i <= sdata->header.dshb_csnte.dti_object_count; i++)
02153 {
02154 if (bfd_sym_fetch_contained_statements_table_entry (abfd, &entry, i) < 0)
02155 fprintf (f, " [%8lu] [INVALID]\n", i);
02156 else
02157 {
02158 fprintf (f, " [%8lu] ", i);
02159 bfd_sym_print_contained_statements_table_entry (abfd, f, &entry);
02160 fprintf (f, "\n");
02161 }
02162 }
02163 }
02164
02165 void
02166 bfd_sym_display_contained_labels_table (abfd, f)
02167 bfd *abfd;
02168 FILE *f;
02169 {
02170 unsigned long i;
02171 bfd_sym_contained_labels_table_entry entry;
02172 bfd_sym_data_struct *sdata = NULL;
02173
02174 BFD_ASSERT (bfd_sym_valid (abfd));
02175 sdata = abfd->tdata.sym_data;
02176
02177 fprintf (f, "contained labels table (CLTE) contains %lu objects:\n\n",
02178 sdata->header.dshb_clte.dti_object_count);
02179
02180 for (i = 1; i <= sdata->header.dshb_clte.dti_object_count; i++)
02181 {
02182 if (bfd_sym_fetch_contained_labels_table_entry (abfd, &entry, i) < 0)
02183 fprintf (f, " [%8lu] [INVALID]\n", i);
02184 else
02185 {
02186 fprintf (f, " [%8lu] ", i);
02187 bfd_sym_print_contained_labels_table_entry (abfd, f, &entry);
02188 fprintf (f, "\n");
02189 }
02190 }
02191 }
02192
02193 void
02194 bfd_sym_display_contained_types_table (abfd, f)
02195 bfd *abfd;
02196 FILE *f;
02197 {
02198 unsigned long i;
02199 bfd_sym_contained_types_table_entry entry;
02200 bfd_sym_data_struct *sdata = NULL;
02201
02202 BFD_ASSERT (bfd_sym_valid (abfd));
02203 sdata = abfd->tdata.sym_data;
02204
02205 fprintf (f, "contained types table (CTTE) contains %lu objects:\n\n",
02206 sdata->header.dshb_ctte.dti_object_count);
02207
02208 for (i = 1; i <= sdata->header.dshb_ctte.dti_object_count; i++)
02209 {
02210 if (bfd_sym_fetch_contained_types_table_entry (abfd, &entry, i) < 0)
02211 fprintf (f, " [%8lu] [INVALID]\n", i);
02212 else
02213 {
02214 fprintf (f, " [%8lu] ", i);
02215 bfd_sym_print_contained_types_table_entry (abfd, f, &entry);
02216 fprintf (f, "\n");
02217 }
02218 }
02219 }
02220
02221 void
02222 bfd_sym_display_file_references_index_table (abfd, f)
02223 bfd *abfd;
02224 FILE *f;
02225 {
02226 unsigned long i;
02227 bfd_sym_file_references_index_table_entry entry;
02228 bfd_sym_data_struct *sdata = NULL;
02229
02230 BFD_ASSERT (bfd_sym_valid (abfd));
02231 sdata = abfd->tdata.sym_data;
02232
02233 fprintf (f, "file references index table (FITE) contains %lu objects:\n\n",
02234 sdata->header.dshb_fite.dti_object_count);
02235
02236 for (i = 1; i <= sdata->header.dshb_fite.dti_object_count; i++)
02237 {
02238 if (bfd_sym_fetch_file_references_index_table_entry (abfd, &entry, i) < 0)
02239 fprintf (f, " [%8lu] [INVALID]\n", i);
02240 else
02241 {
02242 fprintf (f, " [%8lu] ", i);
02243 bfd_sym_print_file_references_index_table_entry (abfd, f, &entry);
02244 fprintf (f, "\n");
02245 }
02246 }
02247 }
02248
02249 void
02250 bfd_sym_display_constant_pool (abfd, f)
02251 bfd *abfd;
02252 FILE *f;
02253 {
02254 unsigned long i;
02255 bfd_sym_constant_pool_entry entry;
02256 bfd_sym_data_struct *sdata = NULL;
02257
02258 BFD_ASSERT (bfd_sym_valid (abfd));
02259 sdata = abfd->tdata.sym_data;
02260
02261 fprintf (f, "constant pool (CONST) contains %lu objects:\n\n",
02262 sdata->header.dshb_const.dti_object_count);
02263
02264 for (i = 1; i <= sdata->header.dshb_const.dti_object_count; i++)
02265 {
02266 if (bfd_sym_fetch_constant_pool_entry (abfd, &entry, i) < 0)
02267 fprintf (f, " [%8lu] [INVALID]\n", i);
02268 else
02269 {
02270 fprintf (f, " [%8lu] ", i);
02271 bfd_sym_print_constant_pool_entry (abfd, f, &entry);
02272 fprintf (f, "\n");
02273 }
02274 }
02275 }
02276
02277 void
02278 bfd_sym_display_type_information_table (abfd, f)
02279 bfd *abfd;
02280 FILE *f;
02281 {
02282 unsigned long i;
02283 bfd_sym_type_table_entry index;
02284 bfd_sym_type_information_table_entry entry;
02285 bfd_sym_data_struct *sdata = NULL;
02286
02287 BFD_ASSERT (bfd_sym_valid (abfd));
02288 sdata = abfd->tdata.sym_data;
02289
02290 if (sdata->header.dshb_tte.dti_object_count > 99)
02291 fprintf (f, "type table (TINFO) contains %lu objects:\n\n",
02292 sdata->header.dshb_tte.dti_object_count - 99);
02293 else
02294 {
02295 fprintf (f, "type table (TINFO) contains [INVALID] objects:\n\n");
02296 return;
02297 }
02298
02299 for (i = 100; i <= sdata->header.dshb_tte.dti_object_count; i++)
02300 {
02301 if (bfd_sym_fetch_type_table_entry (abfd, &index, i - 100) < 0)
02302 fprintf (f, " [%8lu] [INVALID]\n", i);
02303 else
02304 {
02305 fprintf (f, " [%8lu] (TINFO %lu) ", i, index);
02306
02307 if (bfd_sym_fetch_type_information_table_entry (abfd, &entry, index) < 0)
02308 fprintf (f, "[INVALID]");
02309 else
02310 bfd_sym_print_type_information_table_entry (abfd, f, &entry);
02311
02312 fprintf (f, "\n");
02313 }
02314 }
02315 }
02316
02317 int
02318 bfd_sym_scan (abfd, version, mdata)
02319 bfd *abfd;
02320 bfd_sym_version version;
02321 bfd_sym_data_struct *mdata;
02322 {
02323 asection *bfdsec;
02324 const char *name = "symbols";
02325
02326 mdata->name_table = 0;
02327 mdata->sbfd = abfd;
02328 mdata->version = version;
02329
02330 bfd_seek (abfd, 0, SEEK_SET);
02331 if (bfd_sym_read_header (abfd, &mdata->header, mdata->version) != 0)
02332 return -1;
02333
02334 mdata->name_table = bfd_sym_read_name_table (abfd, &mdata->header);
02335 if (mdata->name_table == NULL)
02336 return -1;
02337
02338 bfdsec = bfd_make_section_anyway (abfd, name);
02339 if (bfdsec == NULL)
02340 return -1;
02341
02342 bfdsec->vma = 0;
02343 bfdsec->lma = 0;
02344 bfdsec->size = 0;
02345 bfdsec->filepos = 0;
02346 bfdsec->alignment_power = 0;
02347
02348 bfdsec->flags = SEC_HAS_CONTENTS;
02349
02350 abfd->tdata.sym_data = mdata;
02351
02352 return 0;
02353 }
02354
02355 const bfd_target *
02356 bfd_sym_object_p (abfd)
02357 bfd *abfd;
02358 {
02359 struct bfd_preserve preserve;
02360 bfd_sym_version version = -1;
02361
02362 preserve.marker = NULL;
02363 bfd_seek (abfd, 0, SEEK_SET);
02364 if (bfd_sym_read_version (abfd, &version) != 0)
02365 goto wrong;
02366
02367 preserve.marker = bfd_alloc (abfd, sizeof (bfd_sym_data_struct));
02368 if (preserve.marker == NULL
02369 || ! bfd_preserve_save (abfd, &preserve))
02370 goto fail;
02371
02372 if (bfd_sym_scan (abfd, version,
02373 (bfd_sym_data_struct *) preserve.marker) != 0)
02374 goto wrong;
02375
02376 bfd_preserve_finish (abfd, &preserve);
02377 return abfd->xvec;
02378
02379 wrong:
02380 bfd_set_error (bfd_error_wrong_format);
02381
02382 fail:
02383 if (preserve.marker != NULL)
02384 bfd_preserve_restore (abfd, &preserve);
02385 return NULL;
02386 }
02387
02388 asymbol *
02389 bfd_sym_make_empty_symbol (abfd)
02390 bfd *abfd;
02391 {
02392 return (asymbol *) bfd_alloc (abfd, sizeof (asymbol));
02393 }
02394
02395 void
02396 bfd_sym_get_symbol_info (abfd, symbol, ret)
02397 bfd *abfd ATTRIBUTE_UNUSED;
02398 asymbol *symbol;
02399 symbol_info *ret;
02400 {
02401 bfd_symbol_info (symbol, ret);
02402 }
02403
02404 long
02405 bfd_sym_get_symtab_upper_bound (abfd)
02406 bfd *abfd ATTRIBUTE_UNUSED;
02407 {
02408 return 0;
02409 }
02410
02411 long
02412 bfd_sym_canonicalize_symtab (abfd, sym)
02413 bfd *abfd ATTRIBUTE_UNUSED;
02414 asymbol **sym ATTRIBUTE_UNUSED;
02415 {
02416 return 0;
02417 }
02418
02419 int
02420 bfd_sym_sizeof_headers (abfd, exec)
02421 bfd *abfd ATTRIBUTE_UNUSED;
02422 bfd_boolean exec ATTRIBUTE_UNUSED;
02423 {
02424 return 0;
02425 }
02426
02427 const bfd_target sym_vec =
02428 {
02429 "sym",
02430 bfd_target_sym_flavour,
02431 BFD_ENDIAN_BIG,
02432 BFD_ENDIAN_BIG,
02433 (HAS_RELOC | EXEC_P |
02434 HAS_LINENO | HAS_DEBUG |
02435 HAS_SYMS | HAS_LOCALS | DYNAMIC | WP_TEXT | D_PAGED),
02436 (SEC_ALLOC | SEC_LOAD | SEC_READONLY | SEC_CODE | SEC_DATA
02437 | SEC_ROM | SEC_HAS_CONTENTS),
02438 0,
02439 ' ',
02440 16,
02441 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
02442 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
02443 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
02444 bfd_getb64, bfd_getb_signed_64, bfd_putb64,
02445 bfd_getb32, bfd_getb_signed_32, bfd_putb32,
02446 bfd_getb16, bfd_getb_signed_16, bfd_putb16,
02447 {
02448 _bfd_dummy_target,
02449 bfd_sym_object_p,
02450 _bfd_dummy_target,
02451 _bfd_dummy_target,
02452 },
02453 {
02454 bfd_false,
02455 bfd_sym_mkobject,
02456 bfd_false,
02457 bfd_false,
02458 },
02459 {
02460 bfd_false,
02461 bfd_true,
02462 bfd_false,
02463 bfd_false,
02464 },
02465
02466 BFD_JUMP_TABLE_GENERIC (bfd_sym),
02467 BFD_JUMP_TABLE_COPY (_bfd_generic),
02468 BFD_JUMP_TABLE_CORE (_bfd_nocore),
02469 BFD_JUMP_TABLE_ARCHIVE (_bfd_noarchive),
02470 BFD_JUMP_TABLE_SYMBOLS (bfd_sym),
02471 BFD_JUMP_TABLE_RELOCS (bfd_sym),
02472 BFD_JUMP_TABLE_WRITE (bfd_sym),
02473 BFD_JUMP_TABLE_LINK (bfd_sym),
02474 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic),
02475
02476 NULL,
02477
02478 NULL
02479 };
02480