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.
This commit is contained in:
Dominik Vogt 2015-11-09 17:12:57 +01:00 committed by Andreas Krebbel
parent c4e0beacd7
commit 8d3842cd15
48 changed files with 118 additions and 65 deletions

View file

@ -1,3 +1,51 @@
2015-11-09 Dominik Vogt <vogt@linux.vnet.ibm.com>
* 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.
2015-11-02 Nick Clifton <nickc@redhat.com> 2015-11-02 Nick Clifton <nickc@redhat.com>
* config/rx-parse.y: Allow zero value for 5-bit displacements. * config/rx-parse.y: Allow zero value for 5-bit displacements.

View file

@ -4505,7 +4505,7 @@ static int
value_match (Expr_Node *exp, int sz, int sign, int mul, int issigned) value_match (Expr_Node *exp, int sz, int sign, int mul, int issigned)
{ {
int umax = (1 << sz) - 1; int umax = (1 << sz) - 1;
int min = -1 << (sz - 1); int min = -(1 << (sz - 1));
int max = (1 << (sz - 1)) - 1; int max = (1 << (sz - 1)) - 1;
int v = (EXPR_VALUE (exp)) & 0xffffffff; int v = (EXPR_VALUE (exp)) & 0xffffffff;

View file

@ -1067,7 +1067,7 @@ md_section_align (segT segment,
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
/* The location from which a PC relative jump should be calculated, /* The location from which a PC relative jump should be calculated,

View file

@ -21019,7 +21019,7 @@ md_section_align (segT segment ATTRIBUTE_UNUSED,
int align; int align;
align = bfd_get_section_alignment (stdoutput, segment); align = bfd_get_section_alignment (stdoutput, segment);
size = ((size + (1 << align) - 1) & ((valueT) -1 << align)); size = ((size + (1 << align) - 1) & (-((valueT) 1 << align)));
} }
#endif #endif

View file

@ -796,7 +796,7 @@ md_section_align (segment, size)
valueT size; valueT size;
{ {
int boundary = bfd_get_section_alignment (stdoutput, segment); int boundary = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << boundary) - 1) & (-1 << boundary)); return ((size + (1 << boundary) - 1) & -(1 << boundary));
} }

View file

@ -206,7 +206,7 @@ l_cons (int nbytes)
return; return;
} }
value |= ((~(-1 << width) & exp.X_add_number) value |= ((~(-(1 << width)) & exp.X_add_number)
<< ((BITS_PER_CHAR * nbytes) - bits_available)); << ((BITS_PER_CHAR * nbytes) - bits_available));
if ((bits_available -= width) == 0 if ((bits_available -= width) == 0

View file

@ -269,7 +269,7 @@ valueT
md_section_align (asection *seg, valueT addr) md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
void void

View file

@ -303,7 +303,7 @@ valueT
md_section_align (asection *seg, valueT addr) md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
void void

View file

@ -173,7 +173,7 @@ md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }

View file

@ -156,7 +156,7 @@ md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
symbolS * symbolS *

View file

@ -1227,7 +1227,7 @@ valueT
md_section_align (segT segment, valueT size) md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
symbolS * symbolS *

View file

@ -2375,7 +2375,7 @@ md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return (addr + (1 << align) - 1) & (-1 << align); return (addr + (1 << align) - 1) & -(1 << align);
} }
/* We don't have any form of relaxing. */ /* We don't have any form of relaxing. */

View file

@ -10317,7 +10317,7 @@ md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size)
int align; int align;
align = bfd_get_section_alignment (stdoutput, segment); align = bfd_get_section_alignment (stdoutput, segment);
size = ((size + (1 << align) - 1) & ((valueT) -1 << align)); size = ((size + (1 << align) - 1) & (-((valueT) 1 << align)));
} }
#endif #endif

View file

@ -1751,7 +1751,7 @@ md_number_to_field (char *instrP, /* Pointer to instruction to be fixed. */
{ {
/* Put bit field into instruction and write back in target /* Put bit field into instruction and write back in target
* byte order. */ * byte order. */
val &= ~(-1 << (int) numbits); /* Clear unused sign bits. */ val &= ~(-(1 << (int) numbits)); /* Clear unused sign bits. */
instr |= val; instr |= val;
md_number_to_chars (instrP, instr, 4); md_number_to_chars (instrP, instr, 4);
} }
@ -2466,7 +2466,7 @@ md_section_align (segT seg,
int align; int align;
align = bfd_get_section_alignment (stdoutput, seg); align = bfd_get_section_alignment (stdoutput, seg);
return (addr + (1 << align) - 1) & (-1 << align); return (addr + (1 << align) - 1) & -(1 << align);
} }
extern int coff_flags; extern int coff_flags;

View file

