From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18293 invoked by alias); 17 Oct 2013 17:50:20 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 18250 invoked by uid 89); 17 Oct 2013 17:50:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.6 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 17 Oct 2013 17:50:19 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9HHoI1j015554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Oct 2013 13:50:18 -0400 Received: from barimba.redhat.com (ovpn-113-54.phx2.redhat.com [10.3.113.54]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9HHnvEu021105; Thu, 17 Oct 2013 13:50:13 -0400 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH v2 8/9] split out elf_read_minimal_symbols Date: Thu, 17 Oct 2013 17:50:00 -0000 Message-Id: <1382032193-9115-9-git-send-email-tromey@redhat.com> In-Reply-To: <1382032193-9115-1-git-send-email-tromey@redhat.com> References: <1382032193-9115-1-git-send-email-tromey@redhat.com> X-SW-Source: 2013-10/txt/msg00528.txt.bz2 This is just a simple refactoring in elfread.c to split out the minsym-reading code into its own function. * elfread.c (elf_read_minimal_symbols): New function, from elf_symfile_read. (elf_symfile_read): Call it. --- gdb/elfread.c | 73 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/gdb/elfread.c b/gdb/elfread.c index 1150a0f..5bf4598 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1072,39 +1072,13 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b) update_breakpoint_locations (b, sals, sals_end); } -/* Scan and build partial symbols for a symbol file. - We have been initialized by a call to elf_symfile_init, which - currently does nothing. - - SECTION_OFFSETS is a set of offsets to apply to relocate the symbols - in each section. We simplify it down to a single offset for all - symbols. FIXME. - - This function only does the minimum work necessary for letting the - user "name" things symbolically; it does not read the entire symtab. - Instead, it reads the external and static symbols and puts them in partial - symbol tables. When more extensive information is requested of a - file, the corresponding partial symbol table is mutated into a full - fledged symbol table by going back and reading the symbols - for real. - - We look for sections with specific names, to tell us what debug - format to look for: FIXME!!! - - elfstab_build_psymtabs() handles STABS symbols; - mdebug_build_psymtabs() handles ECOFF debugging information. - - Note that ELF files have a "minimal" symbol table, which looks a lot - like a COFF symbol table, but has only the minimal information necessary - for linking. We process this also, and use the information to - build gdb's minimal symbol table. This gives us some minimal debugging - capability even for files compiled without -g. */ +/* A helper function for elf_symfile_read that reads the minimal + symbols. */ static void -elf_symfile_read (struct objfile *objfile, int symfile_flags) +elf_read_minimal_symbols (struct objfile *objfile, int symfile_flags) { bfd *synth_abfd, *abfd = objfile->obfd; - struct elfinfo ei; struct cleanup *back_to; long symcount = 0, dynsymcount = 0, synthcount, storage_needed; asymbol **symbol_table = NULL, **dyn_symbol_table = NULL; @@ -1121,8 +1095,6 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags) init_minimal_symbol_collection (); back_to = make_cleanup_discard_minimal_symbols (); - memset ((char *) &ei, 0, sizeof (ei)); - /* Allocate struct to keep track of the symfile. */ dbx = XCNEW (struct dbx_symfile_info); set_objfile_data (objfile, dbx_objfile_data_key, dbx); @@ -1226,6 +1198,45 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags) if (symtab_create_debug) fprintf_unfiltered (gdb_stdlog, "Done reading minimal symbols.\n"); +} + +/* Scan and build partial symbols for a symbol file. + We have been initialized by a call to elf_symfile_init, which + currently does nothing. + + SECTION_OFFSETS is a set of offsets to apply to relocate the symbols + in each section. We simplify it down to a single offset for all + symbols. FIXME. + + This function only does the minimum work necessary for letting the + user "name" things symbolically; it does not read the entire symtab. + Instead, it reads the external and static symbols and puts them in partial + symbol tables. When more extensive information is requested of a + file, the corresponding partial symbol table is mutated into a full + fledged symbol table by going back and reading the symbols + for real. + + We look for sections with specific names, to tell us what debug + format to look for: FIXME!!! + + elfstab_build_psymtabs() handles STABS symbols; + mdebug_build_psymtabs() handles ECOFF debugging information. + + Note that ELF files have a "minimal" symbol table, which looks a lot + like a COFF symbol table, but has only the minimal information necessary + for linking. We process this also, and use the information to + build gdb's minimal symbol table. This gives us some minimal debugging + capability even for files compiled without -g. */ + +static void +elf_symfile_read (struct objfile *objfile, int symfile_flags) +{ + bfd *abfd = objfile->obfd; + struct elfinfo ei; + + elf_read_minimal_symbols (objfile, symfile_flags); + + memset ((char *) &ei, 0, sizeof (ei)); /* Now process debugging information, which is contained in special ELF sections. */ -- 1.8.1.4