+2019-12-11 Alan Modra <amodra@gmail.com>
+
+ * m68k-dis.c (COERCE32): Cast value first.
+ (NEXTLONG, NEXTULONG): Avoid signed overflow.
+
2019-12-11 Alan Modra <amodra@gmail.com>
* h8300-dis.c (extract_immediate): Avoid signed overflow.
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 \
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)
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)