@ -3339,7 +3339,7 @@ dot_vframe (int dummy ATTRIBUTE_UNUSED)
if (! (unwind.prologue_mask & 2)) if (! (unwind.prologue_mask & 2))
add_unwind_entry (output_psp_gr (reg), NOT_A_CHAR); add_unwind_entry (output_psp_gr (reg), NOT_A_CHAR);
else if (reg != unwind.prologue_gr else if (reg != unwind.prologue_gr
+ (unsigned) popcount (unwind.prologue_mask & (-2 << 1))) + (unsigned) popcount (unwind.prologue_mask & -(2 << 1)))
as_warn (_("Operand of .vframe contradicts .prologue")); as_warn (_("Operand of .vframe contradicts .prologue"));
} }
@ -3421,7 +3421,7 @@ dot_save (int dummy ATTRIBUTE_UNUSED)
if (! (unwind.prologue_mask & 4)) if (! (unwind.prologue_mask & 4))
add_unwind_entry (output_pfs_gr (reg2), NOT_A_CHAR); add_unwind_entry (output_pfs_gr (reg2), NOT_A_CHAR);
else if (reg2 != unwind.prologue_gr else if (reg2 != unwind.prologue_gr
+ (unsigned) popcount (unwind.prologue_mask & (-4 << 1))) + (unsigned) popcount (unwind.prologue_mask & -(4 << 1)))
as_warn (_("Second operand of .save contradicts .prologue")); as_warn (_("Second operand of .save contradicts .prologue"));
break; break;
case REG_AR + AR_LC: case REG_AR + AR_LC:
@ -3440,7 +3440,7 @@ dot_save (int dummy ATTRIBUTE_UNUSED)
if (! (unwind.prologue_mask & 1)) if (! (unwind.prologue_mask & 1))
add_unwind_entry (output_preds_gr (reg2), NOT_A_CHAR); add_unwind_entry (output_preds_gr (reg2), NOT_A_CHAR);
else if (reg2 != unwind.prologue_gr else if (reg2 != unwind.prologue_gr
+ (unsigned) popcount (unwind.prologue_mask & (-1 << 1))) + (unsigned) popcount (unwind.prologue_mask & -(1 << 1)))
as_warn (_("Second operand of .save contradicts .prologue")); as_warn (_("Second operand of .save contradicts .prologue"));
break; break;
case REG_PRIUNAT: case REG_PRIUNAT:

View file

@ -231,7 +231,7 @@ md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }

View file

@ -432,7 +432,7 @@ valueT
md_section_align (segT segment, valueT size) md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
symbolS * symbolS *

View file

