From 2480b6fa946bb2d2dc993b1c4a83a8e1258a75e8 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Wed, 18 Dec 2019 15:37:44 +1030 Subject: More signed overflow fixes The arc fix in create_map avoiding signed overflow by casting an unsigned char to unsigned int before shifting, shows one of the dangers of blinding doing that. The problem in this case was that the variable storing the value, newAuxRegister->address, was a long. Using the unsigned cast meant that the 32-bit value was zero extended when long is 64 bits. Previously we had a sign extension. Net result was that comparisons in arcExtMap_auxRegName didn't match. Of course, I could have cast the 32-bit unsigned value back to signed before storing in a long, but it's neater to just use an unsigned int for the address. opcodes/ * alpha-opc.c (OP): Avoid signed overflow. * arm-dis.c (print_insn): Likewise. * mcore-dis.c (print_insn_mcore): Likewise. * pj-dis.c (get_int): Likewise. * ppc-opc.c (EBD15, EBD15BI): Likewise. * score7-dis.c (s7_print_insn): Likewise. * tic30-dis.c (print_insn_tic30): Likewise. * v850-opc.c (insert_SELID): Likewise. * vax-dis.c (print_insn_vax): Likewise. * arc-ext.c (create_map): Likewise. (struct ExtAuxRegister): Make "address" field unsigned int. (arcExtMap_auxRegName): Pass unsigned address. (dump_ARC_extmap): Adjust. * arc-ext.h (arcExtMap_auxRegName): Update prototype. --- opcodes/arc-ext.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'opcodes/arc-ext.h') diff --git a/opcodes/arc-ext.h b/opcodes/arc-ext.h index e18e568c7a2..4127d187361 100644 --- a/opcodes/arc-ext.h +++ b/opcodes/arc-ext.h @@ -125,7 +125,7 @@ extern void build_ARC_extmap (bfd *); /* Accessor functions. */ extern enum ExtReadWrite arcExtMap_coreReadWrite (int); extern const char * arcExtMap_coreRegName (int); -extern const char * arcExtMap_auxRegName (long); +extern const char * arcExtMap_auxRegName (unsigned); extern const char * arcExtMap_condCodeName (int); extern const extInstruction_t *arcExtMap_insn (int, unsigned long long); extern struct arc_opcode *arcExtMap_genOpcode (const extInstruction_t *, -- cgit v1.2.1