2009-09-16 Tristan Gingold <gingold@adacore.com>

* mach-o.h (bfd_mach_o_filetype): Add new constants from darwin10.
	Reindent.
	* mach-o.c (bfd_mach_o_cpu_name): Reindent.
	(bfd_mach_o_filetype_name): Complete with new constants.  Reindent.
	(bfd_mach_o_print_private_header): Use fputs instead of fprintf
	when possible to avoid warnings.
	(bfd_mach_o_print_section_map): Ditto.
	(bfd_mach_o_section_get_entry_size): New function.
	(bfd_mach_o_section_get_nbr_indirect): Simplify using the newly
	added function.
	(bfd_mach_o_print_dysymtab): Print address of indirect symbols.
This commit is contained in:
Tristan Gingold
2009-09-16 13:30:32 +00:00
parent 5cca3659ec
commit afecc97cf6
3 changed files with 87 additions and 51 deletions

View File

@ -1,3 +1,17 @@
2009-09-16 Tristan Gingold <gingold@adacore.com>
* mach-o.h (bfd_mach_o_filetype): Add new constants from darwin10.
Reindent.
* mach-o.c (bfd_mach_o_cpu_name): Reindent.
(bfd_mach_o_filetype_name): Complete with new constants. Reindent.
(bfd_mach_o_print_private_header): Use fputs instead of fprintf
when possible to avoid warnings.
(bfd_mach_o_print_section_map): Ditto.
(bfd_mach_o_section_get_entry_size): New function.
(bfd_mach_o_section_get_nbr_indirect): Simplify using the newly
added function.
(bfd_mach_o_print_dysymtab): Print address of indirect symbols.
2009-09-14 Nick Clifton <nickc@redhat.com>
* po/fi.po: Updated Finnish translation.

View File

@ -3108,6 +3108,9 @@ static bfd_mach_o_xlat_name bfd_mach_o_filetype_name[] =
{ "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}
};
@ -3220,7 +3223,7 @@ bfd_mach_o_print_private_header (bfd *abfd, FILE *file)
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));
@ -3232,7 +3235,7 @@ bfd_mach_o_print_private_header (bfd *abfd, FILE *file)
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);
}
@ -3243,8 +3246,8 @@ bfd_mach_o_print_section_map (bfd *abfd, FILE *file)
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++)
{
@ -3278,6 +3281,26 @@ bfd_mach_o_print_section_map (bfd *abfd, FILE *file)
}
}
/* 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_entry_size (bfd *abfd, bfd_mach_o_section *sec)
{
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:
return bfd_mach_o_wide_p (abfd) ? 8 : 4;
case BFD_MACH_O_S_SYMBOL_STUBS:
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. */
@ -3287,22 +3310,11 @@ bfd_mach_o_section_get_nbr_indirect (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;
case BFD_MACH_O_S_SYMBOL_STUBS:
elsz = sec->reserved2;
if (elsz)
return sec->size / elsz;
elsz = bfd_mach_o_section_get_entry_size (abfd, sec);
if (elsz == 0)
return 0;
else
return 0;
default:
BFD_FAIL ();
return 0;
}
return sec->size / elsz;
}
static void
@ -3515,6 +3527,8 @@ bfd_mach_o_print_dysymtab (bfd *abfd ATTRIBUTE_UNUSED,
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)
{
@ -3523,13 +3537,17 @@ bfd_mach_o_print_dysymtab (bfd *abfd ATTRIBUTE_UNUSED,
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)
@ -3539,6 +3557,7 @@ bfd_mach_o_print_dysymtab (bfd *abfd ATTRIBUTE_UNUSED,
&& symtab->symbols[isym].symbol.name)
fprintf (file, " %s", symtab->symbols[isym].symbol.name);
fprintf (file, "\n");
addr += entry_size;
}
break;
default:

View File

@ -166,14 +166,17 @@ bfd_mach_o_cpu_subtype;
typedef enum bfd_mach_o_filetype
{
BFD_MACH_O_MH_OBJECT = 1,
BFD_MACH_O_MH_EXECUTE = 2,
BFD_MACH_O_MH_FVMLIB = 3,
BFD_MACH_O_MH_CORE = 4,
BFD_MACH_O_MH_PRELOAD = 5,
BFD_MACH_O_MH_DYLIB = 6,
BFD_MACH_O_MH_DYLINKER = 7,
BFD_MACH_O_MH_BUNDLE = 8
BFD_MACH_O_MH_OBJECT = 0x01,
BFD_MACH_O_MH_EXECUTE = 0x02,
BFD_MACH_O_MH_FVMLIB = 0x03,
BFD_MACH_O_MH_CORE = 0x04,
BFD_MACH_O_MH_PRELOAD = 0x05,
BFD_MACH_O_MH_DYLIB = 0x06,
BFD_MACH_O_MH_DYLINKER = 0x07,
BFD_MACH_O_MH_BUNDLE = 0x08,
BFD_MACH_O_MH_DYLIB_STUB = 0x09,
BFD_MACH_O_MH_DSYM = 0x0a,
BFD_MACH_O_MH_KEXT_BUNDLE = 0x0b
}
bfd_mach_o_filetype;