diff options
author | Alan Modra <amodra@gmail.com> | 2019-12-11 08:23:33 +1030 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-12-11 11:39:42 +1030 |
commit | 334175b693a1cbab8850f5faa6937e7c6ca3db7d (patch) | |
tree | 8b8bbdd8c2b4883def754703b051df53d2bdd8a2 /opcodes/m68k-dis.c | |
parent | f8a87c78e671b6e89c1d6dccdb2f99a34ddc23be (diff) | |
download | gdb-334175b693a1cbab8850f5faa6937e7c6ca3db7d.zip gdb-334175b693a1cbab8850f5faa6937e7c6ca3db7d.tar.gz gdb-334175b693a1cbab8850f5faa6937e7c6ca3db7d.tar.bz2 |
ubsan: m68k: left shift cannot be represented in type 'int'
* m68k-dis.c (COERCE32): Cast value first.
(NEXTLONG, NEXTULONG): Avoid signed overflow.
Diffstat (limited to 'opcodes/m68k-dis.c')
-rw-r--r-- | opcodes/m68k-dis.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/opcodes/m68k-dis.c b/opcodes/m68k-dis.c index 7584541..6e913d7 100644 --- a/opcodes/m68k-dis.c +++ b/opcodes/m68k-dis.c @@ -96,7 +96,7 @@ enum print_insn_arg_error while (0) /* Get a 4 byte signed integer. */ -#define COERCE32(x) ((bfd_signed_vma) ((x) ^ 0x80000000) - 0x80000000) +#define COERCE32(x) (((bfd_vma) (x) ^ 0x80000000) - 0x80000000) #define NEXTLONG(p, val, ret_val) \ do \ @@ -104,7 +104,8 @@ enum print_insn_arg_error p += 4; \ if (!FETCH_DATA (info, p)) \ return ret_val; \ - val = COERCE32 ((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]); \ + val = COERCE32 (((((((unsigned) p[-4] << 8) + p[-3]) << 8) \ + + p[-2]) << 8) + p[-1]); \ } \ while (0) @@ -115,7 +116,8 @@ enum print_insn_arg_error p += 4; \ if (!FETCH_DATA (info, p)) \ return PRINT_INSN_ARG_MEMORY_ERROR; \ - val = (unsigned int) ((((((p[-4] << 8) + p[-3]) << 8) + p[-2]) << 8) + p[-1]); \ + val = (((((((unsigned) p[-4] << 8) + p[-3]) << 8) \ + + p[-2]) << 8) + p[-1]); \ } \ while (0) |