Skip to content

Commit

Permalink
i#2491 ARM unallocated encodings: Better handling of undecoded instrs.
Browse files Browse the repository at this point in the history
In check_encode_decode_consistency(), do not try to reencode an
OP_UNDECODED instruction.

In instr_encode_arch(), use instr->opcode, not instr_get_opcode(instr),
as the latter can call the decoder, which is unhelpful when we are
trying to encode.

Fixes #2491

Change-Id: I66c42dc87268f1722eae4600b364026896796fc8
  • Loading branch information
egrimley-arm committed Jul 4, 2017
1 parent 32374b2 commit 023c4c4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions core/arch/arm/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2893,8 +2893,12 @@ check_encode_decode_consistency(dcontext_t *dcontext, instrlist_t *ilist)
byte buf[THUMB_LONG_INSTR_SIZE];
instr_t tmp;
byte *pc, *npc;
app_pc addr = instr_get_raw_bits(check);
int check_len = instr_length(dcontext, check);
app_pc addr;
int check_len;
if (check->opcode == OP_UNDECODED)
continue;
addr = instr_get_raw_bits(check);
check_len = instr_length(dcontext, check);
instr_set_raw_bits_valid(check, false);
pc = instr_encode_to_copy(dcontext, check, buf, addr);
instr_init(dcontext, &tmp);
Expand Down
2 changes: 1 addition & 1 deletion core/arch/arm/encode.c
Original file line number Diff line number Diff line change
Expand Up @@ -2766,7 +2766,7 @@ instr_encode_arch(dcontext_t *dcontext, instr_t *instr, byte *copy_pc, byte *fin
}

decode_info_init_for_instr(&di, instr);
di.opcode = instr_get_opcode(instr);
di.opcode = instr->opcode;
di.check_reachable = check_reachable;
di.start_pc = copy_pc;
di.final_pc = final_pc;
Expand Down

0 comments on commit 023c4c4

Please sign in to comment.