From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id OeyJOCgHYGnNITMAWB0awg (envelope-from ) for ; Thu, 08 Jan 2026 14:36:08 -0500 Received: by simark.ca (Postfix, from userid 112) id E3FD81E0C2; Thu, 08 Jan 2026 14:36:08 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 628A11E08D for ; Thu, 08 Jan 2026 14:36:07 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id EAB424BA2E1F for ; Thu, 8 Jan 2026 19:36:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EAB424BA2E1F Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 74B964BA2E1F for ; Thu, 8 Jan 2026 19:35:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 74B964BA2E1F Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 74B964BA2E1F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767900911; cv=none; b=lrqoe+/unQ84iH8lC+c5vU7c2w1m8T2xDExdGhVOv5E9mP1iX1g5fh0RDqbhdidwSt4h0eVK5Rc7qjDk2EjmsH4KsGAnI/xvWWJ9mvxi5b195c718aiT3t2bJOwacCJxDeLbfo3E1Qz7mCR4I3+hFn+nSayyn7ND4Eb6IPcFzPg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1767900911; c=relaxed/simple; bh=HEyBJT+UbzLaAdV3lVDWM8vqTH8OTm1jp/nb7Xc4zn8=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=o9KEiB8+s1ELUx+ixyhFUzhLf27Clj9rRROFjIGhM22xa3L94Z+hX3RkNlrHNwaTZFl7y++XBfkPVa2JvZMLK7vAFT0+40fBQy3OSJyKzY3nq4JGVTuESpantQRo3wt5Mb9GA8VSrKn78u5YAoXb1/OoAyk0vBhjRrGKrvtJtHY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 74B964BA2E1F Received: by simark.ca (Postfix) id 81DFC1E0C4; Thu, 08 Jan 2026 14:35:09 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 6/8] gdb/xcoffread: simplify xcoff_secnum_to_sections Date: Thu, 8 Jan 2026 14:33:24 -0500 Message-ID: <20260108193507.553779-7-simon.marchi@efficios.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108193507.553779-1-simon.marchi@efficios.com> References: <20260108193507.553779-1-simon.marchi@efficios.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org The only remaining caller of xcoff_secnum_to_sections doesn't care about the section index in the objfile, so remove that part. Return the BFD section as the return value of the function, instead of an output parameter. Remove the unnecessary default in the switch, to avoid a "jump to label over variable initialization" warning. Rename to xcoff_secnum_to_section (singular). Change-Id: I464d8b0e1425ea2732b0d61355c5b0c66218122e --- gdb/xcoffread.c | 41 ++++++++++------------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 7dd0f29cb107..5494bb0debbb 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -81,34 +81,18 @@ static void scan_xcoff_symtab (struct objfile *); static void xcoff_symfile_init (struct objfile *); /* Search all BFD sections for the section whose target_index is - equal to N_SCNUM. Set *BFD_SECT to that section. The section's - associated index in the objfile's section_offset table is also - stored in *SECNUM. + equal to N_SCNUM. - If no match is found, *BFD_SECT is set to NULL, and *SECNUM - is set to the text section's number. */ + If no match is found, return nullptr. */ -static void -xcoff_secnum_to_sections (int n_scnum, struct objfile *objfile, - asection **bfd_sect, int *secnum) +static asection * +xcoff_secnum_to_section (int n_scnum, objfile *objfile) { - *bfd_sect = NULL; - *secnum = SECT_OFF_TEXT (objfile); - for (asection *sec : gdb_bfd_sections (objfile->obfd.get ())) - { - if (sec->target_index == n_scnum) - { - /* This is the section. Figure out what SECT_OFF_* code it is. */ - if (bfd_section_flags (sec) & SEC_CODE) - *secnum = SECT_OFF_TEXT (objfile); - else if (bfd_section_flags (sec) & SEC_LOAD) - *secnum = SECT_OFF_DATA (objfile); - else - *secnum = gdb_bfd_section_index (objfile->obfd.get (), sec); - *bfd_sect = sec; - } - } + if (sec->target_index == n_scnum) + return sec; + + return nullptr; } /* Do initialization in preparation for reading symbols from OBJFILE. @@ -150,8 +134,6 @@ scan_xcoff_symtab (struct objfile *objfile) { CORE_ADDR toc_offset = 0; /* toc offset value in data section. */ - asection *bfd_sect = nullptr; - int ignored; bfd *abfd = objfile->obfd.get (); file_ptr symtab_offset = obj_sym_filepos (abfd); struct internal_syment symbol; @@ -218,14 +200,11 @@ scan_xcoff_symtab (struct objfile *objfile) /* Make TOC offset relative to start address of section. */ - xcoff_secnum_to_sections (symbol.n_scnum, objfile, - &bfd_sect, &ignored); + asection *bfd_sect + = xcoff_secnum_to_section (symbol.n_scnum, objfile); if (bfd_sect) toc_offset -= bfd_section_vma (bfd_sect); break; - - default: - break; } break; } -- 2.52.0