@ -278,7 +278,7 @@ valueT
md_section_align (asection *seg, valueT addr) md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
/* This function assembles the instructions. It emits the frags/bytes to the /* This function assembles the instructions. It emits the frags/bytes to the

View file

@ -410,7 +410,7 @@ valueT
md_section_align (segT segment, valueT size) md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
symbolS * symbolS *

View file

@ -1450,7 +1450,7 @@ md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
symbolS * symbolS *

View file

@ -584,7 +584,7 @@ valueT
md_section_align (asection *seg, valueT addr) md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
static int static int

View file

@ -7888,7 +7888,7 @@ md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size)
int align; int align;
align = bfd_get_section_alignment (stdoutput, segment); align = bfd_get_section_alignment (stdoutput, segment);
size = ((size + (1 << align) - 1) & ((valueT) -1 << align)); size = ((size + (1 << align) - 1) & (-((valueT) 1 << align)));
#endif #endif
return size; return size;

View file

@ -1382,7 +1382,7 @@ valueT
md_section_align (segT segment, valueT size) md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }

View file

@ -739,7 +739,7 @@ parse_imm (char * s, expressionS * e, offsetT min, offsetT max)
{ {
/* Special case: sign extend negative 32-bit values to 64-bits. */ /* Special case: sign extend negative 32-bit values to 64-bits. */
if ((e->X_add_number >> 31) == 1) if ((e->X_add_number >> 31) == 1)
e->X_add_number |= (-1 << 31); e->X_add_number |= -(1 << 31);
if (e->X_add_number < min || e->X_add_number > max) if (e->X_add_number < min || e->X_add_number > max)
{ {

View file

@ -16500,7 +16500,7 @@ md_section_align (asection *seg, valueT addr)
if (align > 4) if (align > 4)
align = 4; align = 4;
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
/* Utility routine, called from above as well. If called while the /* Utility routine, called from above as well. If called while the

View file

@ -676,7 +676,7 @@ valueT
md_section_align (asection *seg, valueT addr) md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
void void

View file

@ -905,7 +905,7 @@ md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
void void

View file

@ -3955,7 +3955,7 @@ md_section_align (asection * seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
/* If you define this macro, it should return the offset between the /* If you define this macro, it should return the offset between the

View file

@ -333,7 +333,7 @@ md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
symbolS * symbolS *

View file

@ -5380,7 +5380,7 @@ md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
/* GAS will call this function when a symbol table lookup fails, before it /* GAS will call this function when a symbol table lookup fails, before it

View file

@ -166,7 +166,7 @@ valueT
md_section_align (segT segment, valueT size) md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
symbolS * symbolS *

View file

@ -6090,7 +6090,7 @@ md_section_align (asection *seg ATTRIBUTE_UNUSED, valueT addr)
#else #else
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
#endif #endif
} }

View file

@ -1469,5 +1469,5 @@ valueT
md_section_align (segT segment, valueT size) md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }

View file

@ -1248,7 +1248,7 @@ valueT
md_section_align (segT segment, valueT size) md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
/* NOP - 1 cycle */ /* NOP - 1 cycle */

View file

@ -2047,7 +2047,7 @@ md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
/* We don't have any form of relaxing. */ /* We don't have any form of relaxing. */

View file

@ -7089,7 +7089,7 @@ static valueT
s3_section_align (segT segment ATTRIBUTE_UNUSED, valueT size) s3_section_align (segT segment ATTRIBUTE_UNUSED, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
static void static void

View file

@ -6634,7 +6634,7 @@ s7_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
static void static void

View file

@ -281,15 +281,15 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP";
#if BFD_HOST_64BIT_LONG #if BFD_HOST_64BIT_LONG
/* The "reach" type is long, so we can only do this for a 64-bit-long /* The "reach" type is long, so we can only do this for a 64-bit-long
host. */ 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_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) #define SH64PCREL48_LENGTH (3 * 4)
#else #else
/* If the host does not have 64-bit longs, just make this state identical /* 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 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. */ 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_F SH64PCREL32_F
#define SH64PCREL48_M SH64PCREL32_M #define SH64PCREL48_M SH64PCREL32_M
#define SH64PCREL48_LENGTH (3 * 4) #define SH64PCREL48_LENGTH (3 * 4)
@ -313,14 +313,14 @@ const char FLT_CHARS[] = "rRsSfFdDxXpP";
#if BFD_HOST_64BIT_LONG #if BFD_HOST_64BIT_LONG
/* The "reach" type is long, so we can only do this for a 64-bit-long /* The "reach" type is long, so we can only do this for a 64-bit-long
host. */ 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_F ((((long) 1 << 47) - 1) - 4)
#define MOVI_48_M (((long) -1 << 47) - 4) #define MOVI_48_M ((-((long) 1 << 47)) - 4)
#else #else
/* If the host does not have 64-bit longs, just make this state identical /* 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 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. */ 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_F MOVI_32_F
#define MOVI_48_M MOVI_32_M #define MOVI_48_M MOVI_32_M
#endif /* BFD_HOST_64BIT_LONG */ #endif /* BFD_HOST_64BIT_LONG */
@ -3692,7 +3692,7 @@ md_section_align (segT seg ATTRIBUTE_UNUSED, valueT size)
return size; return size;
#else /* ! OBJ_ELF */ #else /* ! OBJ_ELF */
return ((size + (1 << bfd_get_section_alignment (stdoutput, seg)) - 1) 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 */ #endif /* ! OBJ_ELF */
} }

View file

@ -2020,7 +2020,7 @@ shmedia_md_estimate_size_before_relax (fragS *fragP,
offsetT value = fragP->fr_offset offsetT value = fragP->fr_offset
+ (fragP->fr_symbol == NULL ? 0 : S_GET_VALUE (fragP->fr_symbol)); + (fragP->fr_symbol == NULL ? 0 : S_GET_VALUE (fragP->fr_symbol));
if (value >= ((offsetT) -1 << 15) && value < ((offsetT) 1 << 15)) if (value >= (-((offsetT) 1 << 15)) && value < ((offsetT) 1 << 15))
{ {
/* Fits in 16-bit signed number. */ /* Fits in 16-bit signed number. */
int what = GET_WHAT (fragP->fr_subtype); int what = GET_WHAT (fragP->fr_subtype);

View file

@ -4484,7 +4484,7 @@ md_section_align (segT segment ATTRIBUTE_UNUSED,
/* Round up section sizes to ensure that text sections consist of /* Round up section sizes to ensure that text sections consist of
whole fetch packets. */ whole fetch packets. */
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & ((valueT) -1 << align)); return ((size + (1 << align) - 1) & (-((valueT) 1 << align)));
} }
/* No special undefined symbol handling needed for now. */ /* No special undefined symbol handling needed for now. */

View file

@ -1879,7 +1879,7 @@ valueT
md_section_align (asection *seg, valueT addr) md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
void void

View file

@ -224,7 +224,7 @@ md_section_align (asection *seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
void void

View file

@ -235,7 +235,7 @@ valueT
md_section_align (segT segment, valueT size) md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
symbolS * symbolS *

View file

@ -469,7 +469,7 @@ valueT
md_section_align (asection * seg, valueT addr) md_section_align (asection * seg, valueT addr)
{ {
int align = bfd_get_section_alignment (stdoutput, seg); int align = bfd_get_section_alignment (stdoutput, seg);
return ((addr + (1 << align) - 1) & (-1 << align)); return ((addr + (1 << align) - 1) & -(1 << align));
} }
void void

View file

@ -279,7 +279,7 @@ md_section_align (segT segment, valueT size)
{ {
int align = bfd_get_section_alignment (stdoutput, segment); int align = bfd_get_section_alignment (stdoutput, segment);
return ((size + (1 << align) - 1) & (-1 << align)); return ((size + (1 << align) - 1) & -(1 << align));
} }
symbolS * symbolS *

View file

@ -4602,7 +4602,7 @@ parse_bitfield_cons (exp, nbytes)
return; return;
} /* Too complex. */ } /* Too complex. */
value |= ((~(-1 << width) & exp->X_add_number) value |= ((~(-(1 << width)) & exp->X_add_number)
<< ((BITS_PER_CHAR * nbytes) - bits_available)); << ((BITS_PER_CHAR * nbytes) - bits_available));
if ((bits_available -= width) == 0 if ((bits_available -= width) == 0

View file

@ -1,3 +1,8 @@
2015-11-09 Dominik Vogt <vogt@linux.vnet.ibm.com>
* gas/all/test-gen.c (random_order_16s, random_order_24s)
(random_order_32s): Fix left shift of negative value.
2015-11-02 Nick Clifton <nickc@redhat.com> 2015-11-02 Nick Clifton <nickc@redhat.com>
* gas/rx/max.d: Update expected disassembly. * gas/rx/max.d: Update expected disassembly.

View file

@ -404,12 +404,12 @@ int random_order_16s[] =
generated often enough. */ generated often enough. */
-32768, -32768,
32767, 32767,
(-1 << 15) | (64 << 8) | 32, (-(1 << 15)) | (64 << 8) | 32,
(64 << 8) | 32, (64 << 8) | 32,
0x1234, 0x1234,
(-1 << 15) | 0x8765, (-(1 << 15)) | 0x8765,
0x0180, 0x0180,
(-1 << 15) | 0x8001 (-(1 << 15)) | 0x8001
}; };
/* Use `24s' to generate 24-bit signed values. Good for selecting /* Use `24s' to generate 24-bit signed values. Good for selecting
@ -420,14 +420,14 @@ int random_order_24s[] =
intermediate values selected by chance. Keep the number of intermediate values selected by chance. Keep the number of
intermediate values low, to ensure that the limit values are intermediate values low, to ensure that the limit values are
generated often enough. */ generated often enough. */
-1 << 23, -(1 << 23),
1 << 23 -1, 1 << 23 -1,
(-1 << 23) | (((64 << 8) | 32) << 8) | 16, (-(1 << 23)) | (((64 << 8) | 32) << 8) | 16,
(((64 << 8) | 32) << 8) | 16, (((64 << 8) | 32) << 8) | 16,
0x123456, 0x123456,
(-1 << 23) | 0x876543, (-(1 << 23)) | 0x876543,
0x01ff80, 0x01ff80,
(-1 << 23) | 0x80ff01 (-(1 << 23)) | 0x80ff01
}; };
/* Use `32s' to generate 32-bit signed values. Good for selecting /* Use `32s' to generate 32-bit signed values. Good for selecting
@ -438,14 +438,14 @@ int random_order_32s[] =
intermediate values selected by chance. Keep the number of intermediate values selected by chance. Keep the number of
intermediate values low, to ensure that the limit values are intermediate values low, to ensure that the limit values are
generated often enough. */ generated often enough. */
-1 << 31, -(1 << 31),
1 << 31 - 1, 1 << 31 - 1,
(-1 << 31) | (((((64 << 8) | 32) << 8) | 16) << 8) | 8, (-(1 << 31)) | (((((64 << 8) | 32) << 8) | 16) << 8) | 8,
(((((64 << 8) | 32) << 8) | 16) << 8) | 8, (((((64 << 8) | 32) << 8) | 16) << 8) | 8,
0x12345678, 0x12345678,
(-1 << 31) | 0x87654321, (-(1 << 31)) | 0x87654321,
0x01ffff80, 0x01ffff80,
(-1 << 31) | 0x80ffff01 (-(1 << 31)) | 0x80ffff01
}; };
/* This function computes the number of digits needed to represent a /* This function computes the number of digits needed to represent a