aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2020-09-02 11:00:15 +0930
committerAlan Modra <amodra@gmail.com>2020-09-02 16:30:44 +0930
commit7c80dd4c2cc080036b95176bcf35bb6f46355598 (patch)
treeee9db27bbee5db5a81b9d0716a49aa4053722f5c
parentb4b393495f506632a9be966277c6d6e668ba9778 (diff)
downloadgdb-7c80dd4c2cc080036b95176bcf35bb6f46355598.zip
gdb-7c80dd4c2cc080036b95176bcf35bb6f46355598.tar.gz
gdb-7c80dd4c2cc080036b95176bcf35bb6f46355598.tar.bz2
ubsan: v850-opc.c:412 left shift cannot be represented
include/ * opcode/v850.h (struct v850_operand <insert>): Make param op an unsigned long. opcodes/ * v850-opc.c (insert_i5div1, insert_i5div2, insert_i5div3), (insert_d5_4, insert_d8_6, insert_d8_7, insert_v8, insert_d9), (insert_u16_loop, insert_d16_15, insert_d16_16, insert_d17_16), (insert_d22, insert_d23, insert_d23_align1, insert_i9, insert_u9), (insert_spe, insert_r4, insert_POS, insert_WIDTH, insert_SELID), (insert_VECTOR8, insert_VECTOR5, insert_CACHEOP, insert_PREFOP), (nsert_IMM10U, insert_SRSEL1, insert_SRSEL2): Use unsigned long for value parameter and update code to suit. (extract_d9, extract_d16_15, extract_d16_16, extract_d17_16), (extract_d22, extract_d23, extract_i9): Use unsigned long variables.
-rw-r--r--include/ChangeLog5
-rw-r--r--include/opcode/v850.h2
-rw-r--r--opcodes/ChangeLog13
-rw-r--r--opcodes/v850-opc.c142
4 files changed, 87 insertions, 75 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index c6f00b3..62d8822 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,8 @@
+2020-09-02 Alan Modra <amodra@gmail.com>
+
+ * opcode/v850.h (struct v850_operand <insert>): Make param op an
+ unsigned long.
+
2020-09-02 Cooper Qu <cooper.qu@linux.alibaba.com>
* opcode/csky.h (CSKYV2_ISA_3E3R3): Define.
diff --git a/include/opcode/v850.h b/include/opcode/v850.h
index 214f952..2ad8eaa 100644
--- a/include/opcode/v850.h
+++ b/include/opcode/v850.h
@@ -133,7 +133,7 @@ struct v850_operand
operand value is legal, *ERRMSG will be unchanged (most operands
can accept any value). */
unsigned long (* insert)
- (unsigned long instruction, long op, const char ** errmsg);
+ (unsigned long instruction, unsigned long op, const char ** errmsg);
/* Extraction function. This is used by the disassembler. To
extract this operand type from an instruction, check this field.
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 7c7d9f4..7740c88 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,5 +1,18 @@
2020-09-02 Alan Modra <amodra@gmail.com>
+ * v850-opc.c (insert_i5div1, insert_i5div2, insert_i5div3),
+ (insert_d5_4, insert_d8_6, insert_d8_7, insert_v8, insert_d9),
+ (insert_u16_loop, insert_d16_15, insert_d16_16, insert_d17_16),
+ (insert_d22, insert_d23, insert_d23_align1, insert_i9, insert_u9),
+ (insert_spe, insert_r4, insert_POS, insert_WIDTH, insert_SELID),
+ (insert_VECTOR8, insert_VECTOR5, insert_CACHEOP, insert_PREFOP),
+ (nsert_IMM10U, insert_SRSEL1, insert_SRSEL2): Use unsigned long
+ for value parameter and update code to suit.
+ (extract_d9, extract_d16_15, extract_d16_16, extract_d17_16),
+ (extract_d22, extract_d23, extract_i9): Use unsigned long variables.
+
+2020-09-02 Alan Modra <amodra@gmail.com>
+
* i386-dis.c (OP_E_memory): Don't cast to signed type when
negating.
(get32, get32s): Use unsigned types in shift expressions.
diff --git a/opcodes/v850-opc.c b/opcodes/v850-opc.c
index 24b07fc..4c00ac6 100644
--- a/opcodes/v850-opc.c
+++ b/opcodes/v850-opc.c
@@ -75,7 +75,7 @@ v850_msg_is_out_of_range (const char* msg)
}
static unsigned long
-insert_i5div1 (unsigned long insn, long value, const char ** errmsg)
+insert_i5div1 (unsigned long insn, unsigned long value, const char ** errmsg)
{
if (value > 30 || value < 2)
{
@@ -104,7 +104,7 @@ extract_i5div1 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_i5div2 (unsigned long insn, long value, const char ** errmsg)
+insert_i5div2 (unsigned long insn, unsigned long value, const char ** errmsg)
{
if (value > 30 || value < 4)
{
@@ -133,7 +133,7 @@ extract_i5div2 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_i5div3 (unsigned long insn, long value, const char ** errmsg)
+insert_i5div3 (unsigned long insn, unsigned long value, const char ** errmsg)
{
if (value > 32 || value < 2)
{
@@ -162,9 +162,9 @@ extract_i5div3 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_d5_4 (unsigned long insn, long value, const char ** errmsg)
+insert_d5_4 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0x1f || value < 0)
+ if (value > 0x1f)
{
if (value & 1)
* errmsg = _(not_valid);
@@ -192,9 +192,9 @@ extract_d5_4 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_d8_6 (unsigned long insn, long value, const char ** errmsg)
+insert_d8_6 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0xff || value < 0)
+ if (value > 0xff)
{
if ((value % 4) != 0)
* errmsg = _(not_valid);
@@ -222,9 +222,9 @@ extract_d8_6 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_d8_7 (unsigned long insn, long value, const char ** errmsg)
+insert_d8_7 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0xff || value < 0)
+ if (value > 0xff)
{
if ((value % 2) != 0)
* errmsg = _(not_valid);
@@ -252,9 +252,9 @@ extract_d8_7 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_v8 (unsigned long insn, long value, const char ** errmsg)
+insert_v8 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0xff || value < 0)
+ if (value > 0xff)
* errmsg = _(immediate_out_of_range);
return insn | (value & 0x1f) | ((value & 0xe0) << (27-5));
@@ -271,9 +271,9 @@ extract_v8 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_d9 (unsigned long insn, long value, const char ** errmsg)
+insert_d9 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0xff || value < -0x100)
+ if (value + 0x100 > 0x1ff)
{
if ((value % 2) != 0)
* errmsg = branch_out_of_range_and_odd_offset;
@@ -289,7 +289,7 @@ insert_d9 (unsigned long insn, long value, const char ** errmsg)
static unsigned long
extract_d9 (unsigned long insn, int * invalid)
{
- signed long ret = ((insn >> 7) & 0x1f0) | ((insn >> 3) & 0x0e);
+ unsigned long ret = ((insn >> 7) & 0x1f0) | ((insn >> 3) & 0x0e);
ret = (ret ^ 0x100) - 0x100;
@@ -299,11 +299,11 @@ extract_d9 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_u16_loop (unsigned long insn, long value, const char ** errmsg)
+insert_u16_loop (unsigned long insn, unsigned long value, const char ** errmsg)
{
/* Loop displacement is encoded as a positive value,
even though the instruction branches backwards. */
- if (value < 0 || value > 0xffff)
+ if (value > 0xffff)
{
if ((value % 2) != 0)
* errmsg = branch_out_of_range_and_odd_offset;
@@ -327,9 +327,9 @@ extract_u16_loop (unsigned long insn, int * invalid)
}
static unsigned long
-insert_d16_15 (unsigned long insn, long value, const char ** errmsg)
+insert_d16_15 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0x7fff || value < -0x8000)
+ if (value + 0x8000 > 0xffff)
{
if ((value % 2) != 0)
* errmsg = _(not_valid);
@@ -345,7 +345,7 @@ insert_d16_15 (unsigned long insn, long value, const char ** errmsg)
static unsigned long
extract_d16_15 (unsigned long insn, int * invalid)
{
- signed long ret = (insn >> 16) & 0xfffe;
+ unsigned long ret = (insn >> 16) & 0xfffe;
ret = (ret ^ 0x8000) - 0x8000;
@@ -355,9 +355,9 @@ extract_d16_15 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_d16_16 (unsigned long insn, signed long value, const char ** errmsg)
+insert_d16_16 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0x7fff || value < -0x8000)
+ if (value + 0x8000 > 0xffff)
* errmsg = _(out_of_range);
return insn | ((value & 0xfffe) << 16) | ((value & 1) << 5);
@@ -366,7 +366,7 @@ insert_d16_16 (unsigned long insn, signed long value, const char ** errmsg)
static unsigned long
extract_d16_16 (unsigned long insn, int * invalid)
{
- signed long ret = ((insn >> 16) & 0xfffe) | ((insn >> 5) & 1);
+ unsigned long ret = ((insn >> 16) & 0xfffe) | ((insn >> 5) & 1);
ret = (ret ^ 0x8000) - 0x8000;
@@ -376,9 +376,9 @@ extract_d16_16 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_d17_16 (unsigned long insn, long value, const char ** errmsg)
+insert_d17_16 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0xffff || value < -0x10000)
+ if (value + 0x10000 > 0x1ffff)
* errmsg = _(out_of_range);
return insn | ((value & 0xfffe) << 16) | ((value & 0x10000) >> (16 - 4));
@@ -387,19 +387,19 @@ insert_d17_16 (unsigned long insn, long value, const char ** errmsg)
static unsigned long
extract_d17_16 (unsigned long insn, int * invalid)
{
- signed long ret = ((insn >> 16) & 0xfffe) | ((insn << (16 - 4)) & 0x10000);
+ unsigned long ret = ((insn >> 16) & 0xfffe) | ((insn << (16 - 4)) & 0x10000);
ret = (ret ^ 0x10000) - 0x10000;
if (invalid != 0)
*invalid = 0;
- return (unsigned long)ret;
+ return ret;
}
static unsigned long
-insert_d22 (unsigned long insn, long value, const char ** errmsg)
+insert_d22 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0x1fffff || value < -0x200000)
+ if (value + 0x200000 > 0x3fffff)
{
if ((value % 2) != 0)
* errmsg = branch_out_of_range_and_odd_offset;
@@ -415,28 +415,28 @@ insert_d22 (unsigned long insn, long value, const char ** errmsg)
static unsigned long
extract_d22 (unsigned long insn, int * invalid)
{
- signed long ret = ((insn >> 16) & 0xfffe) | ((insn << 16) & 0x3f0000);
+ unsigned long ret = ((insn >> 16) & 0xfffe) | ((insn << 16) & 0x3f0000);
ret = (ret ^ 0x200000) - 0x200000;
if (invalid != 0)
*invalid = 0;
- return (unsigned long) ret;
+ return ret;
}
static unsigned long
-insert_d23 (unsigned long insn, long value, const char ** errmsg)
+insert_d23 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0x3fffff || value < -0x400000)
+ if (value + 0x400000 > 0x7fffff)
* errmsg = out_of_range;
return insn | ((value & 0x7f) << 4) | ((value & 0x7fff80) << (16-7));
}
static unsigned long
-insert_d23_align1 (unsigned long insn, long value, const char ** errmsg)
+insert_d23_align1 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0x3fffff || value < -0x400000)
+ if (value + 0x400000 > 0x7fffff)
{
if (value & 0x1)
* errmsg = _(not_valid);
@@ -452,19 +452,19 @@ insert_d23_align1 (unsigned long insn, long value, const char ** errmsg)
static unsigned long
extract_d23 (unsigned long insn, int * invalid)
{
- signed long ret = ((insn >> 4) & 0x7f) | ((insn >> (16-7)) & 0x7fff80);
+ unsigned long ret = ((insn >> 4) & 0x7f) | ((insn >> (16-7)) & 0x7fff80);
ret = (ret ^ 0x400000) - 0x400000;
if (invalid != 0)
*invalid = 0;
- return (unsigned long) ret;
+ return ret;
}
static unsigned long
-insert_i9 (unsigned long insn, signed long value, const char ** errmsg)
+insert_i9 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- if (value > 0xff || value < -0x100)
+ if (value + 0x100 > 0x1ff)
* errmsg = _(immediate_out_of_range);
return insn | ((value & 0x1e0) << 13) | (value & 0x1f);
@@ -473,7 +473,7 @@ insert_i9 (unsigned long insn, signed long value, const char ** errmsg)
static unsigned long
extract_i9 (unsigned long insn, int * invalid)
{
- signed long ret = ((insn >> 13) & 0x1e0) | (insn & 0x1f);
+ unsigned long ret = ((insn >> 13) & 0x1e0) | (insn & 0x1f);
ret = (ret ^ 0x100) - 0x100;
@@ -483,10 +483,8 @@ extract_i9 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_u9 (unsigned long insn, long v, const char ** errmsg)
+insert_u9 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- unsigned long value = (unsigned long) v;
-
if (value > 0x1ff)
* errmsg = _(immediate_out_of_range);
@@ -504,10 +502,8 @@ extract_u9 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_spe (unsigned long insn, long v, const char ** errmsg)
+insert_spe (unsigned long insn, unsigned long value, const char ** errmsg)
{
- unsigned long value = (unsigned long) v;
-
if (value != 3)
* errmsg = _("invalid register for stack adjustment");
@@ -524,10 +520,8 @@ extract_spe (unsigned long insn ATTRIBUTE_UNUSED, int * invalid)
}
static unsigned long
-insert_r4 (unsigned long insn, long v, const char ** errmsg)
+insert_r4 (unsigned long insn, unsigned long value, const char ** errmsg)
{
- unsigned long value = (unsigned long) v;
-
if (value >= 32)
* errmsg = _("invalid register name");
@@ -552,12 +546,12 @@ extract_r4 (unsigned long insn, int * invalid)
static unsigned long G_pos;
static unsigned long
-insert_POS (unsigned long insn, long pos, const char ** errmsg)
+insert_POS (unsigned long insn, unsigned long pos, const char ** errmsg)
{
- if (pos > 0x1f || pos < 0)
+ if (pos > 0x1f)
* errmsg = _(pos_out_of_range);
- G_pos = (unsigned long) pos;
+ G_pos = pos;
return insn; /* Not an oparaton until WIDTH. */
}
@@ -598,17 +592,17 @@ extract_POS_L (unsigned long insn, int * invalid)
}
static unsigned long
-insert_WIDTH (unsigned long insn, long width, const char ** errmsg)
+insert_WIDTH (unsigned long insn, unsigned long width, const char ** errmsg)
{
unsigned long msb, lsb, opc, ret;
unsigned long msb_expand, lsb_expand;
- msb = (unsigned long)width + G_pos - 1;
+ msb = width + G_pos - 1;
lsb = G_pos;
opc = 0;
G_pos = 0;
- if (width > 0x20 || width < 0)
+ if (width > 0x20)
* errmsg = _(width_out_of_range);
if ((msb >= 16) && (lsb >= 16))
@@ -691,9 +685,9 @@ extract_WIDTH_L (unsigned long insn, int * invalid)
}
static unsigned long
-insert_SELID (unsigned long insn, long selid, const char ** errmsg)
+insert_SELID (unsigned long insn, unsigned long selid, const char ** errmsg)
{
- if ((unsigned long) selid > 0x1f)
+ if (selid > 0x1f)
* errmsg = _(selid_out_of_range);
return insn | ((selid & 0x1fUL) << 27);
@@ -716,12 +710,12 @@ extract_SELID (unsigned long insn, int * invalid)
}
static unsigned long
-insert_VECTOR8 (unsigned long insn, long vector8, const char ** errmsg)
+insert_VECTOR8 (unsigned long insn, unsigned long vector8, const char ** errmsg)
{
unsigned long ret;
- unsigned long VVV,vvvvv;
+ unsigned long VVV, vvvvv;
- if (vector8 > 0xff || vector8 < 0)
+ if (vector8 > 0xff)
* errmsg = _(vector8_out_of_range);
VVV = (vector8 & 0xe0) >> 5;
@@ -751,12 +745,12 @@ extract_VECTOR8 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_VECTOR5 (unsigned long insn, long vector5, const char ** errmsg)
+insert_VECTOR5 (unsigned long insn, unsigned long vector5, const char ** errmsg)
{
unsigned long ret;
unsigned long vvvvv;
- if (vector5 > 0x1f || vector5 < 0)
+ if (vector5 > 0x1f)
* errmsg = _(vector5_out_of_range);
vvvvv = (vector5 & 0x1f);
@@ -780,10 +774,10 @@ extract_VECTOR5 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_CACHEOP (unsigned long insn, long cacheop, const char ** errmsg ATTRIBUTE_UNUSED)
+insert_CACHEOP (unsigned long insn, unsigned long cacheop, const char ** errmsg ATTRIBUTE_UNUSED)
{
unsigned long ret;
- unsigned long pp,PPPPP;
+ unsigned long pp, PPPPP;
pp = (cacheop & 0x60) >> 5;
PPPPP = (cacheop & 0x1f);
@@ -797,7 +791,7 @@ static unsigned long
extract_CACHEOP (unsigned long insn, int * invalid)
{
unsigned long ret;
- unsigned long pp,PPPPP;
+ unsigned long pp, PPPPP;
unsigned long insn2;
insn2 = insn >> 16;
@@ -814,7 +808,7 @@ extract_CACHEOP (unsigned long insn, int * invalid)
}
static unsigned long
-insert_PREFOP (unsigned long insn, long prefop, const char ** errmsg ATTRIBUTE_UNUSED)
+insert_PREFOP (unsigned long insn, unsigned long prefop, const char ** errmsg ATTRIBUTE_UNUSED)
{
unsigned long ret;
unsigned long PPPPP;
@@ -846,15 +840,15 @@ extract_PREFOP (unsigned long insn, int * invalid)
}
static unsigned long
-insert_IMM10U (unsigned long insn, long value, const char ** errmsg)
+insert_IMM10U (unsigned long insn, unsigned long value, const char ** errmsg)
{
unsigned long imm10, ret;
unsigned long iiiii,IIIII;
- if (value > 0x3ff || value < 0)
+ if (value > 0x3ff)
* errmsg = _(imm10_out_of_range);
- imm10 = ((unsigned long) value) & 0x3ff;
+ imm10 = value & 0x3ff;
IIIII = (imm10 >> 5) & 0x1f;
iiiii = imm10 & 0x1f;
@@ -883,15 +877,15 @@ extract_IMM10U (unsigned long insn, int * invalid)
}
static unsigned long
-insert_SRSEL1 (unsigned long insn, long value, const char ** errmsg)
+insert_SRSEL1 (unsigned long insn, unsigned long value, const char ** errmsg)
{
unsigned long imm10, ret;
unsigned long sr,selid;
- if (value > 0x3ff || value < 0)
+ if (value > 0x3ff)
* errmsg = _(sr_selid_out_of_range);
- imm10 = (unsigned long) value;
+ imm10 = value;
selid = (imm10 & 0x3e0) >> 5;
sr = imm10 & 0x1f;
@@ -921,15 +915,15 @@ extract_SRSEL1 (unsigned long insn, int * invalid)
}
static unsigned long
-insert_SRSEL2 (unsigned long insn, long value, const char ** errmsg)
+insert_SRSEL2 (unsigned long insn, unsigned long value, const char ** errmsg)
{
unsigned long imm10, ret;
unsigned long sr, selid;
- if (value > 0x3ff || value < 0)
+ if (value > 0x3ff)
* errmsg = _(sr_selid_out_of_range);
- imm10 = (unsigned long) value;
+ imm10 = value;
selid = (imm10 & 0x3e0) >> 5;
sr = imm10 & 0x1f;