qilingframework / qiling

A True Instrumentable Binary Emulation Framework
https://qiling.io
GNU General Public License v2.0
5.11k stars 742 forks source link

QlArchARM object has no attribute unicorn_exception_handler during ARM Cortex-M emulation #1478

Open thdemarty opened 3 months ago

thdemarty commented 3 months ago

Describe the bug When attempting to emulate a bare-metal ARM program for Cortex-M using Qiling, the following error occurs: AttributeError: 'QlArchARM' object has no attribute 'unicorn_exception_handler'.

Sample Code

from qiling import Qiling
from qiling.const import *

ELF_FILE_PATH = "my-application.axf"
ROOT_FS_PATH = "./rootfs"

ql = Qiling([ELF_FILE_PATH], ROOT_FS_PATH, archtype=QL_ARCH.ARM, ostype=QL_OS.MCU, verbose=QL_VERBOSE.DEBUG)
ql.run()

Expected behavior The Qiling emulator should successfully initialize and run the provided ARM Cortex-M ELF file without raising an AttributeError.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

elicn commented 3 months ago

Hi there and welcome to Qiling. Can you please provide the relevant error message from the logs?

thdemarty commented 3 months ago

Hello,

Here is the full traceback when executing the program :

[+]     Profile: default
Traceback (most recent call last):
  File "/home/me/emulation/qiling_emulation.py", line 15, in <module>
    ql = Qiling([ELF_FILE_PATH], ROOT_FS_PATH, archtype=QL_ARCH.ARM, ostype=QL_OS.MCU, verbose=QL_VERBOSE.DEBUG)
  File "/home/me/emulation/env/lib/python3.10/site-packages/qiling/core.py", line 190, in __init__
    self.loader.run()
  File "/home/me/emulation/env/lib/python3.10/site-packages/qiling/loader/mcu.py", line 136, in run
    self.ql.hook_intr(self.ql.arch.unicorn_exception_handler)
AttributeError: 'QlArchARM' object has no attribute 'unicorn_exception_handler'

'QlArchARM' object has no attribute 'unicorn_exception_handler'
elicn commented 3 months ago

archtype=QL_ARCH.ARM is not supported for MCU; try archtype=QL_ARCH.CORTEX_M instead