ubsan: score: left shift of negative value
* score-dis.c (print_insn_score48): Use unsigned variables for unsigned values. Don't left shift negative values. (print_insn_score32): Likewise. * score7-dis.c (print_insn_score32, print_insn_score16): Likewise.
This commit is contained in:
parent
b50ef514ff
commit
b2c759ce68
@ -1,3 +1,10 @@
|
||||
2020-01-13 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* score-dis.c (print_insn_score48): Use unsigned variables for
|
||||
unsigned values. Don't left shift negative values.
|
||||
(print_insn_score32): Likewise.
|
||||
* score7-dis.c (print_insn_score32, print_insn_score16): Likewise.
|
||||
|
||||
2020-01-13 Alan Modra <amodra@gmail.com>
|
||||
|
||||
* tic4x-dis.c (tic4x_print_register): Remove dead code.
|
||||
|
@ -565,7 +565,7 @@ print_insn_score48 (struct disassemble_info *info, bfd_vma given)
|
||||
{
|
||||
case 'r':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
@ -575,7 +575,7 @@ print_insn_score48 (struct disassemble_info *info, bfd_vma given)
|
||||
break;
|
||||
case 'd':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
@ -600,14 +600,14 @@ print_insn_score48 (struct disassemble_info *info, bfd_vma given)
|
||||
|| ((given & insn->mask) == 0x0c00000b) /* stc1 */
|
||||
|| ((given & insn->mask) == 0x0c000013) /* stc2 */
|
||||
|| ((given & insn->mask) == 0x0c00001b)) /* stc3 */
|
||||
reg <<= 2;
|
||||
reg *= 4;
|
||||
|
||||
func (stream, "%ld", reg);
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
@ -617,7 +617,7 @@ print_insn_score48 (struct disassemble_info *info, bfd_vma given)
|
||||
break;
|
||||
case 'w':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
reg = given >> bitstart;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
reg <<= 2;
|
||||
@ -731,7 +731,7 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
}
|
||||
else
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
int bitstart = 10;
|
||||
int bitend = 14;
|
||||
reg = given >> bitstart;
|
||||
@ -784,7 +784,7 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
{
|
||||
case 'r':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
@ -794,7 +794,7 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
break;
|
||||
case 'd':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
@ -817,14 +817,14 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
|| ((given & insn->mask) == 0x0c00000b) /* stc1 */
|
||||
|| ((given & insn->mask) == 0x0c000013) /* stc2 */
|
||||
|| ((given & insn->mask) == 0x0c00001b)) /* stc3 */
|
||||
reg <<= 2;
|
||||
reg *= 4;
|
||||
|
||||
func (stream, "%ld", reg);
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
|
@ -613,20 +613,20 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
{
|
||||
case 'r':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2 << (bitend - bitstart)) - 1;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
|
||||
func (stream, "%s", score_regnames[reg]);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2 << (bitend - bitstart)) - 1;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
|
||||
func (stream, "%ld", reg);
|
||||
}
|
||||
@ -636,9 +636,9 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2 << (bitend - bitstart)) - 1;
|
||||
reg = ((reg ^ (1 << (bitend - bitstart))) -
|
||||
(1 << (bitend - bitstart)));
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
reg = ((reg ^ (1 << (bitend - bitstart)))
|
||||
- (1 << (bitend - bitstart)));
|
||||
|
||||
if (((given & insn->mask) == 0x0c00000a) /* ldc1 */
|
||||
|| ((given & insn->mask) == 0x0c000012) /* ldc2 */
|
||||
@ -646,17 +646,17 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
|| ((given & insn->mask) == 0x0c00000b) /* stc1 */
|
||||
|| ((given & insn->mask) == 0x0c000013) /* stc2 */
|
||||
|| ((given & insn->mask) == 0x0c00001b)) /* stc3 */
|
||||
reg <<= 2;
|
||||
reg *= 4;
|
||||
|
||||
func (stream, "%ld", reg);
|
||||
}
|
||||
break;
|
||||
case 'x':
|
||||
{
|
||||
long reg;
|
||||
unsigned long reg;
|
||||
|
||||
reg = given >> bitstart;
|
||||
reg &= (2 << (bitend - bitstart)) - 1;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
|
||||
func (stream, "%lx", reg);
|
||||
}
|
||||
@ -667,12 +667,12 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
break;
|
||||
case '`':
|
||||
c++;
|
||||
if ((given & (1 << bitstart)) == 0)
|
||||
if ((given & (1u << bitstart)) == 0)
|
||||
func (stream, "%c", *c);
|
||||
break;
|
||||
case '\'':
|
||||
c++;
|
||||
if ((given & (1 << bitstart)) != 0)
|
||||
if ((given & (1u << bitstart)) != 0)
|
||||
func (stream, "%c", *c);
|
||||
break;
|
||||
default:
|
||||
@ -789,7 +789,7 @@ print_insn_score16 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
if (!bitend)
|
||||
abort ();
|
||||
reg = given >> bitstart;
|
||||
reg &= (2 << (bitend - bitstart)) - 1;
|
||||
reg &= (2u << (bitend - bitstart)) - 1;
|
||||
switch (*c)
|
||||
{
|
||||
case 'R':
|
||||
@ -835,7 +835,7 @@ print_insn_score16 (bfd_vma pc, struct disassemble_info *info, long given)
|
||||
|
||||
case '\'':
|
||||
c++;
|
||||
if ((given & (1 << bitstart)) != 0)
|
||||
if ((given & (1u << bitstart)) != 0)
|
||||
func (stream, "%c", *c);
|
||||
break;
|
||||
default:
|
||||
|
Loading…
x
Reference in New Issue
Block a user