NDS32 disassembly of odd sized sections
* nds32-dis.c (print_insn_nds32): Remove unnecessary casts. Initialize parts of buffer not written when handling a possible 2-byte insn at end of section. Don't attempt decoding of such an insn by the 4-byte machinery.
This commit is contained in:
parent
833d919c93
commit
fe90ae8a9f
|
@ -1,3 +1,10 @@
|
||||||
|
2020-03-20 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
|
* nds32-dis.c (print_insn_nds32): Remove unnecessary casts.
|
||||||
|
Initialize parts of buffer not written when handling a possible
|
||||||
|
2-byte insn at end of section. Don't attempt decoding of such
|
||||||
|
an insn by the 4-byte machinery.
|
||||||
|
|
||||||
2020-03-20 Alan Modra <amodra@gmail.com>
|
2020-03-20 Alan Modra <amodra@gmail.com>
|
||||||
|
|
||||||
* ppc-dis.c (print_insn_powerpc): Only clear needed bytes of
|
* ppc-dis.c (print_insn_powerpc): Only clear needed bytes of
|
||||||
|
|
|
@ -985,7 +985,7 @@ print_insn_nds32 (bfd_vma pc, disassemble_info *info)
|
||||||
int is_data = FALSE;
|
int is_data = FALSE;
|
||||||
bfd_boolean found = FALSE;
|
bfd_boolean found = FALSE;
|
||||||
struct nds32_private_data *private_data;
|
struct nds32_private_data *private_data;
|
||||||
unsigned int size = 16;
|
unsigned int size;
|
||||||
enum map_type mapping_type = MAP_CODE;
|
enum map_type mapping_type = MAP_CODE;
|
||||||
|
|
||||||
if (info->private_data == NULL)
|
if (info->private_data == NULL)
|
||||||
|
@ -1063,6 +1063,7 @@ print_insn_nds32 (bfd_vma pc, disassemble_info *info)
|
||||||
|
|
||||||
/* Fix corner case: there is no next mapping symbol,
|
/* Fix corner case: there is no next mapping symbol,
|
||||||
let mapping type decides size */
|
let mapping type decides size */
|
||||||
|
size = 16;
|
||||||
if (last_symbol_index + 1 >= info->symtab_size)
|
if (last_symbol_index + 1 >= info->symtab_size)
|
||||||
{
|
{
|
||||||
if (mapping_type == MAP_DATA0)
|
if (mapping_type == MAP_DATA0)
|
||||||
|
@ -1096,7 +1097,7 @@ print_insn_nds32 (bfd_vma pc, disassemble_info *info)
|
||||||
size = (pc & 1) ? 1 : 2;
|
size = (pc & 1) ? 1 : 2;
|
||||||
|
|
||||||
/* Read bytes from BFD. */
|
/* Read bytes from BFD. */
|
||||||
info->read_memory_func (pc, (bfd_byte *) buf_data, size, info);
|
info->read_memory_func (pc, buf_data, size, info);
|
||||||
given = 0;
|
given = 0;
|
||||||
given1 = 0;
|
given1 = 0;
|
||||||
/* Start assembling data. */
|
/* Start assembling data. */
|
||||||
|
@ -1153,16 +1154,20 @@ print_insn_nds32 (bfd_vma pc, disassemble_info *info)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = info->read_memory_func (pc, (bfd_byte *) buf, 4, info);
|
size = 4;
|
||||||
|
status = info->read_memory_func (pc, buf, 4, info);
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
/* For the last 16-bit instruction. */
|
/* For the last 16-bit instruction. */
|
||||||
status = info->read_memory_func (pc, (bfd_byte *) buf, 2, info);
|
size = 2;
|
||||||
|
status = info->read_memory_func (pc, buf, 2, info);
|
||||||
if (status)
|
if (status)
|
||||||
{
|
{
|
||||||
(*info->memory_error_func)(status, pc, info);
|
(*info->memory_error_func) (status, pc, info);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
buf[2] = 0;
|
||||||
|
buf[3] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
insn = bfd_getb32 (buf);
|
insn = bfd_getb32 (buf);
|
||||||
|
@ -1174,11 +1179,12 @@ print_insn_nds32 (bfd_vma pc, disassemble_info *info)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 32-bit instructions. */
|
/* 32-bit instructions. */
|
||||||
|
if (size == 4)
|
||||||
|
print_insn32 (pc, info, insn, NDS32_PARSE_INSN32);
|
||||||
else
|
else
|
||||||
{
|
info->fprintf_func (info->stream,
|
||||||
print_insn32 (pc, info, insn, NDS32_PARSE_INSN32);
|
_("insufficient data to decode instruction"));
|
||||||
return 4;
|
return 4;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Ignore disassembling unnecessary name. */
|
/* Ignore disassembling unnecessary name. */
|
||||||
|
|
Loading…
Reference in New Issue