- bfd_mach_o_dysymtab_command *dysymtab = &cmd->command.dysymtab;
- bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
- unsigned int i;
-
- fprintf (file, " local symbols: idx: %10lu num: %-8lu",
- dysymtab->ilocalsym, dysymtab->nlocalsym);
- fprintf (file, " (nxtidx: %lu)\n",
- dysymtab->ilocalsym + dysymtab->nlocalsym);
- fprintf (file, " external symbols: idx: %10lu num: %-8lu",
- dysymtab->iextdefsym, dysymtab->nextdefsym);
- fprintf (file, " (nxtidx: %lu)\n",
- dysymtab->iextdefsym + dysymtab->nextdefsym);
- fprintf (file, " undefined symbols: idx: %10lu num: %-8lu",
- dysymtab->iundefsym, dysymtab->nundefsym);
- fprintf (file, " (nxtidx: %lu)\n",
- dysymtab->iundefsym + dysymtab->nundefsym);
- fprintf (file, " table of content: off: 0x%08lx num: %-8lu",
- dysymtab->tocoff, dysymtab->ntoc);
- fprintf (file, " (endoff: 0x%08lx)\n",
- dysymtab->tocoff
- + dysymtab->ntoc * BFD_MACH_O_TABLE_OF_CONTENT_SIZE);
- fprintf (file, " module table: off: 0x%08lx num: %-8lu",
- dysymtab->modtaboff, dysymtab->nmodtab);
- fprintf (file, " (endoff: 0x%08lx)\n",
- dysymtab->modtaboff + dysymtab->nmodtab
- * (mach_o_wide_p (&mdata->header) ?
- BFD_MACH_O_DYLIB_MODULE_64_SIZE : BFD_MACH_O_DYLIB_MODULE_SIZE));
- fprintf (file, " external reference table: off: 0x%08lx num: %-8lu",
- dysymtab->extrefsymoff, dysymtab->nextrefsyms);
- fprintf (file, " (endoff: 0x%08lx)\n",
- dysymtab->extrefsymoff
- + dysymtab->nextrefsyms * BFD_MACH_O_REFERENCE_SIZE);
- fprintf (file, " indirect symbol table: off: 0x%08lx num: %-8lu",
- dysymtab->indirectsymoff, dysymtab->nindirectsyms);
- fprintf (file, " (endoff: 0x%08lx)\n",
- dysymtab->indirectsymoff
- + dysymtab->nindirectsyms * BFD_MACH_O_INDIRECT_SYMBOL_SIZE);
- fprintf (file, " external relocation table: off: 0x%08lx num: %-8lu",
- dysymtab->extreloff, dysymtab->nextrel);
- fprintf (file, " (endoff: 0x%08lx)\n",
- dysymtab->extreloff + dysymtab->nextrel * BFD_MACH_O_RELENT_SIZE);
- fprintf (file, " local relocation table: off: 0x%08lx num: %-8lu",
- dysymtab->locreloff, dysymtab->nlocrel);
- fprintf (file, " (endoff: 0x%08lx)\n",
- dysymtab->locreloff + dysymtab->nlocrel * BFD_MACH_O_RELENT_SIZE);
-
- if (dysymtab->ntoc > 0
- || dysymtab->nindirectsyms > 0
- || dysymtab->nextrefsyms > 0)
- {
- /* Try to read the symbols to display the toc or indirect symbols. */
- bfd_mach_o_read_symtab_symbols (abfd);
- }
- else if (dysymtab->nmodtab > 0)
- {
- /* Try to read the strtab to display modules name. */
- bfd_mach_o_read_symtab_strtab (abfd);
- }
-
- for (i = 0; i < dysymtab->nmodtab; i++)
- {
- bfd_mach_o_dylib_module *module = &dysymtab->dylib_module[i];
- fprintf (file, " module %u:\n", i);
- fprintf (file, " name: %lu", module->module_name_idx);
- if (mdata->symtab && mdata->symtab->strtab)
- fprintf (file, ": %s",
- mdata->symtab->strtab + module->module_name_idx);
- fprintf (file, "\n");
- fprintf (file, " extdefsym: idx: %8lu num: %lu\n",
- module->iextdefsym, module->nextdefsym);
- fprintf (file, " refsym: idx: %8lu num: %lu\n",
- module->irefsym, module->nrefsym);
- fprintf (file, " localsym: idx: %8lu num: %lu\n",
- module->ilocalsym, module->nlocalsym);
- fprintf (file, " extrel: idx: %8lu num: %lu\n",
- module->iextrel, module->nextrel);
- fprintf (file, " init: idx: %8u num: %u\n",
- module->iinit, module->ninit);
- fprintf (file, " term: idx: %8u num: %u\n",
- module->iterm, module->nterm);
- fprintf (file, " objc_module_info: addr: ");
- fprintf_vma (file, module->objc_module_info_addr);
- fprintf (file, " size: %lu\n", module->objc_module_info_size);
- }
-
- if (dysymtab->ntoc > 0)
- {
- bfd_mach_o_symtab_command *symtab = mdata->symtab;
-
- fprintf (file, " table of content: (symbol/module)\n");
- for (i = 0; i < dysymtab->ntoc; i++)
- {
- bfd_mach_o_dylib_table_of_content *toc = &dysymtab->dylib_toc[i];
-
- fprintf (file, " %4u: ", i);
- if (symtab && symtab->symbols && toc->symbol_index < symtab->nsyms)
- {
- const char *name = symtab->symbols[toc->symbol_index].symbol.name;
- fprintf (file, "%s (%lu)", name ? name : "*invalid*",
- toc->symbol_index);
- }
- else
- fprintf (file, "%lu", toc->symbol_index);
-
- fprintf (file, " / ");
- if (symtab && symtab->strtab
- && toc->module_index < dysymtab->nmodtab)
- {
- bfd_mach_o_dylib_module *mod;
- mod = &dysymtab->dylib_module[toc->module_index];
- fprintf (file, "%s (%lu)",
- symtab->strtab + mod->module_name_idx,
- toc->module_index);
- }
- else
- fprintf (file, "%lu", toc->module_index);
-
- fprintf (file, "\n");
- }
- }
-
- if (dysymtab->nindirectsyms != 0)
- {
- fprintf (file, " indirect symbols:\n");
-
- for (i = 0; i < mdata->nsects; i++)
- {
- bfd_mach_o_section *sec = mdata->sections[i];
- unsigned int j, first, last;
- bfd_mach_o_symtab_command *symtab = mdata->symtab;
- bfd_vma addr;
- bfd_vma entry_size;
-
- switch (sec->flags & BFD_MACH_O_SECTION_TYPE_MASK)
- {
- case BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS:
- case BFD_MACH_O_S_LAZY_SYMBOL_POINTERS:
- case BFD_MACH_O_S_SYMBOL_STUBS:
- first = sec->reserved1;
- last = first + bfd_mach_o_section_get_nbr_indirect (abfd, sec);
- addr = sec->addr;
- entry_size = bfd_mach_o_section_get_entry_size (abfd, sec);
- fprintf (file, " for section %s.%s:\n",
- sec->segname, sec->sectname);
- for (j = first; j < last; j++)
- {
- unsigned int isym = dysymtab->indirect_syms[j];
-
- fprintf (file, " ");
- fprintf_vma (file, addr);
- fprintf (file, " %5u: 0x%08x", j, isym);
- if (isym & BFD_MACH_O_INDIRECT_SYMBOL_LOCAL)
- fprintf (file, " LOCAL");
- if (isym & BFD_MACH_O_INDIRECT_SYMBOL_ABS)
- fprintf (file, " ABSOLUTE");
- if (symtab && symtab->symbols
- && isym < symtab->nsyms
- && symtab->symbols[isym].symbol.name)
- fprintf (file, " %s", symtab->symbols[isym].symbol.name);
- fprintf (file, "\n");
- addr += entry_size;
- }
- break;
- default:
- break;
- }
- }
- }
- if (dysymtab->nextrefsyms > 0)
- {
- bfd_mach_o_symtab_command *symtab = mdata->symtab;
-
- fprintf (file, " external reference table: (symbol flags)\n");
- for (i = 0; i < dysymtab->nextrefsyms; i++)
- {
- bfd_mach_o_dylib_reference *ref = &dysymtab->ext_refs[i];
-
- fprintf (file, " %4u: %5lu 0x%02lx", i, ref->isym, ref->flags);
- if (symtab && symtab->symbols
- && ref->isym < symtab->nsyms
- && symtab->symbols[ref->isym].symbol.name)
- fprintf (file, " %s", symtab->symbols[ref->isym].symbol.name);
- fprintf (file, "\n");
- }
- }