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.
This commit is contained in:
Alan Modra 2019-12-10 19:09:47 +10:30
parent 9d48687b41
commit a11db3e9f3
2 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2019-12-11 Alan Modra <amodra@gmail.com>
* arc-dis.c (find_format_from_table): Use ull constant when
shifting by up to 32.
2019-12-11 Alan Modra <amodra@gmail.com>
PR 25270

View File

@ -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. */