ubsan: microblaze: left shift cannot be represented in type 'int'

* microblaze-dis.c (read_insn_microblaze): Avoid signed overflow.
This commit is contained in:
Alan Modra 2019-12-16 09:59:23 +10:30
parent 8a92faab92
commit 488d02fe77
2 changed files with 8 additions and 2 deletions

View File

@ -1,3 +1,7 @@
2019-12-16 Alan Modra <amodra@gmail.com>
* microblaze-dis.c (read_insn_microblaze): Avoid signed overflow.
2019-12-16 Alan Modra <amodra@gmail.com>
* nios2-dis.c (nios2_print_insn_arg): Avoid signed overflow

View File

@ -200,9 +200,11 @@ read_insn_microblaze (bfd_vma memaddr,
}
if (info->endian == BFD_ENDIAN_BIG)
inst = (ibytes[0] << 24) | (ibytes[1] << 16) | (ibytes[2] << 8) | ibytes[3];
inst = (((unsigned) ibytes[0] << 24) | (ibytes[1] << 16)
| (ibytes[2] << 8) | ibytes[3]);
else if (info->endian == BFD_ENDIAN_LITTLE)
inst = (ibytes[3] << 24) | (ibytes[2] << 16) | (ibytes[1] << 8) | ibytes[0];
inst = (((unsigned) ibytes[3] << 24) | (ibytes[2] << 16)
| (ibytes[1] << 8) | ibytes[0]);
else
abort ();