diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog index df17f550a9..2f5c6c918a 100644 --- a/opcodes/ChangeLog +++ b/opcodes/ChangeLog @@ -1,3 +1,11 @@ +2016-12-12 Yao Qi + + * rx-dis.c: Include + (struct private): New. + (rx_get_byte): Check return value of read_memory_func, and + call memory_error_func and OPCODES_SIGLONGJMP on error. + (print_insn_rx): Call OPCODES_SIGSETJMP. + 2016-12-12 Yao Qi * rl78-dis.c: Include . diff --git a/opcodes/rx-dis.c b/opcodes/rx-dis.c index b0ff4b3697..5f2bf352ff 100644 --- a/opcodes/rx-dis.c +++ b/opcodes/rx-dis.c @@ -27,22 +27,38 @@ #include "dis-asm.h" #include "opcode/rx.h" +#include + typedef struct { bfd_vma pc; disassemble_info * dis; } RX_Data; +struct private +{ + OPCODES_SIGJMP_BUF bailout; +}; + static int rx_get_byte (void * vdata) { bfd_byte buf[1]; RX_Data *rx_data = (RX_Data *) vdata; + int status; - rx_data->dis->read_memory_func (rx_data->pc, - buf, - 1, - rx_data->dis); + status = rx_data->dis->read_memory_func (rx_data->pc, + buf, + 1, + rx_data->dis); + if (status != 0) + { + struct private *priv = (struct private *) rx_data->dis->private_data; + + rx_data->dis->memory_error_func (status, rx_data->pc, + rx_data->dis); + OPCODES_SIGLONGJMP (priv->bailout, 1); + } rx_data->pc ++; return buf[0]; @@ -92,10 +108,18 @@ print_insn_rx (bfd_vma addr, disassemble_info * dis) RX_Data rx_data; RX_Opcode_Decoded opcode; const char * s; + struct private priv; + dis->private_data = (PTR) &priv; rx_data.pc = addr; rx_data.dis = dis; + if (OPCODES_SIGSETJMP (priv.bailout) != 0) + { + /* Error return. */ + return -1; + } + rv = rx_decode_opcode (addr, &opcode, rx_get_byte, &rx_data); dis->bytes_per_line = 10;