From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id fNrsFAiIy2fzdwgAWB0awg (envelope-from ) for ; Fri, 07 Mar 2025 18:58:00 -0500 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=gEXhViSc; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 3D03E1E105; Fri, 7 Mar 2025 18:58:00 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) 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.0 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 E38D61E05C for ; Fri, 7 Mar 2025 18:57:58 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 50ECA3858C98 for ; Fri, 7 Mar 2025 23:57:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 50ECA3858C98 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=gEXhViSc Received: from cp165172.hpdns.net (cp165172.hpdns.net [91.238.165.172]) by sourceware.org (Postfix) with ESMTPS id E47273858D1E for ; Fri, 7 Mar 2025 23:57:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E47273858D1E Authentication-Results: sourceware.org; dmarc=none (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 E47273858D1E 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=1741391848; cv=none; b=tvCUXdD4w/6jp9mbQSisNvX4vKy2ffA94oYxTuvZbXlWWq/cmuRNEccQU4OHfn/P7gSs+Ip4+ANmdmBCtvD1SFptbZNJnO9uVtibgc+l0FTtik9MI6UxleKeoqI3s6cynVSa7tERuOrwJPd54EDV+kjnJdLCS1SmIVUKo9Sw/v4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741391848; c=relaxed/simple; bh=hxNqdKHbxYDJvP7D/Gl8St00LDwQNEBao5Xl1WhDLWI=; h=DKIM-Signature:From:To:Subject:Message-Id:Date; b=dcKgGvw/q38ltqo0Tv4c8fd9Va/QhVTXH7nSemf0WN7dog5UpvmevDjdjz6xb3O1BZdwdi5piJNHfHyfEXPlKrfJITzob+sCPpWK4EMxTKTevwNuWJWbZwJ5iAE2LyQTXQtLmBAkAq8WUE59ReWGQsxxPym4LTmUiy9G1mFGRng= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E47273858D1E DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dyxyl.com; s=default; h=Date:Message-Id:Subject:To:From:Sender:Reply-To:Cc:MIME-Version: Content-Type:Content-Transfer-Encoding:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=u2T5OPqyTxu36pNmFQeDfoKBF4gYwd/p/+dIrlHgNmA=; b=gEXhViScK9Rg02g42JAtDyfwJJ InXKbUPwai6e2/q3AqQ5eVfMk03dtUQJKT7QYP4UAVz6WQqbD0rIhjVAsNQkWc1OEaxiEKEZn9ndS F+8OpZ+1MCcGnzbe8dZTtQEY5lbcJa27gS2upNadZOLmOWbzGf0RI+k6PYy/D9Y6uOt214DEW95tf SfrKIIv9X9bZ6r1SRTV/4WwfAgNRP3h06Drx11exg/6xEyW8Dk4KPxROWqHV9wkO0dDPLsqPqgyi1 U3DtL8YdrwjLP/36EexgvSuxl0BnTLWdC76xFrlEq8fx+cSASKKeapUZUvJwRR7CwQXgA00cF5qwm PqkD9zQA==; Received: from cmbg-19-b2-v4wan-170160-cust2145.vm17.cable.virginm.net ([94.175.88.98]:51524 helo=localhost.localdomain) by cp165172.hpdns.net with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.98.1) (envelope-from ) id 1tqhZF-0000000110B-2pLK for gdb-patches@sourceware.org; Fri, 07 Mar 2025 23:57:22 +0000 Received: by localhost.localdomain (Postfix, from userid 597) id 1D4CDEE05D; Fri, 7 Mar 2025 23:57:22 +0000 (GMT) From: Martin Simmons To: gdb-patches@sourceware.org Subject: [PATCH][PR symtab/32658] Fix parsing .debug_aranges section for MIPS signed addresses Message-Id: <20250307235722.1D4CDEE05D@localhost.localdomain> Date: Fri, 7 Mar 2025 23:57:22 +0000 (GMT) X-YourOrg-MailScanner-Information: Please contact the ISP for more information X-YourOrg-MailScanner-ID: 1tqhZF-0000000110B-2pLK 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 This patch fixes https://sourceware.org/bugzilla/show_bug.cgi?id=32658 by sign extending the addresses read from the .debug_aranges section as required for MIPS. I made it explicitly sign extend the addresses after they are read (instead of using extract_signed_integer) because I don't know if the address_size in the section will always be equal to the gdb arch_size. I've tested the patch with the MIPS example from PR 32658 and also with a few x86_64 binaries (where it has no effect, as expected). diff --git a/gdb/dwarf2/aranges.c b/gdb/dwarf2/aranges.c index 1be67852b43..a95e93aed27 100644 --- a/gdb/dwarf2/aranges.c +++ b/gdb/dwarf2/aranges.c @@ -59,6 +59,15 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, std::set debug_info_offset_seen; const bfd_endian dwarf5_byte_order = gdbarch_byte_order (gdbarch); + ULONGEST sign_extend_bit = 0; + if (bfd_get_sign_extend_vma (abfd)) + { + int arch_size = bfd_get_arch_size (abfd); + if (arch_size < 8 * sizeof(ULONGEST)) + { + sign_extend_bit = (ULONGEST) 1 << (arch_size - 1); + } + } const gdb_byte *addr = section->buffer; while (addr < section->buffer + section->size) { @@ -187,6 +196,13 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile, /* Symbol was eliminated due to a COMDAT group. */ continue; } + if (sign_extend_bit != 0) + { + /* Sign extend from the arch size. */ + start = (((start & ((sign_extend_bit << 1) - 1)) + ^ sign_extend_bit) + - sign_extend_bit); + } ULONGEST end = start + length; mutable_map->set_empty (start, end - 1, per_cu); }