From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121439 invoked by alias); 11 Dec 2019 01:30:44 -0000 Mailing-List: contact gdb-testers-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-testers-owner@sourceware.org Received: (qmail 121331 invoked by uid 89); 11 Dec 2019 01:30:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.1 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1626 X-HELO: kwanyin.sergiodj.net Received: from kwanyin.sergiodj.net (HELO kwanyin.sergiodj.net) (158.69.185.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 11 Dec 2019 01:30:35 +0000 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [binutils-gdb] ubsan: ia64: left shift of negative value From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Message-Id: <8ff23dba80b80a9f47d75dd43812e041f6674763@gdb-build> Date: Wed, 11 Dec 2019 01:34:00 -0000 X-SW-Source: 2019-q4/txt/msg04296.txt.bz2 *** TEST RESULTS FOR COMMIT 8ff23dba80b80a9f47d75dd43812e041f6674763 *** commit 8ff23dba80b80a9f47d75dd43812e041f6674763 Author: Alan Modra AuthorDate: Tue Dec 10 17:57:14 2019 +1030 Commit: Alan Modra CommitDate: Wed Dec 11 11:33:36 2019 +1030 ubsan: ia64: left shift of negative value Here, since val is signed: *valuep = (val << scale); * cpu-ia64-opc.c (ext_imms_scaled): Avoid undefined left shift of negative values by using unsigned vars. diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 50c878b29d..17ad44160a 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,8 @@ +2019-12-11 Alan Modra + + * cpu-ia64-opc.c (ext_imms_scaled): Avoid undefined left shift + of negative values by using unsigned vars. + 2019-12-07 Alan Modra PR 25236 diff --git a/bfd/cpu-ia64-opc.c b/bfd/cpu-ia64-opc.c index 84ee0e2e4a..8df90befe3 100644 --- a/bfd/cpu-ia64-opc.c +++ b/bfd/cpu-ia64-opc.c @@ -186,7 +186,7 @@ ext_imms_scaled (const struct ia64_operand *self, ia64_insn code, ia64_insn *valuep, int scale) { int i, bits = 0, total = 0; - BFD_HOST_64_BIT val = 0, sign; + BFD_HOST_U_64_BIT val = 0, sign; for (i = 0; i < NELEMS (self->field) && self->field[i].bits; ++i) { @@ -196,10 +196,10 @@ ext_imms_scaled (const struct ia64_operand *self, ia64_insn code, total += bits; } /* sign extend: */ - sign = (BFD_HOST_64_BIT) 1 << (total - 1); + sign = (BFD_HOST_U_64_BIT) 1 << (total - 1); val = (val ^ sign) - sign; - *valuep = (val << scale); + *valuep = val << scale; return 0; }