From 8d3842cd156eb6cd6cd6c68c49c090b8f9452a2d Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Mon, 9 Nov 2015 17:12:57 +0100 Subject: gas: Fix left shift of negative value. This patch fixes all occurences of left-shifting negative constants in C cod which is undefined by the C standard. gas/ChangeLog: * read.c (parse_bitfield_cons): Fix left shift of negative value. * config/tc-xstormy16.c (md_section_align): Likewise. * config/tc-xgate.c (md_section_align): Likewise. * config/tc-visium.c (md_section_align): Likewise. * config/tc-v850.c (md_section_align): Likewise. * config/tc-tic6x.c (md_section_align): Likewise. * config/tc-sh.c (SH64PCREL32_M, SH64PCREL48_M, SH64PCREL32_M) (MOVI_32_M, MOVI_48_M, MOVI_32_M, md_section_align): Likewise. * config/tc-sh64.c (shmedia_md_estimate_size_before_relax): Likewise. * config/tc-score.c (s3_section_align): Likewise. * config/tc-score7.c (s7_section_align): Likewise. * config/tc-s390.c (md_section_align): Likewise. * config/tc-rx.c (md_section_align): Likewise. * config/tc-rl78.c (md_section_align): Likewise. * config/tc-ppc.c (md_section_align): Likewise. * config/tc-or1k.c (md_section_align): Likewise. * config/tc-nds32.c (md_section_align): Likewise. * config/tc-mt.c (md_section_align): Likewise. * config/tc-msp430.c (md_section_align): Likewise. * config/tc-mn10300.c (md_section_align): Likewise. * config/tc-mn10200.c (md_section_align): Likewise. * config/tc-mips.c (md_section_align): Likewise. * config/tc-microblaze.c (parse_imm): Likewise. * config/tc-mep.c (md_section_align): Likewise. * config/tc-m68k.c (md_section_align): Likewise. * config/tc-m68hc11.c (md_section_align): Likewise. * config/tc-m32r.c (md_section_align): Likewise. * config/tc-m32c.c (md_section_align): Likewise. * config/tc-lm32.c (md_section_align): Likewise. * config/tc-iq2000.c (md_section_align): Likewise. * config/tc-ip2k.c (md_section_align): Likewise. * config/tc-ia64.c (dot_save, dot_vframe): Likewise. * config/tc-i960.c (md_number_to_field, md_section_align): Likewise. * config/tc-i386.c (md_section_align): Likewise. * config/tc-i370.c (md_section_align): Likewise. * config/tc-frv.c (md_section_align): Likewise. * config/tc-fr30.c (md_section_align): Likewise. * config/tc-epiphany.c (md_section_align): Likewise. * config/tc-d30v.c (md_section_align): Likewise. * config/tc-d10v.c (md_section_align): Likewise. * config/tc-cr16.c (l_cons): Likewise. * config/tc-bfin.c (md_section_align): Likewise. * config/tc-arm.c (md_section_align): Likewise. * config/tc-arc.c (md_section_align): Likewise. * config/bfin-parse.y (expr_1): Likewise. gas/testsuite/ChangeLog: * gas/all/test-gen.c (random_order_16s, random_order_24s) (random_order_32s): Fix left shift of negative value. --- gas/config/tc-sh.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'gas/config/tc-sh.c') diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index 1b5beb2..125f073 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -281,15 +281,15 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP"; #if BFD_HOST_64BIT_LONG /* The "reach" type is long, so we can only do this for a 64-bit-long host. */ -#define SH64PCREL32_M (((long) -1 << 30) * 2 - 4) +#define SH64PCREL32_M ((-((long) 1 << 30)) * 2 - 4) #define SH64PCREL48_F ((((long) 1 << 47) - 1) - 4) -#define SH64PCREL48_M (((long) -1 << 47) - 4) +#define SH64PCREL48_M ((-((long) 1 << 47)) - 4) #define SH64PCREL48_LENGTH (3 * 4) #else /* If the host does not have 64-bit longs, just make this state identical in reach to the 32-bit state. Note that we have a slightly incorrect reach, but the correct one above will overflow a 32-bit number. */ -#define SH64PCREL32_M (((long) -1 << 30) * 2) +#define SH64PCREL32_M ((-((long) 1 << 30)) * 2) #define SH64PCREL48_F SH64PCREL32_F #define SH64PCREL48_M SH64PCREL32_M #define SH64PCREL48_LENGTH (3 * 4) @@ -313,14 +313,14 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP"; #if BFD_HOST_64BIT_LONG /* The "reach" type is long, so we can only do this for a 64-bit-long host. */ -#define MOVI_32_M (((long) -1 << 30) * 2 - 4) +#define MOVI_32_M ((-((long) 1 << 30)) * 2 - 4) #define MOVI_48_F ((((long) 1 << 47) - 1) - 4) -#define MOVI_48_M (((long) -1 << 47) - 4) +#define MOVI_48_M ((-((long) 1 << 47)) - 4) #else /* If the host does not have 64-bit longs, just make this state identical in reach to the 32-bit state. Note that we have a slightly incorrect reach, but the correct one above will overflow a 32-bit number. */ -#define MOVI_32_M (((long) -1 << 30) * 2) +#define MOVI_32_M ((-((long) 1 << 30)) * 2) #define MOVI_48_F MOVI_32_F #define MOVI_48_M MOVI_32_M #endif /* BFD_HOST_64BIT_LONG */ @@ -3692,7 +3692,7 @@ md_section_align (segT seg ATTRIBUTE_UNUSED, valueT size) return size; #else /* ! OBJ_ELF */ return ((size + (1 << bfd_get_section_alignment (stdoutput, seg)) - 1) - & (-1 << bfd_get_section_alignment (stdoutput, seg))); + & -(1 << bfd_get_section_alignment (stdoutput, seg))); #endif /* ! OBJ_ELF */ } -- cgit v1.1