mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-27 06:17:47 +08:00
Prevent more potential illegal memory accesses in the RX disassembler.
* rx-dis.c (get_size_name): New function. Provides safe access to name array. (get_opsize_name): Likewise. (print_insn_rx): Use the accessor functions.
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
2019-10-22 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
|
* rx-dis.c (get_size_name): New function. Provides safe
|
||||||
|
access to name array.
|
||||||
|
(get_opsize_name): Likewise.
|
||||||
|
(print_insn_rx): Use the accessor functions.
|
||||||
|
|
||||||
2019-10-16 Nick Clifton <nickc@redhat.com>
|
2019-10-16 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* rx-dis.c (get_register_name): New function. Provides safe
|
* rx-dis.c (get_register_name): New function. Provides safe
|
||||||
|
@ -195,6 +195,22 @@ get_double_condition_name (unsigned int cond)
|
|||||||
return _("<inavlid condition code>");
|
return _("<inavlid condition code>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const char *
|
||||||
|
get_opsize_name (unsigned int opsize)
|
||||||
|
{
|
||||||
|
if (opsize < ARRAY_SIZE (opsize_names))
|
||||||
|
return opsize_names[opsize];
|
||||||
|
return _("<inavlid opsize>");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline const char *
|
||||||
|
get_size_name (unsigned int size)
|
||||||
|
{
|
||||||
|
if (size < ARRAY_SIZE (size_names))
|
||||||
|
return size_names[size];
|
||||||
|
return _("<inavlid size>");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
print_insn_rx (bfd_vma addr, disassemble_info * dis)
|
print_insn_rx (bfd_vma addr, disassemble_info * dis)
|
||||||
@ -278,14 +294,16 @@ print_insn_rx (bfd_vma addr, disassemble_info * dis)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
PR (PS, "%s", opsize_names[opcode.size]);
|
PR (PS, "%s", get_opsize_name (opcode.size));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'b':
|
case 'b':
|
||||||
s ++;
|
s ++;
|
||||||
if (*s == 'f') {
|
if (*s == 'f')
|
||||||
|
{
|
||||||
int imm = opcode.op[2].addend;
|
int imm = opcode.op[2].addend;
|
||||||
int slsb, dlsb, width;
|
int slsb, dlsb, width;
|
||||||
|
|
||||||
dlsb = (imm >> 5) & 0x1f;
|
dlsb = (imm >> 5) & 0x1f;
|
||||||
slsb = (imm & 0x1f);
|
slsb = (imm & 0x1f);
|
||||||
slsb = (slsb >= 0x10?(slsb ^ 0x1f) + 1:slsb);
|
slsb = (slsb >= 0x10?(slsb ^ 0x1f) + 1:slsb);
|
||||||
@ -294,8 +312,8 @@ print_insn_rx (bfd_vma addr, disassemble_info * dis)
|
|||||||
width = ((imm >> 10) & 0x1f) - dlsb;
|
width = ((imm >> 10) & 0x1f) - dlsb;
|
||||||
PR (PS, "#%d, #%d, #%d, %s, %s",
|
PR (PS, "#%d, #%d, #%d, %s, %s",
|
||||||
slsb, dlsb, width,
|
slsb, dlsb, width,
|
||||||
register_names[opcode.op[1].reg],
|
get_register_name (opcode.op[1].reg),
|
||||||
register_names[opcode.op[0].reg]);
|
get_register_name (opcode.op[0].reg));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '0':
|
case '0':
|
||||||
@ -305,7 +323,7 @@ print_insn_rx (bfd_vma addr, disassemble_info * dis)
|
|||||||
if (do_size)
|
if (do_size)
|
||||||
{
|
{
|
||||||
if (oper->type == RX_Operand_Indirect || oper->type == RX_Operand_Zero_Indirect)
|
if (oper->type == RX_Operand_Indirect || oper->type == RX_Operand_Zero_Indirect)
|
||||||
PR (PS, "%s", size_names[oper->size]);
|
PR (PS, "%s", get_size_name (oper->size));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
switch (oper->type)
|
switch (oper->type)
|
||||||
|
Reference in New Issue
Block a user