opcodes: blackfin: handle memory read errors
The current code ignores memory read errors which isn't a great idea. So add a helper function which takes care of error checking and update the code to use that. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
This commit is contained in:
parent
63e1777c6c
commit
ba32981791
@ -1,3 +1,9 @@
|
|||||||
|
2014-08-13 Mike Frysinger <vapier@gentoo.org>
|
||||||
|
|
||||||
|
* bfin-dis.c (ifetch): New function.
|
||||||
|
(_print_insn_bfin, print_insn_bfin): Call new ifetch and return
|
||||||
|
-1 when it errors.
|
||||||
|
|
||||||
2014-07-29 Matthew Fortune <matthew.fortune@imgtec.com>
|
2014-07-29 Matthew Fortune <matthew.fortune@imgtec.com>
|
||||||
|
|
||||||
* micromips-opc.c (COD): Rename throughout to...
|
* micromips-opc.c (COD): Rename throughout to...
|
||||||
|
@ -4639,24 +4639,42 @@ decode_pseudodbg_assert_0 (TIword iw0, TIword iw1, disassemble_info *outf)
|
|||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
ifetch (bfd_vma pc, disassemble_info *outf, TIword *iw)
|
||||||
|
{
|
||||||
|
bfd_byte buf[2];
|
||||||
|
int status;
|
||||||
|
|
||||||
|
status = (*outf->read_memory_func) (pc & ~0x01, buf, 2, outf);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
(*outf->memory_error_func) (status, pc, outf);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*iw = bfd_getl16 (buf);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_print_insn_bfin (bfd_vma pc, disassemble_info *outf)
|
_print_insn_bfin (bfd_vma pc, disassemble_info *outf)
|
||||||
{
|
{
|
||||||
bfd_byte buf[4];
|
|
||||||
TIword iw0;
|
TIword iw0;
|
||||||
TIword iw1;
|
TIword iw1;
|
||||||
int status;
|
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
status = (*outf->read_memory_func) (pc & ~0x1, buf, 2, outf);
|
if (ifetch (pc, outf, &iw0))
|
||||||
/* FIXME */
|
return -1;
|
||||||
(void) status;
|
|
||||||
status = (*outf->read_memory_func) ((pc + 2) & ~0x1, buf + 2, 2, outf);
|
|
||||||
/* FIXME */
|
|
||||||
(void) status;
|
|
||||||
|
|
||||||
iw0 = bfd_getl16 (buf);
|
if ((iw0 & 0xc000) == 0xc000)
|
||||||
iw1 = bfd_getl16 (buf + 2);
|
{
|
||||||
|
/* 32-bit insn. */
|
||||||
|
if (ifetch (pc + 2, outf, &iw1))
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/* 16-bit insn. */
|
||||||
|
iw1 = 0;
|
||||||
|
|
||||||
if ((iw0 & 0xf7ff) == 0xc003 && iw1 == 0x1800)
|
if ((iw0 & 0xf7ff) == 0xc003 && iw1 == 0x1800)
|
||||||
{
|
{
|
||||||
@ -4752,17 +4770,15 @@ _print_insn_bfin (bfd_vma pc, disassemble_info *outf)
|
|||||||
int
|
int
|
||||||
print_insn_bfin (bfd_vma pc, disassemble_info *outf)
|
print_insn_bfin (bfd_vma pc, disassemble_info *outf)
|
||||||
{
|
{
|
||||||
bfd_byte buf[2];
|
TIword iw0;
|
||||||
unsigned short iw0;
|
int count;
|
||||||
int status;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
status = (*outf->read_memory_func) (pc & ~0x01, buf, 2, outf);
|
if (ifetch (pc, outf, &iw0) == -1)
|
||||||
/* FIXME */
|
return -1;
|
||||||
(void) status;
|
|
||||||
iw0 = bfd_getl16 (buf);
|
|
||||||
|
|
||||||
count += _print_insn_bfin (pc, outf);
|
count = _print_insn_bfin (pc, outf);
|
||||||
|
if (count == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
/* Proper display of multiple issue instructions. */
|
/* Proper display of multiple issue instructions. */
|
||||||
|
|
||||||
@ -4775,10 +4791,14 @@ print_insn_bfin (bfd_vma pc, disassemble_info *outf)
|
|||||||
parallel = 1;
|
parallel = 1;
|
||||||
OUTS (outf, " || ");
|
OUTS (outf, " || ");
|
||||||
len = _print_insn_bfin (pc + 4, outf);
|
len = _print_insn_bfin (pc + 4, outf);
|
||||||
|
if (len == -1)
|
||||||
|
return -1;
|
||||||
OUTS (outf, " || ");
|
OUTS (outf, " || ");
|
||||||
if (len != 2)
|
if (len != 2)
|
||||||
legal = 0;
|
legal = 0;
|
||||||
len = _print_insn_bfin (pc + 6, outf);
|
len = _print_insn_bfin (pc + 6, outf);
|
||||||
|
if (len == -1)
|
||||||
|
return -1;
|
||||||
if (len != 2)
|
if (len != 2)
|
||||||
legal = 0;
|
legal = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user