From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id vNm1ITp24mqPFgUAWB0awg (envelope-from ) for ; Wed, 28 Oct 2026 18:24:58 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IEXc8Tkr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 719881E007; Wed, 28 Oct 2026 18:24:58 -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.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 715931E007 for ; Wed, 28 Oct 2026 18:24:52 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E49B74BA23DD for ; Wed, 28 Oct 2026 22:24:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E49B74BA23DD Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IEXc8Tkr Received: from mail-dy1-x132e.google.com (mail-dy1-x132e.google.com [IPv6:2607:f8b0:4864:20::132e]) by sourceware.org (Postfix) with ESMTPS id D5E284BA2E1D for ; Wed, 28 Oct 2026 22:24:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5E284BA2E1D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D5E284BA2E1D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::132e ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793226267; cv=none; b=pDELoG4gmfNXU2IrHHtn3RABbVDvYNjJfVmytf90788/wjoTloDhbxA56HQ1XrmuM+w4DVoTQkIqSJMyhTRZOBChU+Kc4J0jFzSTEkXFGri/tjNd+43lNreI9J9/Hlu35YwQoEvfcuC6W97Wswe4HVNQuHz+oaonQ0q5eL6tTDI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1793226267; c=relaxed/simple; bh=SC0GNlHfh4sw5l4n2qPuN3ChYRO7xbm10v0Gov7/Lf4=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=DSmIbXRNIRb0MSx0i9Vr3NRK+VZc79155KPiq+n7mL60eNhbgOggE1Xplz+lxYpwERFR+fxfCJyR0WEUJfdtu2NR5woC4XHsiAqyO9C4FuzLZtXYP5R6dA8mRZlM9FZju/FdL0T/cJDRCAq1tSDZB04lu414nI+fYdE+nQfF2Ho= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IEXc8Tkr DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5E284BA2E1D Received: by mail-dy1-x132e.google.com with SMTP id 5a478bee46e88-3645f0f3fcdso2684817eec.0 for ; Wed, 28 Oct 2026 15:24:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793226266; x=1793831066; darn=sourceware.org; h=content-disposition:content-type:mime-version:message-id:subject:to :from:date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=GqRwj/z6+F1tF2CGfw32tGYMFEo3PHxVtv4TYTXZJ4Y=; b=IEXc8TkrcYs6RO1vKqE+lES3ssrh276aXI+0jg9o9rnc1mp8/auaUxJnIRt/zA5WlJ YItF7IbWxisxM/bBi0Bchgd7n/PauchFDVFvtBDdBf+7UOfVgA6LCWYBOe2V6hqAu8iu UymBIhuZgMLqSYko3KdIQ996HMUdS5WVJx3pZVCbujQZC+u/kPcIwYIqNL35p7cmToZ0 32+u2cxpOLYlo9M8353bXv4HCR470uXP09FefQQUJKtpL2MWT8+ou0YDHyWOds+MJp4+ 99lfEnMudNbhnMVaMyDrUc5Znp/zyhwZfiYthNV3RbsN8vJK0AtwmBuysEKX/5G4ZkuD IDJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793226266; x=1793831066; h=content-disposition:content-type:mime-version:message-id:subject:to :from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=GqRwj/z6+F1tF2CGfw32tGYMFEo3PHxVtv4TYTXZJ4Y=; b=Lo+UFeJDoYjiuy+/N76raPSRaqrTZ7I/cTU1oout0BBtM1Cruazie6Xt/NAXeykfJE OnToIV7pE4Gy1vcdWMwK1BGx6kKSmiih6/5A7sckFr9ucDZf6LhIHKkXTnzYj9ZhfGIT zzhxcEp8WzZsNlzjFHuRbW+uQ9RWzkHaxdBRLFtEK3p+wtUiVgrCLiKqRzY76+gJoWhD MJUe2v8G9odzQFBNbUPzjEtThRxkumKSYfC/aVJq6j0drnWbu1ir0XPsDMAOgaAqOnQs YKJpm6TnQlrTPysykbqrIAScsV7Tc7a0SJD+YjZajvWskCbdZSGiUQnfRnFSSSaQIc9q ocVw== X-Forwarded-Encrypted: i=1; AKwUvBytWMl39sFC/2BrLjTC/xbu8nL6nDGyMQ5j+CWjSlFUfGQi3nWw7xuMVtQmZblTd7yW/M0AXVG5GBjh6w==@sourceware.org X-Gm-Message-State: AFq9FYJrSjaTPMKcmIhj0880kErdfyxnuhA9ni3TplHDEa6DXyfk0UdQ rZxF82oYZOkrDOWBur+DTQp99YB8Kn70oLmh0V+3kssLR1qvdTkpUyWZXM8jsw== X-Gm-Gg: AYBFou3mVLnTyyEEKBSKXqqGcahZsVy6G9T8zzUYpbbcbo3s5BsE0w37sn01VQ0lFuy HuNLm+bXud6owHn9DtSwtJacPmh0fxCGlaPsIN4nEccT+fQnmWfVDPa56rN7w8zU4EHdXV+9aL2 W7ThSpf6Nf9zB3JqSUFL5W1D9AVyWC0J7/OBxnGHVrEfl2l8jOsUWJeou3br6plAL/+VXmblmqI RIdhc8QU+YSdDwyISi9IqjNG1scAgTq7iCvpQurjlSdKq2YKunYncsiwQSJEpG8oOUVIK1nqw6j xshS4pb+ncbpEo/fXt2pzjYfu1eMPspY1tJ4UzrvLaRcS0lFPjlGB/obfauwlV+LALI1RLBo9Wt w4aJ0SUKayBb5JLVR5OM/bSoYSwtHdbSGzujiUSOk9psW01IPlfjM6KJ/H8FMLSQxjjG0q3ruac CqNN8zRm2WPcvXm6hW/Zi7jnMwIxJNF4CuJdvtPBrlx6ptnkSRvDI1JpAXJNi0iPciuzeE4XXh6 9YrjJ+mRa7KSFf5wac6JwyUjSv/RNupW47qBVUnSGbHRI5yIK0H0Qcuo1qCJ4dab9yV0FZbz3iT uCEEUTqUcjvYqiBR33QF6mbwactNr79O99Z3tRMakM4= X-Received: by 2002:a05:7022:b044:20b0:14c:8461:b3ef with SMTP id a92af1059eb24-1a6ce208dfamr4882789c88.24.1793226265497; Wed, 28 Oct 2026 15:24:25 -0700 (PDT) Received: from squeak.grove.modra.org ([2406:3400:51d:8cc0:82b6:ade8:138a:c265]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1a75f7fb28csm11186524c88.18.2026.10.28.15.24.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Oct 2026 15:24:24 -0700 (PDT) Received: by squeak.grove.modra.org (Postfix, from userid 1000) id 7532C114193A; Thu, 29 Oct 2026 08:54:22 +1030 (ACDT) Date: Thu, 29 Oct 2026 08:54:22 +1030 From: Alan Modra To: binutils@sourceware.org, gdb-patches@sourceware.org Subject: Undefined shift in print_insn_tilepro Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 It is possible for tilepro operand_values to contain a value with the top bit set (see parse_insn_tilepro op->is_signed code), which can trigger a ubsan error when shifting it left. Avoid these "errors" by making operand_values an unsigned int rather than an int. tilegx has operand_values as long long but stores an unsigned int value, so the field may as well be unsigned int there too. include/ * opcode/tilepro.h (struct tilepro_decoded_instruction): Make operand_values unsigned int. * opcode/tilegx.h (struct tilegx_decoded_instruction): Likewise. opcodes/ * tilepro-dis.c (contains_insn): Make expected_first_operand, expected_second_operand and last_operand_ret unsigned int. (print_insn_tilepro): Make num and addr_piece unsigned int. * tilegx-dis.c (print_insn_tilegx): Make num unsigned int. gdb/ * tilegx-tdep.c (tilegx_analyze_prologue): Adjust "operands". diff --git a/gdb/tilegx-tdep.c b/gdb/tilegx-tdep.c index 0d1421f8758..27829d2ad04 100644 --- a/gdb/tilegx-tdep.c +++ b/gdb/tilegx-tdep.c @@ -440,7 +440,7 @@ tilegx_analyze_prologue (struct gdbarch* gdbarch, for (i = 0; i < num_insns; i++) { struct tilegx_decoded_instruction *this_insn = &decoded[i]; - long long *operands = this_insn->operand_values; + unsigned int *operands = this_insn->operand_values; const struct tilegx_opcode *opcode = this_insn->opcode; switch (opcode->mnemonic) diff --git a/include/opcode/tilegx.h b/include/opcode/tilegx.h index aeb73ddcec1..43ab417d04c 100644 --- a/include/opcode/tilegx.h +++ b/include/opcode/tilegx.h @@ -1258,7 +1258,7 @@ struct tilegx_decoded_instruction { const struct tilegx_opcode *opcode; const struct tilegx_operand *operands[TILEGX_MAX_OPERANDS]; - long long operand_values[TILEGX_MAX_OPERANDS]; + unsigned int operand_values[TILEGX_MAX_OPERANDS]; }; diff --git a/include/opcode/tilepro.h b/include/opcode/tilepro.h index 86b7e90ebf7..2af4796abe5 100644 --- a/include/opcode/tilepro.h +++ b/include/opcode/tilepro.h @@ -1581,7 +1581,7 @@ struct tilepro_decoded_instruction { const struct tilepro_opcode *opcode; const struct tilepro_operand *operands[TILEPRO_MAX_OPERANDS]; - int operand_values[TILEPRO_MAX_OPERANDS]; + unsigned int operand_values[TILEPRO_MAX_OPERANDS]; }; diff --git a/opcodes/tilegx-dis.c b/opcodes/tilegx-dis.c index b19afdfa454..2cb03266451 100644 --- a/opcodes/tilegx-dis.c +++ b/opcodes/tilegx-dis.c @@ -94,7 +94,7 @@ print_insn_tilegx (bfd_vma memaddr, disassemble_info *info) for (j = 0; j < opcode->num_operands; j++) { - bfd_vma num; + unsigned int num; const struct tilegx_operand *op; const char *spr_name; @@ -109,20 +109,20 @@ print_insn_tilegx (bfd_vma memaddr, disassemble_info *info) { case TILEGX_OP_TYPE_REGISTER: info->fprintf_func (info->stream, "%s", - tilegx_register_names[(int) num]); + tilegx_register_names[num]); break; case TILEGX_OP_TYPE_SPR: spr_name = get_tilegx_spr_name (num); if (spr_name != NULL) info->fprintf_func (info->stream, "%s", spr_name); else - info->fprintf_func (info->stream, "%d", (int)num); + info->fprintf_func (info->stream, "%d", num); break; case TILEGX_OP_TYPE_IMMEDIATE: - info->fprintf_func (info->stream, "%d", (int)num); + info->fprintf_func (info->stream, "%d", num); break; case TILEGX_OP_TYPE_ADDRESS: - info->print_address_func (num, info); + info->print_address_func ((bfd_vma) num, info); break; default: abort (); diff --git a/opcodes/tilepro-dis.c b/opcodes/tilepro-dis.c index aa9b532e2aa..d120545fd3f 100644 --- a/opcodes/tilepro-dis.c +++ b/opcodes/tilepro-dis.c @@ -32,10 +32,10 @@ static int contains_insn (tilepro_mnemonic expected_mnemonic, - int expected_first_operand, - int expected_second_operand, + unsigned int expected_first_operand, + unsigned int expected_second_operand, bfd_vma memaddr, - int *last_operand_ret, + unsigned int *last_operand_ret, disassemble_info *info) { struct tilepro_decoded_instruction @@ -59,11 +59,11 @@ contains_insn (tilepro_mnemonic expected_mnemonic, if (opcode->mnemonic != expected_mnemonic) continue; - if (expected_first_operand != -1 + if (expected_first_operand != -1u && decoded[i].operand_values[0] != expected_first_operand) continue; - if (expected_second_operand != -1 + if (expected_second_operand != -1u && decoded[i].operand_values[1] != expected_second_operand) continue; @@ -141,7 +141,7 @@ print_insn_tilepro (bfd_vma memaddr, disassemble_info *info) for (j = 0; j < opcode->num_operands; j++) { - int num; + unsigned int num; const struct tilepro_operand *op; const char *spr_name; @@ -171,7 +171,7 @@ print_insn_tilepro (bfd_vma memaddr, disassemble_info *info) { bfd_vma addr = 0; int found_addr = 0; - int addr_piece; + unsigned int addr_piece; switch (opcode->mnemonic) { @@ -191,7 +191,7 @@ print_insn_tilepro (bfd_vma memaddr, disassemble_info *info) case TILEPRO_OPC_AULI: if (contains_insn (TILEPRO_OPC_MOVELI, decoded[i].operand_values[1], - -1, + -1u, memaddr - TILEPRO_BUNDLE_SIZE_IN_BYTES, &addr_piece, info)) @@ -218,7 +218,7 @@ print_insn_tilepro (bfd_vma memaddr, disassemble_info *info) break; case TILEPRO_OP_TYPE_ADDRESS: - info->print_address_func ((bfd_vma)(unsigned int) num, info); + info->print_address_func ((bfd_vma) num, info); break; default: -- Alan Modra