unicorn
unicorn copied to clipboard
Behaviour change with emu_start stop address between Unicorn 1 and 2
The following code does not behave the same depending on Unicorn version:
- with Unicorn 2, this code returns "intno == 3".
- with Unicorn 1, this code returns nothing.
import unicorn as uc
def intr_hook(uci, intno, data):
if intno == 3:
print("intno == 3") # only happens with Unicorn 2
uci.emu_stop()
else:
print("other")
emu = uc.Uc(uc.UC_ARCH_ARM, uc.UC_MODE_THUMB | uc.UC_MODE_MCLASS)
known_regs = [i[len('UC_ARM_REG_'):] for i in dir(uc.arm_const) if '_REG' in i]
reg_map = {r.lower(): getattr(uc.arm_const, 'UC_ARM_REG_'+r) for r in known_regs}
assert not emu.mem_map(0xfffffc00, 0x400)
emu.hook_add(uc.UC_HOOK_INTR, intr_hook)
assert not emu.mem_map(0x10000, 0x400)
assert not emu.mem_map(0x0, 0x400)
assert not emu.mem_write(0x10000, b"\x00\xb5\x00\xbd") # push {lr}; pop {pc}
assert not emu.reg_write(reg_map["lr"], 0)
assert not emu.emu_start(0x10000 | 1, 0)
Is this expected?
Yes, according to arm doc here: https://developer.arm.com/documentation/ddi0403/d/System-Level-Architecture/System-Address-Map/The-system-address-map?lang=en
0xfffffc00 is an address in XN, which means trying to execute on that address will generate a fault as you see.
*Note uc1 is too old to have a working arm MMU.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.