Mach-O: improve objdump -P load output.
binutils/ * od-macho.c (dump_header): Display sizeofcmds in decimal too. (dump_segment): Reformat output. (dump_dyld_info): Also display end offsets. (dump_load_command): Add IDX argument, display commands size and offset, reformat display. (dump_load_commands): Adjust for added argument.
This commit is contained in:
parent
12241a34d7
commit
47f8a1070c
|
@ -1,3 +1,12 @@
|
||||||
|
2014-04-16 Tristan Gingold <gingold@adacore.com>
|
||||||
|
|
||||||
|
* od-macho.c (dump_header): Display sizeofcmds in decimal too.
|
||||||
|
(dump_segment): Reformat output.
|
||||||
|
(dump_dyld_info): Also display end offsets.
|
||||||
|
(dump_load_command): Add IDX argument, display commands size
|
||||||
|
and offset, reformat display.
|
||||||
|
(dump_load_commands): Adjust for added argument.
|
||||||
|
|
||||||
2014-04-07 Alan Modra <amodra@gmail.com>
|
2014-04-07 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
PR binutils/16811
|
PR binutils/16811
|
||||||
|
|
|
@ -294,7 +294,7 @@ dump_header (bfd *abfd)
|
||||||
h->filetype,
|
h->filetype,
|
||||||
bfd_mach_o_get_name (bfd_mach_o_filetype_name, h->filetype));
|
bfd_mach_o_get_name (bfd_mach_o_filetype_name, h->filetype));
|
||||||
printf (_(" ncmds : %08lx (%lu)\n"), h->ncmds, h->ncmds);
|
printf (_(" ncmds : %08lx (%lu)\n"), h->ncmds, h->ncmds);
|
||||||
printf (_(" sizeofcmds: %08lx\n"), h->sizeofcmds);
|
printf (_(" sizeofcmds: %08lx (%lu)\n"), h->sizeofcmds, h->sizeofcmds);
|
||||||
printf (_(" flags : %08lx ("), h->flags);
|
printf (_(" flags : %08lx ("), h->flags);
|
||||||
bfd_mach_o_print_flags (bfd_mach_o_header_flags_name, h->flags);
|
bfd_mach_o_print_flags (bfd_mach_o_header_flags_name, h->flags);
|
||||||
fputs (_(")\n"), stdout);
|
fputs (_(")\n"), stdout);
|
||||||
|
@ -405,26 +405,26 @@ dump_segment (bfd *abfd ATTRIBUTE_UNUSED, bfd_mach_o_load_command *cmd)
|
||||||
bfd_mach_o_segment_command *seg = &cmd->command.segment;
|
bfd_mach_o_segment_command *seg = &cmd->command.segment;
|
||||||
bfd_mach_o_section *sec;
|
bfd_mach_o_section *sec;
|
||||||
|
|
||||||
printf (" name: %s\n", *seg->segname ? seg->segname : "*none*");
|
printf (" name: %16s", *seg->segname ? seg->segname : "*none*");
|
||||||
printf (" vmaddr: ");
|
printf (" nsects: %lu", seg->nsects);
|
||||||
|
printf (" flags: %lx", seg->flags);
|
||||||
|
printf (" initprot: ");
|
||||||
|
disp_segment_prot (seg->initprot);
|
||||||
|
printf (" maxprot: ");
|
||||||
|
disp_segment_prot (seg->maxprot);
|
||||||
|
printf ("\n");
|
||||||
|
printf (" vmaddr: ");
|
||||||
printf_vma (seg->vmaddr);
|
printf_vma (seg->vmaddr);
|
||||||
printf (" vmsize: ");
|
printf (" vmsize: ");
|
||||||
printf_vma (seg->vmsize);
|
printf_vma (seg->vmsize);
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf (" fileoff: ");
|
printf (" fileoff: ");
|
||||||
printf_vma (seg->fileoff);
|
printf_vma (seg->fileoff);
|
||||||
printf (" filesize: ");
|
printf (" filesize: ");
|
||||||
printf_vma ((bfd_vma)seg->filesize);
|
printf_vma ((bfd_vma)seg->filesize);
|
||||||
printf (" endoff: ");
|
printf (" endoff: ");
|
||||||
printf_vma ((bfd_vma)(seg->fileoff + seg->filesize));
|
printf_vma ((bfd_vma)(seg->fileoff + seg->filesize));
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
printf (" nsects: %lu", seg->nsects);
|
|
||||||
printf (" flags: %lx", seg->flags);
|
|
||||||
printf (" initprot: ");
|
|
||||||
disp_segment_prot (seg->initprot);
|
|
||||||
printf (" maxprot: ");
|
|
||||||
disp_segment_prot (seg->maxprot);
|
|
||||||
printf ("\n");
|
|
||||||
for (sec = seg->sect_head; sec != NULL; sec = sec->next)
|
for (sec = seg->sect_head; sec != NULL; sec = sec->next)
|
||||||
dump_section_header (abfd, sec);
|
dump_section_header (abfd, sec);
|
||||||
}
|
}
|
||||||
|
@ -627,16 +627,21 @@ dump_dyld_info (bfd *abfd ATTRIBUTE_UNUSED, bfd_mach_o_load_command *cmd)
|
||||||
{
|
{
|
||||||
bfd_mach_o_dyld_info_command *info = &cmd->command.dyld_info;
|
bfd_mach_o_dyld_info_command *info = &cmd->command.dyld_info;
|
||||||
|
|
||||||
printf (" rebase: off: 0x%08x size: %-8u\n",
|
printf (" rebase: off: 0x%08x size: %-8u (endoff: 0x%08x)\n",
|
||||||
info->rebase_off, info->rebase_size);
|
info->rebase_off, info->rebase_size,
|
||||||
printf (" bind: off: 0x%08x size: %-8u\n",
|
info->rebase_off + info->rebase_size);
|
||||||
info->bind_off, info->bind_size);
|
printf (" bind: off: 0x%08x size: %-8u (endoff: 0x%08x)\n",
|
||||||
printf (" weak bind: off: 0x%08x size: %-8u\n",
|
info->bind_off, info->bind_size,
|
||||||
info->weak_bind_off, info->weak_bind_size);
|
info->bind_off + info->bind_size);
|
||||||
printf (" lazy bind: off: 0x%08x size: %-8u\n",
|
printf (" weak bind: off: 0x%08x size: %-8u (endoff: 0x%08x)\n",
|
||||||
info->lazy_bind_off, info->lazy_bind_size);
|
info->weak_bind_off, info->weak_bind_size,
|
||||||
printf (" export: off: 0x%08x size: %-8u\n",
|
info->weak_bind_off + info->weak_bind_size);
|
||||||
info->export_off, info->export_size);
|
printf (" lazy bind: off: 0x%08x size: %-8u (endoff: 0x%08x)\n",
|
||||||
|
info->lazy_bind_off, info->lazy_bind_size,
|
||||||
|
info->lazy_bind_off + info->lazy_bind_size);
|
||||||
|
printf (" export: off: 0x%08x size: %-8u (endoff: 0x%08x)\n",
|
||||||
|
info->export_off, info->export_size,
|
||||||
|
info->export_off + info->export_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1084,18 +1089,19 @@ dump_twolevel_hints (bfd *abfd, bfd_mach_o_twolevel_hints_command *cmd)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
bfd_boolean verbose)
|
unsigned int idx, bfd_boolean verbose)
|
||||||
{
|
{
|
||||||
bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
|
bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
|
||||||
const char *cmd_name;
|
const char *cmd_name;
|
||||||
|
|
||||||
cmd_name = bfd_mach_o_get_name_or_null
|
cmd_name = bfd_mach_o_get_name_or_null
|
||||||
(bfd_mach_o_load_command_name, cmd->type);
|
(bfd_mach_o_load_command_name, cmd->type);
|
||||||
printf ("Load command ");
|
printf ("Load command #%-2u (size: %3u, offset: %4u): ",
|
||||||
|
idx, cmd->len, cmd->offset);
|
||||||
if (cmd_name == NULL)
|
if (cmd_name == NULL)
|
||||||
printf ("0x%02x:", cmd->type);
|
printf ("0x%02x\n", cmd->type);
|
||||||
else
|
else
|
||||||
printf ("%s:", cmd_name);
|
printf ("%s\n", cmd_name);
|
||||||
|
|
||||||
switch (cmd->type)
|
switch (cmd->type)
|
||||||
{
|
{
|
||||||
|
@ -1108,6 +1114,7 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
bfd_mach_o_uuid_command *uuid = &cmd->command.uuid;
|
bfd_mach_o_uuid_command *uuid = &cmd->command.uuid;
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
|
||||||
|
printf (" ");
|
||||||
for (j = 0; j < sizeof (uuid->uuid); j ++)
|
for (j = 0; j < sizeof (uuid->uuid); j ++)
|
||||||
printf (" %02x", uuid->uuid[j]);
|
printf (" %02x", uuid->uuid[j]);
|
||||||
putchar ('\n');
|
putchar ('\n');
|
||||||
|
@ -1121,7 +1128,7 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB:
|
case BFD_MACH_O_LC_LOAD_UPWARD_DYLIB:
|
||||||
{
|
{
|
||||||
bfd_mach_o_dylib_command *dylib = &cmd->command.dylib;
|
bfd_mach_o_dylib_command *dylib = &cmd->command.dylib;
|
||||||
printf (" %s\n", dylib->name_str);
|
printf (" name: %s\n", dylib->name_str);
|
||||||
printf (" time stamp: 0x%08lx\n",
|
printf (" time stamp: 0x%08lx\n",
|
||||||
dylib->timestamp);
|
dylib->timestamp);
|
||||||
printf (" current version: 0x%08lx\n",
|
printf (" current version: 0x%08lx\n",
|
||||||
|
@ -1132,17 +1139,15 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
break;
|
break;
|
||||||
case BFD_MACH_O_LC_LOAD_DYLINKER:
|
case BFD_MACH_O_LC_LOAD_DYLINKER:
|
||||||
case BFD_MACH_O_LC_ID_DYLINKER:
|
case BFD_MACH_O_LC_ID_DYLINKER:
|
||||||
printf (" %s\n", cmd->command.dylinker.name_str);
|
printf (" %s\n", cmd->command.dylinker.name_str);
|
||||||
break;
|
break;
|
||||||
case BFD_MACH_O_LC_DYLD_ENVIRONMENT:
|
case BFD_MACH_O_LC_DYLD_ENVIRONMENT:
|
||||||
putchar ('\n');
|
printf (" %s\n", cmd->command.dylinker.name_str);
|
||||||
printf (" %s\n", cmd->command.dylinker.name_str);
|
|
||||||
break;
|
break;
|
||||||
case BFD_MACH_O_LC_SYMTAB:
|
case BFD_MACH_O_LC_SYMTAB:
|
||||||
{
|
{
|
||||||
bfd_mach_o_symtab_command *symtab = &cmd->command.symtab;
|
bfd_mach_o_symtab_command *symtab = &cmd->command.symtab;
|
||||||
printf ("\n"
|
printf (" symoff: 0x%08x nsyms: %8u (endoff: 0x%08x)\n",
|
||||||
" symoff: 0x%08x nsyms: %8u (endoff: 0x%08x)\n",
|
|
||||||
symtab->symoff, symtab->nsyms,
|
symtab->symoff, symtab->nsyms,
|
||||||
symtab->symoff + symtab->nsyms
|
symtab->symoff + symtab->nsyms
|
||||||
* (mdata->header.version == 2
|
* (mdata->header.version == 2
|
||||||
|
@ -1153,14 +1158,13 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BFD_MACH_O_LC_DYSYMTAB:
|
case BFD_MACH_O_LC_DYSYMTAB:
|
||||||
putchar ('\n');
|
|
||||||
dump_dysymtab (abfd, cmd, verbose);
|
dump_dysymtab (abfd, cmd, verbose);
|
||||||
break;
|
break;
|
||||||
case BFD_MACH_O_LC_LOADFVMLIB:
|
case BFD_MACH_O_LC_LOADFVMLIB:
|
||||||
case BFD_MACH_O_LC_IDFVMLIB:
|
case BFD_MACH_O_LC_IDFVMLIB:
|
||||||
{
|
{
|
||||||
bfd_mach_o_fvmlib_command *fvmlib = &cmd->command.fvmlib;
|
bfd_mach_o_fvmlib_command *fvmlib = &cmd->command.fvmlib;
|
||||||
printf (" %s\n", fvmlib->name_str);
|
printf (" fvmlib: %s\n", fvmlib->name_str);
|
||||||
printf (" minor version: 0x%08x\n", fvmlib->minor_version);
|
printf (" minor version: 0x%08x\n", fvmlib->minor_version);
|
||||||
printf (" header address: 0x%08x\n", fvmlib->header_addr);
|
printf (" header address: 0x%08x\n", fvmlib->header_addr);
|
||||||
}
|
}
|
||||||
|
@ -1173,8 +1177,7 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
{
|
{
|
||||||
bfd_mach_o_linkedit_command *linkedit = &cmd->command.linkedit;
|
bfd_mach_o_linkedit_command *linkedit = &cmd->command.linkedit;
|
||||||
printf
|
printf
|
||||||
("\n"
|
(" dataoff: 0x%08lx datasize: 0x%08lx (endoff: 0x%08lx)\n",
|
||||||
" dataoff: 0x%08lx datasize: 0x%08lx (endoff: 0x%08lx)\n",
|
|
||||||
linkedit->dataoff, linkedit->datasize,
|
linkedit->dataoff, linkedit->datasize,
|
||||||
linkedit->dataoff + linkedit->datasize);
|
linkedit->dataoff + linkedit->datasize);
|
||||||
|
|
||||||
|
@ -1205,7 +1208,7 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
case BFD_MACH_O_LC_RPATH:
|
case BFD_MACH_O_LC_RPATH:
|
||||||
{
|
{
|
||||||
bfd_mach_o_str_command *str = &cmd->command.str;
|
bfd_mach_o_str_command *str = &cmd->command.str;
|
||||||
printf (" %s\n", str->str);
|
printf (" %s\n", str->str);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BFD_MACH_O_LC_THREAD:
|
case BFD_MACH_O_LC_THREAD:
|
||||||
|
@ -1217,8 +1220,7 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
bfd_mach_o_encryption_info_command *cryp =
|
bfd_mach_o_encryption_info_command *cryp =
|
||||||
&cmd->command.encryption_info;
|
&cmd->command.encryption_info;
|
||||||
printf
|
printf
|
||||||
("\n"
|
(" cryptoff: 0x%08x cryptsize: 0x%08x (endoff 0x%08x)"
|
||||||
" cryptoff: 0x%08x cryptsize: 0x%08x (endoff 0x%08x)"
|
|
||||||
" cryptid: %u\n",
|
" cryptid: %u\n",
|
||||||
cryp->cryptoff, cryp->cryptsize,
|
cryp->cryptoff, cryp->cryptsize,
|
||||||
cryp->cryptoff + cryp->cryptsize,
|
cryp->cryptoff + cryp->cryptsize,
|
||||||
|
@ -1226,7 +1228,6 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BFD_MACH_O_LC_DYLD_INFO:
|
case BFD_MACH_O_LC_DYLD_INFO:
|
||||||
putchar ('\n');
|
|
||||||
dump_dyld_info (abfd, cmd);
|
dump_dyld_info (abfd, cmd);
|
||||||
break;
|
break;
|
||||||
case BFD_MACH_O_LC_VERSION_MIN_MACOSX:
|
case BFD_MACH_O_LC_VERSION_MIN_MACOSX:
|
||||||
|
@ -1234,15 +1235,14 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
{
|
{
|
||||||
bfd_mach_o_version_min_command *ver = &cmd->command.version_min;
|
bfd_mach_o_version_min_command *ver = &cmd->command.version_min;
|
||||||
|
|
||||||
printf (" %u.%u.%u\n", ver->rel, ver->maj, ver->min);
|
printf (" %u.%u.%u\n", ver->rel, ver->maj, ver->min);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BFD_MACH_O_LC_SOURCE_VERSION:
|
case BFD_MACH_O_LC_SOURCE_VERSION:
|
||||||
{
|
{
|
||||||
bfd_mach_o_source_version_command *version =
|
bfd_mach_o_source_version_command *version =
|
||||||
&cmd->command.source_version;
|
&cmd->command.source_version;
|
||||||
printf ("\n"
|
printf (" version a.b.c.d.e: %u.%u.%u.%u.%u\n",
|
||||||
" version a.b.c.d.e: %u.%u.%u.%u.%u\n",
|
|
||||||
version->a, version->b, version->c, version->d, version->e);
|
version->a, version->b, version->c, version->d, version->e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1253,7 +1253,7 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
unsigned int last;
|
unsigned int last;
|
||||||
|
|
||||||
printf (" %s\n", pbdy->name_str);
|
printf (" dylib: %s\n", pbdy->name_str);
|
||||||
printf (" nmodules: %u\n", pbdy->nmodules);
|
printf (" nmodules: %u\n", pbdy->nmodules);
|
||||||
printf (" linked modules (at %u): ",
|
printf (" linked modules (at %u): ",
|
||||||
pbdy->linked_modules_offset - cmd->offset);
|
pbdy->linked_modules_offset - cmd->offset);
|
||||||
|
@ -1268,7 +1268,7 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
case BFD_MACH_O_LC_PREBIND_CKSUM:
|
case BFD_MACH_O_LC_PREBIND_CKSUM:
|
||||||
{
|
{
|
||||||
bfd_mach_o_prebind_cksum_command *cksum = &cmd->command.prebind_cksum;
|
bfd_mach_o_prebind_cksum_command *cksum = &cmd->command.prebind_cksum;
|
||||||
printf (" 0x%08x\n", cksum->cksum);
|
printf (" 0x%08x\n", cksum->cksum);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BFD_MACH_O_LC_TWOLEVEL_HINTS:
|
case BFD_MACH_O_LC_TWOLEVEL_HINTS:
|
||||||
|
@ -1276,8 +1276,7 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
bfd_mach_o_twolevel_hints_command *hints =
|
bfd_mach_o_twolevel_hints_command *hints =
|
||||||
&cmd->command.twolevel_hints;
|
&cmd->command.twolevel_hints;
|
||||||
|
|
||||||
printf ("\n"
|
printf (" table offset: 0x%08x nbr hints: %u\n",
|
||||||
" table offset: 0x%08x nbr hints: %u\n",
|
|
||||||
hints->offset, hints->nhints);
|
hints->offset, hints->nhints);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
dump_twolevel_hints (abfd, hints);
|
dump_twolevel_hints (abfd, hints);
|
||||||
|
@ -1286,8 +1285,7 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
case BFD_MACH_O_LC_MAIN:
|
case BFD_MACH_O_LC_MAIN:
|
||||||
{
|
{
|
||||||
bfd_mach_o_main_command *entry = &cmd->command.main;
|
bfd_mach_o_main_command *entry = &cmd->command.main;
|
||||||
printf ("\n"
|
printf (" entry offset: ");
|
||||||
" entry offset: ");
|
|
||||||
printf_uint64 (entry->entryoff);
|
printf_uint64 (entry->entryoff);
|
||||||
printf ("\n"
|
printf ("\n"
|
||||||
" stack size: ");
|
" stack size: ");
|
||||||
|
@ -1296,9 +1294,6 @@ dump_load_command (bfd *abfd, bfd_mach_o_load_command *cmd,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
putchar ('\n');
|
|
||||||
printf (" offset: 0x%08lx\n", (unsigned long)cmd->offset);
|
|
||||||
printf (" size: 0x%08lx\n", (unsigned long)cmd->len);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
putchar ('\n');
|
putchar ('\n');
|
||||||
|
@ -1315,9 +1310,9 @@ dump_load_commands (bfd *abfd, unsigned int cmd32, unsigned int cmd64)
|
||||||
bfd_mach_o_load_command *cmd = &mdata->commands[i];
|
bfd_mach_o_load_command *cmd = &mdata->commands[i];
|
||||||
|
|
||||||
if (cmd32 == 0)
|
if (cmd32 == 0)
|
||||||
dump_load_command (abfd, cmd, FALSE);
|
dump_load_command (abfd, cmd, i, FALSE);
|
||||||
else if (cmd->type == cmd32 || cmd->type == cmd64)
|
else if (cmd->type == cmd32 || cmd->type == cmd64)
|
||||||
dump_load_command (abfd, cmd, TRUE);
|
dump_load_command (abfd, cmd, i, TRUE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue