From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id kZh7Mxc9g2p8RC0AWB0awg (envelope-from ) for ; Mon, 17 Aug 2026 12:55:51 -0400 Received: by simark.ca (Postfix, from userid 112) id D05981E033; Mon, 17 Aug 2026 12:55: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=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 841D31E033 for ; Mon, 17 Aug 2026 12:55:51 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1FB284B99F5A for ; Mon, 17 Aug 2026 16:55:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1FB284B99F5A Received: from angie.orcam.me.uk (angie.orcam.me.uk [IPv6:2001:4190:8020::34]) by sourceware.org (Postfix) with ESMTP id 274184BAE7F4 for ; Mon, 17 Aug 2026 16:54:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 274184BAE7F4 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=orcam.me.uk Authentication-Results: sourceware.org; spf=none smtp.mailfrom=orcam.me.uk ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 274184BAE7F4 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2001:4190:8020::34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786985649; cv=none; b=e7yacwW9vb63eppkO9X6v09VOeKk2RaVsP2U3UfeNgRgurscp8wRQtjfGmzdS2ngIgGRMk31z5/Xti7WJtaMqotROR+GA6P7dLvKzgcQ6T46s8CEovGpjJGUvZulVVtKpjDdap/onWDMqK8vqf7gUtvI/ckakH2dplt23Wh8NzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786985649; c=relaxed/simple; bh=7O7g9LJanjsoZ9wJyTM3Dmh5y7GSVheTGS/CSAelW8A=; h=Date:From:To:Subject:Message-ID:MIME-Version; b=xaiO62oi8vbpwaGMBA+MTdKY8ufknAqK4WDADxOWv7CRN5Sukh9kAfQRh+ker48BOVOR2O3EhOJmpWk9KLibr9J6IckCIL3zG03yuKnW1flqloVZfed+BjQNXOH+elQ8hSvaun7gNltK+Hik0ySTmToVzWxS5dqBJkn5tAs9N8k= ARC-Authentication-Results: i=1; sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 274184BAE7F4 Received: by angie.orcam.me.uk (Postfix, from userid 500) id A8BF29200B4; Mon, 17 Aug 2026 18:54:08 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id A2F8292009B; Mon, 17 Aug 2026 17:54:08 +0100 (BST) Date: Mon, 17 Aug 2026 17:54:08 +0100 (BST) From: "Maciej W. Rozycki" To: gdb-patches@sourceware.org cc: Jovan Dmitrovic , Djordje Todorovic , Milica Matic , "Maciej W. Rozycki" Subject: [PATCH v2 10/12] MIPS: Correct segment calculation for MIPS16 JAL/X In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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: , Reply-To: "Maciej W. Rozycki" Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org From: Maciej W. Rozycki Fix an off-by-two segment calculation bug in determining the target PC for MIPS16 JAL and JALX instructions in `extended_mips16_next_pc'. The segment to use is determined by the address right after the instruction. However unlike with extended instructions while JAL and JALX are being decoded by said function `pc' points at the start of the instruction rather than beyond the EXTEND prefix. Therefore the correct adjustment for `pc' is 4 rather than 2. This bug was originally present in `add_offset_16' and not eliminated with the rewrite in commit 484933d11fca ("MIPS: Rewrite `add_offset_16' to match its name"). No testcase added as that would require 256MiB+ of target memory and a correspondingly large executable to be built, which seems not worth it for such a corner-case bug. Approved-By: Maciej W. Rozycki --- New change in v2. --- gdb/mips-tdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) gdb-mips16-next-pc-jal.diff Index: binutils-gdb/gdb/mips-tdep.c =================================================================== --- binutils-gdb.orig/gdb/mips-tdep.c +++ binutils-gdb/gdb/mips-tdep.c @@ -2297,7 +2297,7 @@ extended_mips16_next_pc (regcache *regca { struct upk_mips16 upk; unpack_mips16 (gdbarch, pc, extension, insn, jalxtype, &upk); - pc = ((pc + 2) & (~(CORE_ADDR) 0x0fffffff)) | (upk.offset << 2); + pc = ((pc + 4) & (~(CORE_ADDR) 0x0fffffff)) | (upk.offset << 2); if ((insn >> 10) & 0x01) /* Exchange mode */ pc = pc & ~0x01; /* Clear low bit, indicate 32 bit mode. */ else