ARM pseudo subvar: don't substitude [pc, reg]

This commit is contained in:
Zhang Zengbo 2022-07-20 17:09:50 +08:00 committed by Riccardo Schirone
parent 6b7ea38969
commit 3b9e823db7
2 changed files with 14 additions and 10 deletions

View file

@ -290,16 +290,20 @@ static bool subvar(RzParse *p, RzAnalysisFunction *f, RzAnalysisOp *op, char *da
if (!ripend) {
ripend = "]";
}
if (neg) {
repl_num -= rz_num_get(NULL, neg + 1);
} else {
repl_num += rz_num_get(NULL, rip);
const char *maybe_num = neg ? neg + 1 : rip;
maybe_num = rz_str_trim_head_ro(maybe_num);
if (rz_is_valid_input_num_value(NULL, maybe_num)) {
if (neg) {
repl_num -= rz_num_get(NULL, maybe_num);
} else {
repl_num += rz_num_get(NULL, maybe_num);
}
rip -= 3;
*rip = 0;
tstr_new = rz_str_newf("%s0x%08" PFMT64x "%s", tstr, repl_num, ripend);
free(tstr);
tstr = tstr_new;
}
rip -= 3;
*rip = 0;
tstr_new = rz_str_newf("%s0x%08" PFMT64x "%s", tstr, repl_num, ripend);
free(tstr);
tstr = tstr_new;
}
}

View file

@ -11,7 +11,7 @@ pdr~case
EOF
EXPECT=<<EOF
| 0x00000008 bhs case.0xa.0
| 0x0000000a switch.0x000 tbb [0x00000010] ; switch table (6 cases) at 0xe
| 0x0000000a switch.0x000 tbb [pc, r0] ; switch table (6 cases) at 0xe
| 0x00000014 case.0xa.2: ldr r0, [0x00000050] ; [0x50:4]=0x200001a1
| 0x0000001a beq case.0xa.0
| 0x0000002a case.0xa.3: movs r0, 0