public inbox for gdb-testers@sourceware.org help / color / mirror / Atom feed
From: gdb-buildbot@sergiodj.net To: gdb-testers@sourceware.org Subject: [binutils-gdb] ubsan: v850: left shift cannot be represented in type 'long' Date: Wed, 11 Dec 2019 17:05:00 -0000 [thread overview] Message-ID: <2a81ccbbbf81ab9c66ba366a0c1da7abb6460423@gdb-build> (raw) *** TEST RESULTS FOR COMMIT 2a81ccbbbf81ab9c66ba366a0c1da7abb6460423 *** commit 2a81ccbbbf81ab9c66ba366a0c1da7abb6460423 Author: Alan Modra <amodra@gmail.com> AuthorDate: Wed Dec 11 08:53:50 2019 +1030 Commit: Alan Modra <amodra@gmail.com> CommitDate: Wed Dec 11 11:41:52 2019 +1030 ubsan: v850: left shift cannot be represented in type 'long' * v850-dis.c (get_operand_value): Use unsigned arithmetic. Don't sign extend using shifts. diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 3ba885c48b..2ad26cb5d6 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,8 @@ +2019-12-11 Alan Modra <amodra@gmail.com> + + * v850-dis.c (get_operand_value): Use unsigned arithmetic. Don't + sign extend using shifts. + 2019-12-11 Alan Modra <amodra@gmail.com> * tic6x-dis.c (tic6x_extract_32): Avoid signed overflow. diff --git a/opcodes/v850-dis.c b/opcodes/v850-dis.c index f8b5d1c93f..45e6c65d83 100644 --- a/opcodes/v850-dis.c +++ b/opcodes/v850-dis.c @@ -88,7 +88,7 @@ get_operand_value (const struct v850_operand *operand, bfd_boolean noerror, int *invalid) { - long value; + unsigned long value; bfd_byte buffer[4]; if ((operand->flags & V850E_IMMEDIATE16) @@ -158,11 +158,13 @@ get_operand_value (const struct v850_operand *operand, if (operand->bits == -1) value = (insn & operand->shift); else - value = (insn >> operand->shift) & ((1 << operand->bits) - 1); + value = (insn >> operand->shift) & ((1ul << operand->bits) - 1); if (operand->flags & V850_OPERAND_SIGNED) - value = ((long)(value << (sizeof (long)*8 - operand->bits)) - >> (sizeof (long)*8 - operand->bits)); + { + unsigned long sign = 1ul << (operand->bits - 1); + value = (value ^ sign) - sign; + } } return value;
next reply other threads:[~2019-12-11 16:49 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-11 17:05 gdb-buildbot [this message] 2019-12-11 16:49 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot 2019-12-11 17:16 ` Failures on Ubuntu-Aarch64-native-extended-gdbserver-m64, " gdb-buildbot 2019-12-11 17:50 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot 2019-12-12 5:59 ` Failures on Fedora-i686, " gdb-buildbot 2019-12-12 6:36 ` Failures on Fedora-x86_64-m64, " gdb-buildbot 2019-12-12 6:37 ` Failures on Fedora-x86_64-m32, " gdb-buildbot 2019-12-12 6:54 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot 2019-12-12 6:57 ` Failures on Fedora-x86_64-native-gdbserver-m32, " gdb-buildbot 2019-12-12 6:59 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot 2019-12-12 7:29 ` Failures on Fedora-x86_64-native-gdbserver-m64, " gdb-buildbot
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=2a81ccbbbf81ab9c66ba366a0c1da7abb6460423@gdb-build \ --to=gdb-buildbot@sergiodj.net \ --cc=gdb-testers@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).