Skip to content

Commit

Permalink
Use codeAlign instead of dataAlign for thumb stepping ##emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
radare authored and trufae committed Jun 22, 2024
1 parent 87dc31f commit 220b849
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libr/core/anal_tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ R_API void r_core_anal_type_match(RCore *core, RAnalFunction *fcn) {
// eprintf ("STEP 0x%"PFMT64x"\n", addr);
int res = r_core_esil_step (core, UT64_MAX, NULL, NULL, false);
if (breakoninvalid && !res) {
R_LOG_ERROR ("step failed at 0x%08"PFMT64x"\n", addr);
R_LOG_ERROR ("step failed at 0x%08"PFMT64x, addr);
retries--;
goto repeat;
}
Expand Down
17 changes: 15 additions & 2 deletions libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6716,7 +6716,8 @@ R_API int r_core_esil_step(RCore *core, ut64 until_addr, const char *until_expr,
ut64 addr = -1;
ut64 oaddr = -1;
int minopsz = r_arch_info (core->anal->arch, R_ARCH_INFO_MINOP_SIZE);
int dataAlign = r_anal_archinfo (esil->anal, R_ARCH_INFO_DATA_ALIGN);
// int dataAlign = r_anal_archinfo (esil->anal, R_ARCH_INFO_DATA_ALIGN);
int codeAlign = r_anal_archinfo (esil->anal, R_ARCH_INFO_CODE_ALIGN);
ut64 naddr = addr + minopsz;
bool notfirst = false;
if (maxopsz > sizeof (code)) {
Expand Down Expand Up @@ -6770,17 +6771,29 @@ R_API int r_core_esil_step(RCore *core, ut64 until_addr, const char *until_expr,
return_tail (1);
}
}
#if 0
if (dataAlign > 1) {
if (addr % dataAlign) {
if (esil->cmd && R_STR_ISNOTEMPTY (esil->cmd_trap)) {
esil->cmd (esil, esil->cmd_trap, addr, R_ANAL_TRAP_UNALIGNED);
}
if (breakoninvalid) {
R_LOG_INFO ("Execution stopped on unaligned instruction (see e?esil.breakoninvalid)");
R_LOG_INFO ("Execution stopped on unaligned %d instruction (see e?esil.breakoninvalid)", dataAlign);
return_tail (0);
}
}
}
#else
if (codeAlign > 1 && addr % codeAlign) {
if (esil->cmd && R_STR_ISNOTEMPTY (esil->cmd_trap)) {
esil->cmd (esil, esil->cmd_trap, addr, R_ANAL_TRAP_UNALIGNED);
}
if (breakoninvalid) {
R_LOG_INFO ("Execution stopped on unaligned %d instruction (see e?esil.breakoninvalid)", codeAlign);
return_tail (0);
}
}
#endif
int re = r_io_read_at (core->io, addr, code, maxopsz);
if (re < 1) {
ret = 0;
Expand Down

0 comments on commit 220b849

Please sign in to comment.