Skip to content

Commit

Permalink
Fix ao@jmp modifying ar~^pc ##analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Jan 28, 2025
1 parent 4e0d253 commit 410054d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libr/core/cmd_anal.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2323,6 +2323,14 @@ static bool mw(REsil *esil, ut64 addr, const ut8 *buf, int len) {
return true;
}

static bool rw(REsil *esil, const char *regname, ut64 num) {
return true;
}

static bool rr(REsil *esil, const char *regname, ut64 *num, int *size) {
return true;
}

static bool mr(REsil *esil, ut64 addr, ut8 *buf, int len) {
int *ec = (int*)esil->user;
*ec += len;
Expand All @@ -2339,6 +2347,8 @@ static int esil_cost(RCore *core, ut64 addr, const char *expr) {
e->user = &ec;
e->cb.mem_read = mr;
e->cb.mem_write = mw;
e->cb.reg_write = rw;
e->cb.reg_read = rr;
r_esil_parse (e, expr);
r_esil_free (e);
return ec;
Expand Down
17 changes: 17 additions & 0 deletions test/db/cmd/cmd_ao
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,20 @@ EXPECT=<<EOF
]
EOF
RUN


NAME=araoar
FILE=bins/mach0/mac-ls4
ARGS=-a arm -b 64
CMDS=<<EOF
ar PC=entry0
ar~^pc
ao @ 0x100003ba0~type
ar~^pc
EOF
EXPECT=<<EOF
pc = 0x100003a90
type: jmp
pc = 0x100003a90
EOF
RUN

0 comments on commit 410054d

Please sign in to comment.