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: aarch64: left shift cannot be represented in type 'int64_t' Date: Tue, 17 Dec 2019 14:06:00 -0000 [thread overview] Message-ID: <29298bf66f62f2f6c1efb0685623fbc29dfade90@gdb-build> (raw) *** TEST RESULTS FOR COMMIT 29298bf66f62f2f6c1efb0685623fbc29dfade90 *** commit 29298bf66f62f2f6c1efb0685623fbc29dfade90 Author: Alan Modra <amodra@gmail.com> AuthorDate: Tue Dec 17 22:48:48 2019 +1030 Commit: Alan Modra <amodra@gmail.com> CommitDate: Tue Dec 17 22:58:19 2019 +1030 ubsan: aarch64: left shift cannot be represented in type 'int64_t' * aarch64-opc.c (value_fit_signed_field_p): Avoid signed overflow. (value_fit_unsigned_field_p): Likewise. (aarch64_wide_constant_p): Likewise. (operand_general_constraint_met_p): Likewise. * aarch64-opc.h (aarch64_wide_constant_p): Update prototype. diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 1e9945ee8d..e2aa20b5e8 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,11 @@ +2019-12-17 Alan Modra <amodra@gmail.com> + + * aarch64-opc.c (value_fit_signed_field_p): Avoid signed overflow. + (value_fit_unsigned_field_p): Likewise. + (aarch64_wide_constant_p): Likewise. + (operand_general_constraint_met_p): Likewise. + * aarch64-opc.h (aarch64_wide_constant_p): Update prototype. + 2019-12-17 Alan Modra <amodra@gmail.com> * nds32-dis.c (nds32_mask_opcode): Avoid signed overflow. diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c index 61547b403d..2566513776 100644 --- a/opcodes/aarch64-opc.c +++ b/opcodes/aarch64-opc.c @@ -546,7 +546,7 @@ value_fit_signed_field_p (int64_t value, unsigned width) assert (width < 32); if (width < sizeof (value) * 8) { - int64_t lim = (int64_t)1 << (width - 1); + int64_t lim = (uint64_t) 1 << (width - 1); if (value >= -lim && value < lim) return 1; } @@ -560,7 +560,7 @@ value_fit_unsigned_field_p (int64_t value, unsigned width) assert (width < 32); if (width < sizeof (value) * 8) { - int64_t lim = (int64_t)1 << width; + int64_t lim = (uint64_t) 1 << width; if (value >= 0 && value < lim) return 1; } @@ -1063,7 +1063,7 @@ match_operands_qualifier (aarch64_inst *inst, bfd_boolean update_p) amount will be returned in *SHIFT_AMOUNT. */ bfd_boolean -aarch64_wide_constant_p (int64_t value, int is32, unsigned int *shift_amount) +aarch64_wide_constant_p (uint64_t value, int is32, unsigned int *shift_amount) { int amount; @@ -1074,22 +1074,21 @@ aarch64_wide_constant_p (int64_t value, int is32, unsigned int *shift_amount) /* Allow all zeros or all ones in top 32-bits, so that 32-bit constant expressions like ~0x80000000 are permitted. */ - uint64_t ext = value; - if (ext >> 32 != 0 && ext >> 32 != (uint64_t) 0xffffffff) + if (value >> 32 != 0 && value >> 32 != 0xffffffff) /* Immediate out of range. */ return FALSE; - value &= (int64_t) 0xffffffff; + value &= 0xffffffff; } /* first, try movz then movn */ amount = -1; - if ((value & ((int64_t) 0xffff << 0)) == value) + if ((value & ((uint64_t) 0xffff << 0)) == value) amount = 0; - else if ((value & ((int64_t) 0xffff << 16)) == value) + else if ((value & ((uint64_t) 0xffff << 16)) == value) amount = 16; - else if (!is32 && (value & ((int64_t) 0xffff << 32)) == value) + else if (!is32 && (value & ((uint64_t) 0xffff << 32)) == value) amount = 32; - else if (!is32 && (value & ((int64_t) 0xffff << 48)) == value) + else if (!is32 && (value & ((uint64_t) 0xffff << 48)) == value) amount = 48; if (amount == -1) @@ -1535,7 +1534,7 @@ operand_general_constraint_met_p (const aarch64_opnd_info *opnds, int idx, : _("z0-z7 expected")); return 0; } - mask = (1 << (size - shift)) - 1; + mask = (1u << (size - shift)) - 1; if (!value_in_range_p (opnd->reglane.index, 0, mask)) { set_elem_idx_out_of_range_error (mismatch_detail, idx, 0, mask); @@ -2161,7 +2160,7 @@ operand_general_constraint_met_p (const aarch64_opnd_info *opnds, int idx, if (!value_fit_unsigned_field_p (opnd->imm.value, size)) { set_imm_out_of_range_error (mismatch_detail, idx, 0, - (1 << size) - 1); + (1u << size) - 1); return 0; } break; diff --git a/opcodes/aarch64-opc.h b/opcodes/aarch64-opc.h index bb0a50892b..e0d4f5bae2 100644 --- a/opcodes/aarch64-opc.h +++ b/opcodes/aarch64-opc.h @@ -485,7 +485,7 @@ enum aarch64_modifier_kind aarch64_get_operand_modifier_from_value (aarch64_insn, bfd_boolean); -bfd_boolean aarch64_wide_constant_p (int64_t, int, unsigned int *); +bfd_boolean aarch64_wide_constant_p (uint64_t, int, unsigned int *); bfd_boolean aarch64_logical_immediate_p (uint64_t, int, aarch64_insn *); int aarch64_shrink_expanded_imm8 (uint64_t);
next reply other threads:[~2019-12-17 14:02 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-17 14:06 gdb-buildbot [this message] 2019-12-17 14:02 ` Failures on Ubuntu-Aarch64-m64, branch master gdb-buildbot 2019-12-17 15:23 ` Failures on Ubuntu-Aarch64-native-gdbserver-m64, " gdb-buildbot 2019-12-19 17:38 ` Failures on Fedora-i686, " gdb-buildbot 2019-12-19 17:44 ` Failures on Fedora-x86_64-cc-with-index, " gdb-buildbot 2019-12-19 18:32 ` Failures on Fedora-x86_64-m64, " gdb-buildbot 2019-12-19 18:47 ` Failures on Fedora-x86_64-m32, " gdb-buildbot 2019-12-19 19:05 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " gdb-buildbot 2019-12-19 19:55 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " gdb-buildbot 2019-12-19 20:26 ` Failures on Fedora-x86_64-native-gdbserver-m32, " 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=29298bf66f62f2f6c1efb0685623fbc29dfade90@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).