From patchwork Thu Mar 7 20:57:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 31779 Received: (qmail 53725 invoked by alias); 7 Mar 2019 20:57:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 53453 invoked by uid 89); 7 Mar 2019 20:57:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=0s, 2.17.2, 2172 X-HELO: gateway30.websitewelcome.com Received: from gateway30.websitewelcome.com (HELO gateway30.websitewelcome.com) (192.185.150.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Mar 2019 20:57:14 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway30.websitewelcome.com (Postfix) with ESMTP id 782165A41 for ; Thu, 7 Mar 2019 14:57:12 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 204mhelhb4FKp204mhv4NV; Thu, 07 Mar 2019 14:57:12 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=DqVqD+KygdJGBQuYTvepmYTidPcVDdY9GMO4Aukp710=; b=lCpUgljMnb5yLPcl7CjWY37Q5I 6ef2RmOqjX0KdFPl/UKQfCkSpdL1Nn2H1dBiRLUG06GH/TjyQhh5wNKpLX20WLopVriG2g53tJdVB IbnvBacl0kL9XnQsXOVjr/clr; Received: from 75-166-85-218.hlrn.qwest.net ([75.166.85.218]:53182 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1h204m-002TOW-8v; Thu, 07 Mar 2019 14:57:12 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 4/9] Remove minsym termination Date: Thu, 7 Mar 2019 13:57:04 -0700 Message-Id: <20190307205709.21919-5-tom@tromey.com> In-Reply-To: <20190307205709.21919-1-tom@tromey.com> References: <20190307205709.21919-1-tom@tromey.com> I was curious what used the terminating "null" minimal symbol; and after looking I could not find anything. This patch removes terminate_minimal_symbol_table and the extra minimal symbol that is allocated for it. gdb/ChangeLog 2019-03-07 Tom Tromey * symfile.c (reread_symbols): Update. * objfiles.c (objfile::objfile): Update. * minsyms.h (terminate_minimal_symbol_table): Don't declare. * minsyms.c (lookup_minimal_symbol_by_pc_section): Update comment. (minimal_symbol_reader::install): Update. (terminate_minimal_symbol_table): Remove. * jit.c (jit_object_close_impl): Update. --- gdb/ChangeLog | 11 +++++++++++ gdb/jit.c | 2 -- gdb/minsyms.c | 40 +++------------------------------------- gdb/minsyms.h | 7 ------- gdb/objfiles.c | 2 -- gdb/symfile.c | 1 - 6 files changed, 14 insertions(+), 49 deletions(-) diff --git a/gdb/jit.c b/gdb/jit.c index 81c4af40f92..1f87bf2538d 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -805,8 +805,6 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb, OBJF_NOT_FILENAME); objfile->per_bfd->gdbarch = target_gdbarch (); - terminate_minimal_symbol_table (objfile); - j = NULL; for (i = obj->symtabs; i; i = j) { diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 3c91853e780..d937e5d2a99 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -728,11 +728,8 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio { CORE_ADDR pc = pc_in; - /* If this objfile has a minimal symbol table, go search it using - a binary search. Note that a minimal symbol table always consists - of at least two symbols, a "real" symbol and the terminating - "null symbol". If there are no real symbols, then there is no - minimal symbol table at all. */ + /* If this objfile has a minimal symbol table, go search it + using a binary search. */ if (objfile->per_bfd->minimal_symbol_count > 0) { @@ -1356,7 +1353,7 @@ minimal_symbol_reader::install () compact out the duplicate entries. Once we have a final table, we will give back the excess space. */ - alloc_count = m_msym_count + m_objfile->per_bfd->minimal_symbol_count + 1; + alloc_count = m_msym_count + m_objfile->per_bfd->minimal_symbol_count; obstack_blank (&m_objfile->per_bfd->storage_obstack, alloc_count * sizeof (struct minimal_symbol)); msymbols = (struct minimal_symbol *) @@ -1399,16 +1396,6 @@ minimal_symbol_reader::install () msymbols = (struct minimal_symbol *) obstack_finish (&m_objfile->per_bfd->storage_obstack); - /* We also terminate the minimal symbol table with a "null symbol", - which is *not* included in the size of the table. This makes it - easier to find the end of the table when we are handed a pointer - to some symbol in the middle of it. Zero out the fields in the - "null symbol" allocated at the end of the array. Note that the - symbol count does *not* include this null symbol, which is why it - is indexed by mcount and not mcount-1. */ - - memset (&msymbols[mcount], 0, sizeof (struct minimal_symbol)); - /* Attach the minimal symbol table to the specified objfile. The strings themselves are also located in the storage_obstack of this objfile. */ @@ -1424,27 +1411,6 @@ minimal_symbol_reader::install () } } -/* See minsyms.h. */ - -void -terminate_minimal_symbol_table (struct objfile *objfile) -{ - if (! objfile->per_bfd->msymbols) - objfile->per_bfd->msymbols = XOBNEW (&objfile->per_bfd->storage_obstack, - minimal_symbol); - - { - struct minimal_symbol *m - = &objfile->per_bfd->msymbols[objfile->per_bfd->minimal_symbol_count]; - - memset (m, 0, sizeof (*m)); - /* Don't rely on these enumeration values being 0's. */ - MSYMBOL_TYPE (m) = mst_unknown; - MSYMBOL_SET_LANGUAGE (m, language_unknown, - &objfile->per_bfd->storage_obstack); - } -} - /* Check if PC is in a shared library trampoline code stub. Return minimal symbol for the trampoline entry or NULL if PC is not in a trampoline code stub. */ diff --git a/gdb/minsyms.h b/gdb/minsyms.h index 532436c16c1..3e414f6ff7b 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -148,13 +148,6 @@ class minimal_symbol_reader int m_msym_count; }; -/* Create the terminating entry of OBJFILE's minimal symbol table. - If OBJFILE->msymbols is zero, allocate a single entry from - OBJFILE->objfile_obstack; otherwise, just initialize - OBJFILE->msymbols[OBJFILE->minimal_symbol_count]. */ - -void terminate_minimal_symbol_table (struct objfile *objfile); - /* Return whether MSYMBOL is a function/method. If FUNC_ADDRESS_P is diff --git a/gdb/objfiles.c b/gdb/objfiles.c index 4091b42dbf1..2468ca7a3f7 100644 --- a/gdb/objfiles.c +++ b/gdb/objfiles.c @@ -411,8 +411,6 @@ objfile::objfile (bfd *abfd, const char *name, objfile_flags flags_) per_bfd = get_objfile_bfd_data (this, abfd); - terminate_minimal_symbol_table (this); - /* Add this file onto the tail of the linked list of other such files. */ if (object_files == NULL) diff --git a/gdb/symfile.c b/gdb/symfile.c index 2214f16b431..68ec491d357 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -2580,7 +2580,6 @@ reread_symbols (void) objfile_set_sym_fns (objfile, find_sym_fns (objfile->obfd)); build_objfile_section_table (objfile); - terminate_minimal_symbol_table (objfile); /* We use the same section offsets as from last time. I'm not sure whether that is always correct for shared libraries. */