From: Tristan Gingold Date: Wed, 16 Sep 2009 13:30:32 +0000 (+0000) Subject: 2009-09-16 Tristan Gingold X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=afecc97cf6abc6df07f613b0247afe71d48f7092;p=binutils-gdb.git 2009-09-16 Tristan Gingold * 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 4072d59c969..6d91f05b082 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,17 @@ +2009-09-16 Tristan Gingold + + * 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 * po/fi.po: Updated Finnish translation. diff --git a/bfd/mach-o.c b/bfd/mach-o.c index 5cf531ea069..747a637aa9c 100644 --- a/bfd/mach-o.c +++ b/bfd/mach-o.c @@ -3081,33 +3081,36 @@ bfd_mach_o_get_name (const bfd_mach_o_xlat_name *table, unsigned long val) 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} }; @@ -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,33 +3281,42 @@ bfd_mach_o_print_section_map (bfd *abfd, FILE *file) } } -/* 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) @@ -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: diff --git a/bfd/mach-o.h b/bfd/mach-o.h index c1831e4bc14..b86fe075c55 100644 --- a/bfd/mach-o.h +++ b/bfd/mach-o.h @@ -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;