From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id TJ/2BKd65WcTmBwAWB0awg (envelope-from ) for ; Thu, 27 Mar 2025 12:19:51 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=dyxyl.com header.i=@dyxyl.com header.a=rsa-sha256 header.s=default header.b=Hsr73fns; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 0257C1E0C3; Thu, 27 Mar 2025 12:19:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-4.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,HK_RANDOM_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (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 AFD361E0C0 for ; Thu, 27 Mar 2025 12:19:49 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3E3B1385802C for ; Thu, 27 Mar 2025 16:19:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3E3B1385802C Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (2048-bit key, unprotected) header.d=dyxyl.com header.i=@dyxyl.com header.a=rsa-sha256 header.s=default header.b=Hsr73fns Received: from cp165172.hpdns.net (cp165172.hpdns.net [91.238.165.172]) by sourceware.org (Postfix) with ESMTPS id B420E382E284 for ; Thu, 27 Mar 2025 16:03:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B420E382E284 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=dyxyl.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dyxyl.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B420E382E284 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=91.238.165.172 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743091431; cv=none; b=bX+tvnM5YuGqfRyMACF7Tb4EKT52AGnRz2sBnpyn3dQYXFaG0iuKrKqdYUsmtBhVpewMdX1GPYbXkieUN1lcRRLTmnyLt0fsRP7iOA9QjvZ+PzCbouRHMogZVQQcZ3ustKYclZVZndMYBK0OiZntGRQIMIaWObFiYooCHPbnQGY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1743091431; c=relaxed/simple; bh=PldK5yr9rgkymXKVaCCHiBBCOg2xZsTcoSR0nIIWGm0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=HZKQIo4/zSzneIAG/f56EmupNTsLhtnYmNVZjIhLInyJZKA6kilnGGH4TchTf6ULut4ES/XIJzRsPIDlej/NKTp2dviL0FxTGFHjqy9oyWRNaxlDyAXlT9+SakZH8GDx/YDJ2pknnFhaNfrNiRKMTUrxYPNgoG27079QQSdrdtM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B420E382E284 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dyxyl.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:To:From:Sender:Reply-To:Cc: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=0wmcRC2zLREJFtjQpNoChN+3uCL3iyTgfR+IE+PbG9E=; b=Hsr73fnse6GYWLxiCwsqKas7/w pSf1d5WWcJs4YOcyAxcCuaDDyadsdWARo95DemFe5Y50iRP2VZeFJoeAZcWsPbP0i8DVBu6nUtyvu oggAg8KagCD43w28s6ajdrslvXKwqQUkArgTfd0wyh893uMUfpQE/+hyF0644AkB03WfdB4fn9N8C Ffd3dxk3klbCqhfNpr/jv6pKHW9xRvMzL/XvWamTYyREPhZ1Jm+k83/+XCIWgHUewjEFy4UMMsYvt /r6c1/7Qmx1ASRl0hiiXYALy85E6DcYT8fOCDorkt5ytaxPQV3ZxzsKie39W4COz2vrJe9BMv+K9s wu96Lfug==; Received: from cmbg-19-b2-v4wan-170160-cust2145.vm17.cable.virginm.net ([94.175.88.98]:36024 helo=localhost.localdomain) by cp165172.hpdns.net with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1txphq-00000008kCe-02UF for gdb-patches@sourceware.org; Thu, 27 Mar 2025 16:03:46 +0000 Received: by localhost.localdomain (Postfix, from userid 597) id 3A323E0A48; Thu, 27 Mar 2025 16:03:45 +0000 (GMT) From: Martin Simmons To: gdb-patches@sourceware.org Subject: [PATCH v2][PR symtab/32658] Fix parsing .debug_aranges section for MIPS signed addresses In-Reply-To: <87tt7pj7au.fsf@tromey.com> (message from Tom Tromey on Wed, 19 Mar 2025 10:48:09 -0600) References: <20250307235722.1D4CDEE05D@localhost.localdomain> <87tt7pj7au.fsf@tromey.com> Date: Thu, 27 Mar 2025 16:03:45 +0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-YourOrg-MailScanner-Information: Please contact the ISP for more information X-YourOrg-MailScanner-ID: 1txphq-00000008kCe-02UF X-YourOrg-MailScanner: Found to be clean X-YourOrg-MailScanner-SpamCheck: X-YourOrg-MailScanner-From: qqxnjvamvxwx@dyxyl.com X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cp165172.hpdns.net X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - dyxyl.com X-Get-Message-Sender-Via: cp165172.hpdns.net: authenticated_id: dyxyl/from_h X-Authenticated-Sender: cp165172.hpdns.net: qqxnjvamvxwx@dyxyl.com X-Source: X-Source-Args: X-Source-Dir: 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 >>>>> On Wed, 19 Mar 2025 10:48:09 -0600, Tom Tromey said: > >>>>> "Martin" == Martin Simmons writes: > > Martin> This patch fixes https://sourceware.org/bugzilla/show_bug.cgi?id=32658 by sign > > There should be a 'Bug: ...' trailer in the comment with this link. > > FWIW I see now that other spots in the DWARF reader do use the BFD > approach: > > int signed_addr_p = bfd_get_sign_extend_vma (objfile->obfd.get ()); > > Martin> I made it explicitly sign extend the addresses after they are read > Martin> (instead of using extract_signed_integer) because I don't know if the > Martin> address_size in the section will always be equal to the gdb arch_size. > > I don't think this should be a concern, unless you have an example where > it actually happens. > > The .debug_aranges header spec explicitly says "size of an address in > bytes on the target architecture". I've not found an example (and both gcc and clang explicitly write them using the target's pointer size). Here is v2 of the patch addressing the above. Fix parsing .debug_aranges section for signed addresses. Some architectures, such as MIPS, have signed addresses and this changes read_addrmap_from_aranges to record them as signed when required. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32658 diff --git a/gdb/dwarf2/aranges.c b/gdb/dwarf2/aranges.c index 7016eee557c..ac530abd6b3 100644 --- a/gdb/dwarf2/aranges.c +++ b/gdb/dwarf2/aranges.c @@ -59,6 +59,7 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, gdb::unordered_set debug_info_offset_seen; const bfd_endian dwarf5_byte_order = gdbarch_byte_order (gdbarch); + const int signed_addr_p = bfd_get_sign_extend_vma (abfd); const gdb_byte *addr = section->buffer; while (addr < section->buffer + section->size) { @@ -167,8 +168,13 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, plongest (entry_addr - section->buffer)); return false; } - ULONGEST start = extract_unsigned_integer (addr, address_size, - dwarf5_byte_order); + ULONGEST start; + if (signed_addr_p) + start = extract_signed_integer (addr, address_size, + dwarf5_byte_order); + else + start = extract_unsigned_integer (addr, address_size, + dwarf5_byte_order); addr += address_size; ULONGEST length = extract_unsigned_integer (addr, address_size, dwarf5_byte_order);