From: Alan Modra Date: Tue, 10 Dec 2019 08:39:47 +0000 (+1030) Subject: ubsan: arc: shift exponent 32 is too large for 32-bit type 'int' X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a11db3e9f3a679601f41671a9e7f54c37f2c5073;p=binutils-gdb.git ubsan: arc: shift exponent 32 is too large for 32-bit type 'int' When operand->bits is 32, the following results in UB. value = (insn >> operand->shift) & ((1 << operand->bits) - 1); * arc-dis.c (find_format_from_table): Use ull constant when shifting by up to 32. --- diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index 3460b3e2d60..d3f1e699406 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,8 @@ +2019-12-11 Alan Modra + + * arc-dis.c (find_format_from_table): Use ull constant when + shifting by up to 32. + 2019-12-11 Alan Modra PR 25270 diff --git a/opcodes/arc-dis.c b/opcodes/arc-dis.c index 3c88c334283..a038fa0ca27 100644 --- a/opcodes/arc-dis.c +++ b/opcodes/arc-dis.c @@ -295,7 +295,7 @@ find_format_from_table (struct disassemble_info *info, if (operand->extract) value = (*operand->extract) (insn, &invalid); else - value = (insn >> operand->shift) & ((1 << operand->bits) - 1); + value = (insn >> operand->shift) & ((1ull << operand->bits) - 1); /* Check for LIMM indicator. If it is there, then make sure we pick the right format. */