From owner-svn-src-projects@FreeBSD.ORG Mon Jan 3 22:25:34 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 87DF6106564A; Mon, 3 Jan 2011 22:25:34 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 769518FC12; Mon, 3 Jan 2011 22:25:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p03MPY2A007081; Mon, 3 Jan 2011 22:25:34 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p03MPYvx007079; Mon, 3 Jan 2011 22:25:34 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201101032225.p03MPYvx007079@svn.freebsd.org> From: Nathan Whitehorn Date: Mon, 3 Jan 2011 22:25:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216933 - projects/binutils-2.17/contrib/gdb/gdb X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Jan 2011 22:25:34 -0000 Author: nwhitehorn Date: Mon Jan 3 22:25:34 2011 New Revision: 216933 URL: http://svn.freebsd.org/changeset/base/216933 Log: Use the synthetic symtab interface in binutils 2.17 to handle absent dotsyms on powerpc64. This is a backport of GDB elfread.c r1.51 by Daniel Jacobowitz. Modified: projects/binutils-2.17/contrib/gdb/gdb/elfread.c Modified: projects/binutils-2.17/contrib/gdb/gdb/elfread.c ============================================================================== --- projects/binutils-2.17/contrib/gdb/gdb/elfread.c Mon Jan 3 21:28:12 2011 (r216932) +++ projects/binutils-2.17/contrib/gdb/gdb/elfread.c Mon Jan 3 22:25:34 2011 (r216933) @@ -124,13 +124,14 @@ record_minimal_symbol (char *name, CORE_ SYNOPSIS - void elf_symtab_read (struct objfile *objfile, int dynamic) + void elf_symtab_read (struct objfile *objfile, int dynamic, + long number_of_symbols, asymbol **symbol_table) DESCRIPTION - Given an objfile and a flag that specifies whether or not the objfile - is for an executable or not (may be shared library for example), add - all the global function and data symbols to the minimal symbol table. + Given an objfile, a symbol table, and a flag indicating whether the + symbol table contains dynamic symbols, add all the global function + and data symbols to the minimal symbol table. In stabs-in-ELF, as implemented by Sun, there are some local symbols defined in the ELF symbol table, which can be used to locate @@ -141,14 +142,12 @@ record_minimal_symbol (char *name, CORE_ */ static void -elf_symtab_read (struct objfile *objfile, int dynamic) +elf_symtab_read (struct objfile *objfile, int dynamic, + long number_of_symbols, asymbol **symbol_table) { long storage_needed; asymbol *sym; - asymbol **symbol_table; - long number_of_symbols; long i; - struct cleanup *back_to; CORE_ADDR symaddr; CORE_ADDR offset; enum minimal_symbol_type ms_type; @@ -165,34 +164,8 @@ elf_symtab_read (struct objfile *objfile struct dbx_symfile_info *dbx = objfile->sym_stab_info; int stripped = (bfd_get_symcount (objfile->obfd) == 0); - if (dynamic) + if (1) { - storage_needed = bfd_get_dynamic_symtab_upper_bound (objfile->obfd); - - /* Nothing to be done if there is no dynamic symtab. */ - if (storage_needed < 0) - return; - } - else - { - storage_needed = bfd_get_symtab_upper_bound (objfile->obfd); - if (storage_needed < 0) - error ("Can't read symbols from %s: %s", bfd_get_filename (objfile->obfd), - bfd_errmsg (bfd_get_error ())); - } - if (storage_needed > 0) - { - symbol_table = (asymbol **) xmalloc (storage_needed); - back_to = make_cleanup (xfree, symbol_table); - if (dynamic) - number_of_symbols = bfd_canonicalize_dynamic_symtab (objfile->obfd, - symbol_table); - else - number_of_symbols = bfd_canonicalize_symtab (objfile->obfd, symbol_table); - if (number_of_symbols < 0) - error ("Can't read symbols from %s: %s", bfd_get_filename (objfile->obfd), - bfd_errmsg (bfd_get_error ())); - for (i = 0; i < number_of_symbols; i++) { sym = symbol_table[i]; @@ -448,7 +421,6 @@ elf_symtab_read (struct objfile *objfile ELF_MAKE_MSYMBOL_SPECIAL (sym, msym); } } - do_cleanups (back_to); } } @@ -491,6 +463,9 @@ elf_symfile_read (struct objfile *objfil struct elfinfo ei; struct cleanup *back_to; CORE_ADDR offset; + long symcount = 0, dynsymcount = 0, synthcount, storage_needed; + asymbol **symbol_table = NULL, **dyn_symbol_table = NULL; + asymbol *synthsyms; init_minimal_symbol_collection (); back_to = make_cleanup_discard_minimal_symbols (); @@ -507,11 +482,65 @@ elf_symfile_read (struct objfile *objfil chain of info into the dbx_symfile_info in objfile->sym_stab_info, which can later be used by elfstab_offset_sections. */ - elf_symtab_read (objfile, 0); + storage_needed = bfd_get_symtab_upper_bound (objfile->obfd); + if (storage_needed < 0) + error (_("Can't read symbols from %s: %s"), bfd_get_filename (objfile->obfd), + bfd_errmsg (bfd_get_error ())); + + if (storage_needed > 0) + { + symbol_table = (asymbol **) xmalloc (storage_needed); + make_cleanup (xfree, symbol_table); + symcount = bfd_canonicalize_symtab (objfile->obfd, symbol_table); + + if (symcount < 0) + error (_("Can't read symbols from %s: %s"), bfd_get_filename (objfile->obfd), + bfd_errmsg (bfd_get_error ())); + + elf_symtab_read (objfile, 0, symcount, symbol_table); + } /* Add the dynamic symbols. */ - elf_symtab_read (objfile, 1); + storage_needed = bfd_get_dynamic_symtab_upper_bound (objfile->obfd); + + if (storage_needed > 0) + { + dyn_symbol_table = (asymbol **) xmalloc (storage_needed); + make_cleanup (xfree, dyn_symbol_table); + dynsymcount = bfd_canonicalize_dynamic_symtab (objfile->obfd, + dyn_symbol_table); + + if (dynsymcount < 0) + error (_("Can't read symbols from %s: %s"), bfd_get_filename (objfile->obfd), + bfd_errmsg (bfd_get_error ())); + + elf_symtab_read (objfile, 1, dynsymcount, dyn_symbol_table); + } + + /* Add synthetic symbols - for instance, names for any PLT entries. */ + + synthcount = bfd_get_synthetic_symtab (abfd, symcount, symbol_table, + dynsymcount, dyn_symbol_table, + &synthsyms); + if (synthcount > 0) + { + asymbol **synth_symbol_table; + long i; + + make_cleanup (xfree, synthsyms); + synth_symbol_table = xmalloc (sizeof (asymbol *) * synthcount); + for (i = 0; i < synthcount; i++) + { + synth_symbol_table[i] = synthsyms + i; + /* Synthetic symbols are not, strictly speaking, either local + or global. But we can treat them as global symbols, since + they are effectively dynamic symbols. */ + synth_symbol_table[i]->flags |= BSF_GLOBAL; + } + make_cleanup (xfree, synth_symbol_table); + elf_symtab_read (objfile, 0, synthcount, synth_symbol_table); + } /* Install any minimal symbols that have been collected as the current minimal symbols for this objfile. The debug readers below this point