mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-10 23:55:40 +00:00
verify hardware mode for ARM. this fixes issue #16
This commit is contained in:
parent
cd072b4e20
commit
bb34eebd24
21
regress/wrong_sp_arm.py
Normal file → Executable file
21
regress/wrong_sp_arm.py
Normal file → Executable file
|
@ -3,7 +3,20 @@
|
|||
|
||||
from unicorn import *
|
||||
from unicorn.arm_const import *
|
||||
uc = Uc(UC_ARCH_ARM, UC_MODE_32)
|
||||
uc.reg_write(ARM_REG_SP, 4)
|
||||
print 'Writing 4 to SP'
|
||||
print 'SP =', uc.reg_read(ARM_REG_SP)
|
||||
|
||||
try:
|
||||
uc = Uc(UC_ARCH_ARM, UC_MODE_32)
|
||||
uc.reg_write(ARM_REG_SP, 4)
|
||||
print 'Writing 4 to SP'
|
||||
print 'SP =', uc.reg_read(ARM_REG_SP)
|
||||
except UcError as e:
|
||||
print("ERROR: %s" % e)
|
||||
|
||||
try:
|
||||
print "==========="
|
||||
uc = Uc(UC_ARCH_ARM, UC_MODE_ARM)
|
||||
uc.reg_write(ARM_REG_SP, 4)
|
||||
print 'Writing 4 to SP'
|
||||
print 'SP =', uc.reg_read(ARM_REG_SP)
|
||||
except UcError as e:
|
||||
print("ERROR: %s" % e)
|
||||
|
|
8
uc.c
8
uc.c
|
@ -177,6 +177,14 @@ uc_err uc_open(uc_arch arch, uc_mode mode, uch *handle)
|
|||
#ifdef UNICORN_HAS_ARM
|
||||
case UC_ARCH_ARM:
|
||||
uc->init_arch = arm_uc_init;
|
||||
|
||||
// verify mode
|
||||
if (mode != UC_MODE_ARM && mode != UC_MODE_THUMB) {
|
||||
*handle = 0;
|
||||
free(uc);
|
||||
return UC_ERR_MODE;
|
||||
}
|
||||
|
||||
if (mode == UC_MODE_THUMB)
|
||||
uc->thumb = 1;
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue