+static bfd_boolean
+bfd_mach_o_bfd_print_private_bfd_data (bfd *abfd, PTR ptr)
+{
+ bfd_mach_o_data_struct *mdata = abfd->tdata.mach_o_data;
+ FILE *file = (FILE *) ptr;
+ unsigned int i, j;
+ unsigned int sec_nbr = 0;
+
+ fprintf (file, _("Segments and Sections:\n"));
+ fprintf (file, _(" #: Segment name Section name Address\n"));
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ bfd_mach_o_segment_command *seg;
+
+ if (mdata->commands[i].type != BFD_MACH_O_LC_SEGMENT
+ && mdata->commands[i].type != BFD_MACH_O_LC_SEGMENT_64)
+ continue;
+
+ seg = &mdata->commands[i].command.segment;
+
+ fprintf (file, "[Segment %-16s ", seg->segname);
+ fprintf_vma (file, seg->vmaddr);
+ fprintf (file, "-");
+ fprintf_vma (file, seg->vmaddr + seg->vmsize - 1);
+ fputc (' ', file);
+ fputc (seg->initprot & BFD_MACH_O_PROT_READ ? 'r' : '-', file);
+ fputc (seg->initprot & BFD_MACH_O_PROT_WRITE ? 'w' : '-', file);
+ fputc (seg->initprot & BFD_MACH_O_PROT_EXECUTE ? 'x' : '-', file);
+ fprintf (file, "]\n");
+ for (j = 0; j < seg->nsects; j++)
+ {
+ bfd_mach_o_section *sec = &seg->sections[j];
+ fprintf (file, "%02u: %-16s %-16s ", ++sec_nbr,
+ sec->segname, sec->sectname);
+ fprintf_vma (file, sec->addr);
+ fprintf (file, " ");
+ fprintf_vma (file, sec->size);
+ fprintf (file, " %08lx\n", sec->flags);
+ }
+ }
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ bfd_mach_o_load_command *cmd = &mdata->commands[i];
+
+ switch (cmd->type)
+ {
+ case BFD_MACH_O_LC_SEGMENT:
+ case BFD_MACH_O_LC_SEGMENT_64:
+ break;
+ case BFD_MACH_O_LC_UUID:
+ {
+ bfd_mach_o_uuid_command *uuid = &cmd->command.uuid;
+ unsigned int i;
+
+ fprintf (file, "\n"
+ "UUID:");
+ for (i = 0; i < sizeof (uuid->uuid); i++)
+ fprintf (file, " %02x", uuid->uuid[i]);
+ fputc ('\n', file);
+ }
+ break;
+ case BFD_MACH_O_LC_LOAD_DYLIB:
+ {
+ bfd_mach_o_dylib_command *dylib = &cmd->command.dylib;
+ bfd_byte *data = NULL;
+
+ if (! bfd_malloc_and_get_section (abfd, dylib->section, &data))
+ {
+ if (data != NULL)
+ free (data);
+ break;
+ }
+ fprintf (file, "\n"
+ "LOAD_DYLIB: %s\n",
+ data + dylib->name_offset - cmd->offset - 8);
+ fprintf (file, " time stamp: 0x%08lx\n",
+ dylib->timestamp);
+ fprintf (file, " current version: 0x%08lx\n",
+ dylib->current_version);
+ fprintf (file, " comptibility version: 0x%08lx\n",
+ dylib->compatibility_version);
+ free (data);
+ break;
+ }
+ case BFD_MACH_O_LC_LOAD_DYLINKER:
+ {
+ bfd_mach_o_dylinker_command *linker = &cmd->command.dylinker;
+ bfd_byte *data = NULL;
+
+ if (! bfd_malloc_and_get_section (abfd, linker->section, &data))
+ {
+ if (data != NULL)
+ free (data);
+ break;
+ }
+ fprintf (file, "\n"
+ "LOAD_DYLINKER: %s\n",
+ data + linker->name_offset - cmd->offset - 8);
+ free (data);
+ break;
+ }
+ case BFD_MACH_O_LC_SYMTAB:
+ {
+ bfd_mach_o_symtab_command *symtab = &cmd->command.symtab;
+ fprintf (file, "\n"
+ "LC_SYMTAB: nsyms: %lu, strsize: %lu\n",
+ symtab->nsyms, symtab->strsize);
+ break;
+ }
+ case BFD_MACH_O_LC_DYSYMTAB:
+ {
+ bfd_mach_o_dysymtab_command *dysymtab = &cmd->command.dysymtab;
+ fprintf (file, "\n"
+ "LC_DYSYMTAB:\n"
+ " local symbols: index: %lu number: %lu\n",
+ dysymtab->ilocalsym, dysymtab->nlocalsym);
+ fprintf (file,
+ " external symbols: index: %lu number: %lu\n",
+ dysymtab->iextdefsym, dysymtab->nextdefsym);
+ fprintf (file,
+ " undefined symbols: index: %lu number: %lu\n",
+ dysymtab->iundefsym, dysymtab->nundefsym);
+ fprintf (file,
+ " ntoc: offset: %lu number: %lu\n",
+ dysymtab->tocoff, dysymtab->ntoc);
+ fprintf (file,
+ " module table: offset: %lu number: %lu\n",
+ dysymtab->modtaboff, dysymtab->nmodtab);
+ break;
+ }
+ default:
+ fprintf (file, "LC_%d\n", cmd->type);
+ break;
+ }
+ }
+
+ return TRUE;
+}
+