ubsan: bfin: shift exponent is too large
authorAlan Modra <amodra@gmail.com>
Tue, 10 Dec 2019 12:02:06 +0000 (22:32 +1030)
committerAlan Modra <amodra@gmail.com>
Wed, 11 Dec 2019 01:07:44 +0000 (11:37 +1030)
commit2fd2b153a3819d3ab6b9c4cf06943d498187714c
tree62c7e56be47841b7fff485fe599df8ea5fcd412f
parenta11db3e9f3a679601f41671a9e7f54c37f2c5073
ubsan: bfin: shift exponent is too large

This was the following in fmtconst_val, x is unsigned int.
    x = SIGNEXTEND (x, constant_formats[cf].nbits);
Problem is, the SIGNEXTEND macro assumed its arg was a long and sign
extended by shifting left then shifting right, and didn't cast the
arg.  So don't do the silly shift thing.  It's not guaranteed to work
anyway according to the C standard.  ">>" might do a logical shift
even if its args are signed.

* bfin-dis.c (HOST_LONG_WORD_SIZE, XFIELD): Delete.
(SIGNBIT): New.
(MASKBITS, SIGNEXTEND): Rewrite.
(fmtconst): Don't use ? expression now that SIGNEXTEND uses
unsigned arithmetic, instead assign result of SIGNEXTEND back
to x.
(fmtconst_val): Use 1u in shift expression.
opcodes/ChangeLog
opcodes/bfin-dis.c
This page took 0.02415 seconds and 4 git commands to generate.