static bfd_mach_o_xlat_name bfd_mach_o_cpu_name[] =
{
- { "vax", BFD_MACH_O_CPU_TYPE_VAX},
- { "mc680x0", BFD_MACH_O_CPU_TYPE_MC680x0},
- { "i386", BFD_MACH_O_CPU_TYPE_I386},
- { "mips", BFD_MACH_O_CPU_TYPE_MIPS},
- { "mc98000", BFD_MACH_O_CPU_TYPE_MC98000},
- { "hppa", BFD_MACH_O_CPU_TYPE_HPPA},
- { "arm", BFD_MACH_O_CPU_TYPE_ARM},
- { "mc88000", BFD_MACH_O_CPU_TYPE_MC88000},
- { "sparc", BFD_MACH_O_CPU_TYPE_SPARC},
- { "i860", BFD_MACH_O_CPU_TYPE_I860},
- { "alpha", BFD_MACH_O_CPU_TYPE_ALPHA},
- { "powerpc", BFD_MACH_O_CPU_TYPE_POWERPC},
- { "powerpc_64", BFD_MACH_O_CPU_TYPE_POWERPC_64},
- { "x86_64", BFD_MACH_O_CPU_TYPE_X86_64},
+ { "vax", BFD_MACH_O_CPU_TYPE_VAX },
+ { "mc680x0", BFD_MACH_O_CPU_TYPE_MC680x0 },
+ { "i386", BFD_MACH_O_CPU_TYPE_I386 },
+ { "mips", BFD_MACH_O_CPU_TYPE_MIPS },
+ { "mc98000", BFD_MACH_O_CPU_TYPE_MC98000 },
+ { "hppa", BFD_MACH_O_CPU_TYPE_HPPA },
+ { "arm", BFD_MACH_O_CPU_TYPE_ARM },
+ { "mc88000", BFD_MACH_O_CPU_TYPE_MC88000 },
+ { "sparc", BFD_MACH_O_CPU_TYPE_SPARC },
+ { "i860", BFD_MACH_O_CPU_TYPE_I860 },
+ { "alpha", BFD_MACH_O_CPU_TYPE_ALPHA },
+ { "powerpc", BFD_MACH_O_CPU_TYPE_POWERPC },
+ { "powerpc_64", BFD_MACH_O_CPU_TYPE_POWERPC_64 },
+ { "x86_64", BFD_MACH_O_CPU_TYPE_X86_64 },
{ NULL, 0}
};
static bfd_mach_o_xlat_name bfd_mach_o_filetype_name[] =
{
- { "object", BFD_MACH_O_MH_OBJECT},
- { "execute", BFD_MACH_O_MH_EXECUTE},
- { "fvmlib", BFD_MACH_O_MH_FVMLIB},
- { "core", BFD_MACH_O_MH_CORE},
- { "preload", BFD_MACH_O_MH_PRELOAD},
- { "dylib", BFD_MACH_O_MH_DYLIB},
- { "dylinker", BFD_MACH_O_MH_DYLINKER},
- { "bundle", BFD_MACH_O_MH_BUNDLE},
+ { "object", BFD_MACH_O_MH_OBJECT },
+ { "execute", BFD_MACH_O_MH_EXECUTE },
+ { "fvmlib", BFD_MACH_O_MH_FVMLIB },
+ { "core", BFD_MACH_O_MH_CORE },
+ { "preload", BFD_MACH_O_MH_PRELOAD },
+ { "dylib", BFD_MACH_O_MH_DYLIB },
+ { "dylinker", BFD_MACH_O_MH_DYLINKER },
+ { "bundle", BFD_MACH_O_MH_BUNDLE },
+ { "dylib_stub", BFD_MACH_O_MH_DYLIB_STUB },
+ { "dym", BFD_MACH_O_MH_DSYM },
+ { "kext_bundle", BFD_MACH_O_MH_KEXT_BUNDLE },
{ NULL, 0}
};
bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
bfd_mach_o_header *h = &mdata->header;
- fprintf (file, _("Mach-O header:\n"));
+ fputs (_("Mach-O header:\n"), file);
fprintf (file, _(" magic : %08lx\n"), h->magic);
fprintf (file, _(" cputype : %08lx (%s)\n"), h->cputype,
bfd_mach_o_get_name (bfd_mach_o_cpu_name, h->cputype));
fprintf (file, _(" sizeofcmds: %08lx\n"), h->sizeofcmds);
fprintf (file, _(" flags : %08lx ("), h->flags);
bfd_mach_o_print_flags (bfd_mach_o_header_flags_name, h->flags, file);
- fprintf (file, _(")\n"));
+ fputs (_(")\n"), file);
fprintf (file, _(" reserved : %08x\n"), h->reserved);
}
unsigned int i, j;
unsigned int sec_nbr = 0;
- fprintf (file, _("Segments and Sections:\n"));
- fprintf (file, _(" #: Segment name Section name Address\n"));
+ fputs (_("Segments and Sections:\n"), file);
+ fputs (_(" #: Segment name Section name Address\n"), file);
for (i = 0; i < mdata->header.ncmds; i++)
{
}
}
-/* Return the number of indirect symbols for a section.
+/* Return the size of an entry for section SEC.
Must be called only for symbol pointer section and symbol stubs
sections. */
static unsigned int
-bfd_mach_o_section_get_nbr_indirect (bfd *abfd, bfd_mach_o_section *sec)
+bfd_mach_o_section_get_entry_size (bfd *abfd, bfd_mach_o_section *sec)
{
- unsigned int elsz;
-
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:
- elsz = bfd_mach_o_wide_p (abfd) ? 8 : 4;
- return sec->size / elsz;
+ return bfd_mach_o_wide_p (abfd) ? 8 : 4;
case BFD_MACH_O_S_SYMBOL_STUBS:
- elsz = sec->reserved2;
- if (elsz)
- return sec->size / elsz;
- else
- return 0;
+ return sec->reserved2;
default:
BFD_FAIL ();
return 0;
}
}
+/* Return the number of indirect symbols for a section.
+ Must be called only for symbol pointer section and symbol stubs
+ sections. */
+
+static unsigned int
+bfd_mach_o_section_get_nbr_indirect (bfd *abfd, bfd_mach_o_section *sec)
+{
+ unsigned int elsz;
+
+ elsz = bfd_mach_o_section_get_entry_size (abfd, sec);
+ if (elsz == 0)
+ return 0;
+ else
+ return sec->size / elsz;
+}
+
static void
bfd_mach_o_print_section (bfd *abfd ATTRIBUTE_UNUSED,
bfd_mach_o_section *sec, FILE *file)
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_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, " %5u: 0x%08x (%u)", j, isym, isym);
+ 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)
&& symtab->symbols[isym].symbol.name)
fprintf (file, " %s", symtab->symbols[isym].symbol.name);
fprintf (file, "\n");
+ addr += entry_size;
}
break;
default: