Properly set anal.roregs for x27

This commit is contained in:
pancake committed 2026-07-07 16:15:27 +02:00
1 parent f680d5551a
commit 48736a2a89
4 files changed
+10 -3

No files matched your search

+3
View File
@@ -1153,6 +1153,9 @@ script behavior for local SDK checkouts.
serialized ObjectPool payload physical offset plus the current binary base.
That address is useful after the `-r -p` script maps a malloc-backed ObjectPool
image and sets `anal.gp`/`x27`, but it should not be required for xref recovery.
The r2 setup script must clear `anal.roregs` before `dr x27=...` and then
restore `anal.roregs=x27,gp,zero`; otherwise radare2 refuses to update `x27`
when it is already marked read-only.
For xrefs, prefer resolving collected PP offsets against the serialized
ObjectPool fill payload (`DartPpInfo.paddr` / `source_addr`) and then walking
+2 -2
View File
@@ -452,8 +452,8 @@ The `-R` path emits:
- `PP=x27`; per-function PP offset helper scanning is intentionally skipped by
default in script output because it is too slow on large apps
- `-r -p` is the focused PP setup path: it opens a malloc map at the synthetic
PP base, writes the reconstructed ObjectPool image, and sets `e anal.gp` plus
`dr x27`
PP base, writes the reconstructed ObjectPool image, sets `e anal.gp`, clears
`anal.roregs` before assigning `x27`, then restores `anal.roregs=x27,gp,zero`
## Practical Limits
+2
View File
@@ -1103,7 +1103,9 @@ static char *dump_pp_r2(const DartPpInfo *info, bool quiet) {
r_strbuf_appendf (sb, "s 0x%" PFMT64x "\n", info->base);
r_strbuf_appendf (sb, "wx %s\n", hex);
r_strbuf_appendf (sb, "e anal.gp=0x%" PFMT64x "\n", info->base);
r_strbuf_append (sb, "e anal.roregs=\n");
r_strbuf_appendf (sb, "dr x27=0x%" PFMT64x "\n", info->base);
r_strbuf_append (sb, "e anal.roregs=x27,gp,zero\n");
r_strbuf_appendf (sb, "f PP = 0x%" PFMT64x "\n", info->base);
r_strbuf_appendf (sb, "f dart.pp 0x%" PFMT64x " @ 0x%" PFMT64x "\n", info->size, info->base);
r_strbuf_appendf (sb, "f dart.pp.entries 0x%" PFMT64x " @ 0x%" PFMT64x "\n", info->entry_bits_offset - info->entries_offset, info->base + info->entries_offset);
+3 -1
View File
@@ -21,12 +21,14 @@ RUN
NAME=pp-r2-android
FILE=-
CMDS=<<EOF
!!../bin/r2flutter -q -r -p bins/android/mafia 2>/dev/null | grep -E '^(o malloc://|e anal[.]gp=|dr x27=|f PP =|f dart[.]pp )'
!!../bin/r2flutter -q -r -p bins/android/mafia 2>/dev/null | grep -E '^(o malloc://|e anal[.]gp=|dr anal[.]roregs=|dr x27=|f PP =|f dart[.]pp )'
EOF
EXPECT=<<EOF
o malloc://0x66548 0x385154 rw
e anal.gp=0x385154
dr anal.roregs=
dr x27=0x385154
dr anal.roregs=x27,gp,zero
f PP = 0x385154
f dart.pp 0x66548 @ 0x385154
EOF