From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway30.websitewelcome.com (gateway30.websitewelcome.com [192.185.152.11]) by sourceware.org (Postfix) with ESMTPS id BE430394C076 for ; Fri, 28 Aug 2020 16:23:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BE430394C076 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway30.websitewelcome.com (Postfix) with ESMTP id AA99AC64C for ; Fri, 28 Aug 2020 11:23:56 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id BhARkx0eFCjCVBhASkhT8Q; Fri, 28 Aug 2020 11:23:56 -0500 X-Authority-Reason: nr=8 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=is5A5FHfKr8d6pE7uZ8OS9YtgHHBh7M77sMrC1sXnuA=; b=OegcdYqE00dOiQOgJSH9ly8Fao N61OInKkn0Tp9U6yey6Ok175v6fVMrBG72WJXRaHN13Hz9DqDOgGjG3oaZ6u8A+mds4weJLOfqwrG QT07WJr/uhsLQxhkLCnSXR8RN; Received: from 71-218-12-75.hlrn.qwest.net ([71.218.12.75]:33904 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kBhAR-002WJo-KA; Fri, 28 Aug 2020 10:23:55 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 12/13] Use gdb_bfd_sections in build_section_table Date: Fri, 28 Aug 2020 10:23:48 -0600 Message-Id: <20200828162349.987-13-tom@tromey.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200828162349.987-1-tom@tromey.com> References: <20200828162349.987-1-tom@tromey.com> X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.218.12.75 X-Source-L: No X-Exim-ID: 1kBhAR-002WJo-KA X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-218-12-75.hlrn.qwest.net (bapiya.Home) [71.218.12.75]:33904 X-Source-Auth: tom+tromey.com X-Email-Count: 13 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3035.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Aug 2020 16:23:59 -0000 This changes build_section_table to avoid bfd_map_over_sections, in favor of iteration. In this situation it seemed simple to just remove the helper function entirely. gdb/ChangeLog 2020-08-28 Tom Tromey * exec.c (add_to_section_table): Remove. (build_section_table): Use foreach. --- gdb/ChangeLog | 5 +++++ gdb/exec.c | 50 ++++++++++++++++++++------------------------------ 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/gdb/exec.c b/gdb/exec.c index e50f38899d6..14cc6af7de0 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -587,35 +587,6 @@ file_command (const char *arg, int from_tty) } -/* Locate all mappable sections of a BFD file. - table_pp_char is a char * to get it through bfd_map_over_sections; - we cast it back to its proper type. */ - -static void -add_to_section_table (bfd *abfd, struct bfd_section *asect, - void *table_pp_char) -{ - struct target_section **table_pp = (struct target_section **) table_pp_char; - flagword aflag; - - gdb_assert (abfd == asect->owner); - - /* Check the section flags, but do not discard zero-length sections, since - some symbols may still be attached to this section. For instance, we - encountered on sparc-solaris 2.10 a shared library with an empty .bss - section to which a symbol named "_end" was attached. The address - of this symbol still needs to be relocated. */ - aflag = bfd_section_flags (asect); - if (!(aflag & SEC_ALLOC)) - return; - - (*table_pp)->owner = NULL; - (*table_pp)->the_bfd_section = asect; - (*table_pp)->addr = bfd_section_vma (asect); - (*table_pp)->endaddr = (*table_pp)->addr + bfd_section_size (asect); - (*table_pp)++; -} - /* See exec.h. */ void @@ -665,7 +636,26 @@ build_section_table (struct bfd *some_bfd, struct target_section **start, xfree (*start); *start = XNEWVEC (struct target_section, count); *end = *start; - bfd_map_over_sections (some_bfd, add_to_section_table, (char *) end); + for (asection *asect : gdb_bfd_sections (some_bfd)) + { + flagword aflag; + + /* Check the section flags, but do not discard zero-length + sections, since some symbols may still be attached to this + section. For instance, we encountered on sparc-solaris 2.10 + a shared library with an empty .bss section to which a symbol + named "_end" was attached. The address of this symbol still + needs to be relocated. */ + aflag = bfd_section_flags (asect); + if (!(aflag & SEC_ALLOC)) + continue; + + (*end)->owner = NULL; + (*end)->the_bfd_section = asect; + (*end)->addr = bfd_section_vma (asect); + (*end)->endaddr = (*end)->addr + bfd_section_size (asect); + (*end)++; + } gdb_assert (*end <= *start + count); -- 2.17.2