aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-03-10 21:52:50 +1030
committerAlan Modra <amodra@gmail.com>2020-03-10 21:56:42 +1030
commita6a1f5e050c3d4444b8074ba9ba02f547b725892 (patch)
tree148949871d0afd71346130e2e8cbb7dc60024dde /gas
parente10ac147c80240c2d0aa0a2ae2ec7f6a934c198f (diff)
downloadgdb-a6a1f5e050c3d4444b8074ba9ba02f547b725892.zip
gdb-a6a1f5e050c3d4444b8074ba9ba02f547b725892.tar.gz
gdb-a6a1f5e050c3d4444b8074ba9ba02f547b725892.tar.bz2
More 1 << 31 signed overflows
* config/tc-csky.c (get_operand_value): Rewrite 1 << 31 expressions to avoid signed overflow. * config/tc-mcore.c (md_assemble): Likewise. * config/tc-mips.c (gpr_read_mask, gpr_write_mask): Likewise. * config/tc-nds32.c (SET_ADDEND): Likewise. * config/tc-nios2.c (nios2_assemble_arg_R): Likewise.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog9
-rw-r--r--gas/config/tc-csky.c4
-rw-r--r--gas/config/tc-mcore.c4
-rw-r--r--gas/config/tc-mips.c4
-rw-r--r--gas/config/tc-nds32.c4
-rw-r--r--gas/config/tc-nios2.c2
6 files changed, 18 insertions, 9 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 1ede132..836cb5c 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,12 @@
+2020-03-10 Alan Modra <amodra@gmail.com>
+
+ * config/tc-csky.c (get_operand_value): Rewrite 1 << 31 expressions
+ to avoid signed overflow.
+ * config/tc-mcore.c (md_assemble): Likewise.
+ * config/tc-mips.c (gpr_read_mask, gpr_write_mask): Likewise.
+ * config/tc-nds32.c (SET_ADDEND): Likewise.
+ * config/tc-nios2.c (nios2_assemble_arg_R): Likewise.
+
2020-03-09 Jan Beulich <jbeulich@suse.com>
* testsuite/gas/i386/avx.s: Add long-form VCMP[PS][SD] pseudos.
diff --git a/gas/config/tc-csky.c b/gas/config/tc-csky.c
index d03b817..83fca2a 100644
--- a/gas/config/tc-csky.c
+++ b/gas/config/tc-csky.c
@@ -3166,7 +3166,7 @@ get_operand_value (struct csky_opcode_info *op,
case OPRND_TYPE_IMM5b_1_31:
return is_imm_over_range (oper, 1, 31, -1);
case OPRND_TYPE_IMM5b_POWER:
- if (is_imm_over_range (oper, 1, ~(1 << 31), 1 << 31))
+ if (is_imm_over_range (oper, 1, (1u << 31) - 1, 1u << 31))
{
int log;
int val = csky_insn.val[csky_insn.idx - 1];
@@ -3179,7 +3179,7 @@ get_operand_value (struct csky_opcode_info *op,
/* This type for "mgeni" in csky v1 ISA. */
case OPRND_TYPE_IMM5b_7_31_POWER:
- if (is_imm_over_range (oper, 1, ~(1 << 31), 1 << 31))
+ if (is_imm_over_range (oper, 1, (1u << 31) - 1, 1u << 31))
{
int log;
int val = csky_insn.val[csky_insn.idx - 1];
diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c
index a22ce81..b849a7c 100644
--- a/gas/config/tc-mcore.c
+++ b/gas/config/tc-mcore.c
@@ -1088,7 +1088,7 @@ md_assemble (char * str)
if (* op_end == ',')
{
- op_end = parse_imm (op_end + 1, & reg, 1, 1 << 31);
+ op_end = parse_imm (op_end + 1, & reg, 1, 1u << 31);
/* Further restrict the immediate to a power of two. */
if ((reg & (reg - 1)) == 0)
reg = mylog2 (reg);
@@ -1144,7 +1144,7 @@ md_assemble (char * str)
if (* op_end == ',')
{
- op_end = parse_imm (op_end + 1, & reg, 1, 1 << 31);
+ op_end = parse_imm (op_end + 1, & reg, 1, 1u << 31);
/* Further restrict the immediate to a power of two. */
if ((reg & (reg - 1)) == 0)
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 9f78b5a..31acb77 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -4778,7 +4778,7 @@ gpr_read_mask (const struct mips_cl_insn *ip)
if (pinfo2 & INSN2_READ_SP)
mask |= 1 << SP;
if (pinfo2 & INSN2_READ_GPR_31)
- mask |= 1 << 31;
+ mask |= 1u << 31;
/* Don't include register 0. */
return mask & ~1;
}
@@ -4797,7 +4797,7 @@ gpr_write_mask (const struct mips_cl_insn *ip)
if (pinfo & INSN_WRITE_GPR_24)
mask |= 1 << 24;
if (pinfo & INSN_WRITE_GPR_31)
- mask |= 1 << 31;
+ mask |= 1u << 31;
if (pinfo & INSN_UDI)
/* UDI instructions have traditionally been assumed to write to RD. */
mask |= 1 << EXTRACT_OPERAND (mips_opts.micromips, RD, *ip);
diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c
index 0f5973d..893b61f 100644
--- a/gas/config/tc-nds32.c
+++ b/gas/config/tc-nds32.c
@@ -5278,8 +5278,8 @@ nds32_elf_sethi_range (struct nds32_relocs_pattern *pattern)
not, optimize option, 16 bit instruction is enable. */
#define SET_ADDEND(size, convertible, optimize, insn16_on) \
- (((size) & 0xff) | ((convertible) ? 1 << 31 : 0) \
- | ((optimize) ? 1<< 30 : 0) | (insn16_on ? 1 << 29 : 0))
+ (((size) & 0xff) | ((convertible) ? 1u << 31 : 0) \
+ | ((optimize) ? 1 << 30 : 0) | (insn16_on ? 1 << 29 : 0))
#define MAC_COMBO (E_NDS32_HAS_FPU_MAC_INST|E_NDS32_HAS_MAC_DX_INST)
static void
diff --git a/gas/config/tc-nios2.c b/gas/config/tc-nios2.c
index a7039e4..52cfb98 100644
--- a/gas/config/tc-nios2.c
+++ b/gas/config/tc-nios2.c
@@ -2710,7 +2710,7 @@ nios2_assemble_arg_R (const char *token, nios2_insn_infoS *insn)
mask = (reglist & 0x00ffc000) >> 14;
if (reglist & (1 << 28))
mask |= 1 << 10;
- if (reglist & (1 << 31))
+ if (reglist & (1u << 31))
mask |= 1 << 11;
}
insn->insn_code |= SET_IW_F1X4L17_REGMASK (mask);