From: Alan Modra Date: Tue, 10 Dec 2019 22:07:53 +0000 (+1030) Subject: ubsan: s12z: left shift cannot be represented in type 'int' X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=205c426a9bb387204a21165e2275e31c32248035;p=binutils-gdb.git ubsan: s12z: left shift cannot be represented in type 'int' * s12z-opc.c (z_decode_signed_value): Avoid signed overflow. --- diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index ddf8cd00724..a8e1d30a9d4 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,7 @@ +2019-12-11 Alan Modra + + * s12z-opc.c (z_decode_signed_value): Avoid signed overflow. + 2019-12-11 Alan Modra * ns32k-dis.c (bit_extract): Use unsigned arithmetic. diff --git a/opcodes/s12z-opc.c b/opcodes/s12z-opc.c index 3e0c0e0582c..044c72a21ca 100644 --- a/opcodes/s12z-opc.c +++ b/opcodes/s12z-opc.c @@ -410,9 +410,7 @@ z_decode_signed_value (struct mem_read_abstraction_base *mra, int offset, int i; uint32_t value = 0; for (i = 0; i < size; ++i) - { - value |= buffer[i] << (8 * (size - i - 1)); - } + value = (value << 8) | buffer[i]; if (buffer[0] & 0x80) {