From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id HDSQMS4trGer4ysAWB0awg (envelope-from ) for ; Wed, 12 Feb 2025 00:10:06 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=3HSuJHGI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B65261E105; Wed, 12 Feb 2025 00:10:06 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,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 3D0391E05C for ; Wed, 12 Feb 2025 00:10:05 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BADA33858C2B for ; Wed, 12 Feb 2025 05:10:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BADA33858C2B Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=3HSuJHGI Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id 3A3683858C35 for ; Wed, 12 Feb 2025 05:08:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3A3683858C35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 3A3683858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739336927; cv=none; b=l77qalIyytJznd6wz7koyEhi5KMAq3kWRfQzamBqzGaQ+qlVAIeSFez6Eu7/Bowz3w9TYGZfSt7Xd1Rqi24VHCfIUm0npiuxwKBFCrDVX77pWmprk9qhlQG9kAtu4B3qzHnGRaeDsSzqayIeXKELxZ5m4rxLgUuR3ov9DgZtqGI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739336927; c=relaxed/simple; bh=T7v6LPDVnK4rlDN8FrNMFeFPZe+oz8JMB/CVZCRLqJQ=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=Ki5eYMv+OH1srbDoaEliAZXYNj56hQKiGO1jg49UPNlXycniVyZd+yKVvfCOg82C7RA5FernUnu01XhvoqwftzpwWQ3UWWTLaqMESw8A6DznjjEhoF2nWqv9Qy7wRKb56xJ1KOSDPtcUVk94w0OQkSJZeNkSTYJpDzCuaQbifaY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A3683858C35 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-21f4a4fbb35so6896765ad.0 for ; Tue, 11 Feb 2025 21:08:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1739336926; x=1739941726; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=KQsaqgrjhZJU/SKTWOjDr4wga/IOO0jCs5pBK+mrlLo=; b=3HSuJHGI1AodwfeUtoPa3ZgjHGMgho7okAWsKlFA/leCPCwqRnz6rY45NLy2M+9wlu 3ENu2leEsnjvM8IC+ALu9QZR+bv3iOJJ0akYomGnYbAecvLWNcZRvLe3QjJCezdqjW11 xmh0KAuKt7obtFWEdLzvpkNlvX3B1rOlGRJdnuK2UY8XoSTOma6WyDHxPS9al/WsC0is f1tGmMscbOLQ7kab1u/5fv7xGJ+XgINTjAH7q7zcoexXZF/lDbhLO2W1p7Qbe4gsW7Yj aZozTViA2KJ3JJ8Lv0i6J0j1lhHcx9yoZftILe4D9ELAauX+d3AjjxQkjL9Xkhwe8dEY VnjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739336926; x=1739941726; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KQsaqgrjhZJU/SKTWOjDr4wga/IOO0jCs5pBK+mrlLo=; b=UZdzPpUOPPCjwY2aB7TCbwwnQURvTnkFr4lJ6NzcNAerd0Q3gNPG3+28/jh+wpgEg5 TmKkP3uhxT9Olaj51ktYkMAXMGUivZKBD6E6eOIuZ0RboDXz5wNCXQ2emwy2hzWQ1rEw fHEhi5jiPrVMBZE9VqZ59o9rKv0cK4BVAD3SJgl2Oil2bTqBKiIsBcYus+K6+nrVCiag pDJVVMfeMDMalo4NteR5lSpVnAcdq3XsjI1FjMu4WjPP6gt+tLCIMMs7skJXov6AJLNi wR5rWt4R/+/QIP/WekoGkw1XVRDbYO+0vwffZf3KjipJq5yQQvv8Wdj3hOoUKQhGO1xw 2dCg== X-Gm-Message-State: AOJu0Yw43RnitBeqQQQ9K7u83mqrRmdqsHtSJUYXIQSz1JtOPz+aQhgk uXmtuXeKDgTnd4oBNsUT5iH48H0z9QIbz4R9W8GKXaOQ05hvvrnCrSQkXZxKkas= X-Gm-Gg: ASbGncv6d95fVaRitPsfJrd2iuU++uaPd8PknYtwohjJpUH9wwaTHFqV4DQNpWXgYMD UoFea44wAJGPbXDqnhAltP57RwVNE0IFkvzNNnfCKpQlfs/BrakmrbXTjSgwDIfMeckcKH+QeTO yJfBvpR1r/DsaT1OQJzCjMtKx84GF3+PaLgKLsRrpY1yRDDQ2z2pnu+Jmxim6Pb+XABXXxFM/nY 0QYQ/u1ramY47p3JE9yo7GHDzMnfcoTisR2ZxfK/sgGYC0U8swRh8Zboaebpe2ZbNJadwepJqzh 2ODjS5SvxcDt7LbEN/hciwqQ68pjBvU= X-Google-Smtp-Source: AGHT+IE6Lt2s+s+GyP9PW91Hgqo4dec7/wJdzNlUGdiKmbVPyJf6RVi/ys98IR+KThzx4gMH3uaNlg== X-Received: by 2002:a17:903:41c5:b0:21f:40de:ae4e with SMTP id d9443c01a7336-220bc1e4a6fmr28833445ad.9.1739336926210; Tue, 11 Feb 2025 21:08:46 -0800 (PST) Received: from charlie.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21f8dc5de2csm49232295ad.161.2025.02.11.21.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2025 21:08:45 -0800 (PST) From: Charlie Jenkins Date: Tue, 11 Feb 2025 21:08:30 -0800 Subject: [PATCH 1/2] RISC-V: Fix abort when displaying .dword MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250211-fix_gas_abort-v1-1-afd9730f9c51@rivosinc.com> References: <20250211-fix_gas_abort-v1-0-afd9730f9c51@rivosinc.com> In-Reply-To: <20250211-fix_gas_abort-v1-0-afd9730f9c51@rivosinc.com> To: jiawei , Nelson Chu , Charlie Jenkins , Jan Beulich , Andrew Burgess Cc: gdb-patches , Binutils X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2570; i=charlie@rivosinc.com; h=from:subject:message-id; bh=T7v6LPDVnK4rlDN8FrNMFeFPZe+oz8JMB/CVZCRLqJQ=; b=owGbwMvMwCXWx5hUnlvL8Y3xtFoSQ/oanVvueYq9jtFvd7oZsRaZHmXzZJd1KwpjaPij+thwl 6zlsYsdpSwMYlwMsmKKLDzXGphb7+iXHRUtmwAzh5UJZAgDF6cATKT4HMMffi3xzdnWOzZOVs23 SKtcLbr++6a1Lzmi78yMz8t/Yb+xm5GhzbzY7PnX35MCjhy0frw7cPGRI2sPfj21gsVg04xbskZ MzAA= X-Developer-Key: i=charlie@rivosinc.com; a=openpgp; fpr=7D834FF11B1D8387E61C776FFB10D1F27D6B1354 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 In the normal case an instruction won't be split into 5, 6, or 7 byte sections. However a .dword disassembled with -D can cause an instruction to split across the 6 byte boundary. 6 byte instructions were not supported so riscv_disassemble_data() would abort. Forcing instructions to be at most 4 bytes causes other unintented side-effects, so instead add entries to the switch statement to handle instructions that are 5, 6, or 7 bytes. Signed-off-by: Charlie Jenkins Fixes: 6a04e8230707 ("RISC-V: Fix display of partial instructions") --- opcodes/riscv-dis.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c index 367004d3341e46a5f72253cd70c7c2941912e84d..21bcbd32c7f226d13f1637ad192d8fe3c52e0d7a 100644 --- a/opcodes/riscv-dis.c +++ b/opcodes/riscv-dis.c @@ -1325,6 +1325,33 @@ riscv_disassemble_data (bfd_vma memaddr ATTRIBUTE_UNUSED, (info->stream, dis_style_immediate, "0x%08lx", (unsigned long) data); break; + case 5: + info->bytes_per_line = 8; + (*info->fprintf_styled_func) + (info->stream, dis_style_assembler_directive, ".dword"); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t"); + (*info->fprintf_styled_func) + (info->stream, dis_style_immediate, "0x%010lx", + (unsigned long) data); + break; + case 6: + info->bytes_per_line = 8; + (*info->fprintf_styled_func) + (info->stream, dis_style_assembler_directive, ".dword"); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t"); + (*info->fprintf_styled_func) + (info->stream, dis_style_immediate, "0x%012lx", + (unsigned long) data); + break; + case 7: + info->bytes_per_line = 8; + (*info->fprintf_styled_func) + (info->stream, dis_style_assembler_directive, ".dword"); + (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t"); + (*info->fprintf_styled_func) + (info->stream, dis_style_immediate, "0x%014lx", + (unsigned long) data); + break; case 8: info->bytes_per_line = 8; (*info->fprintf_styled_func) @@ -1332,7 +1359,7 @@ riscv_disassemble_data (bfd_vma memaddr ATTRIBUTE_UNUSED, (*info->fprintf_styled_func) (info->stream, dis_style_text, "\t"); (*info->fprintf_styled_func) (info->stream, dis_style_immediate, "0x%016llx", - (unsigned long long) data); + (unsigned long) data); break; default: abort (); -- 2.43.0