'How to load raw binary into Qemu

As all information I found about Qemu is related to Linux kernel, uboot or elf binaries I can't quite figure out how to load a binary blob from an embedded device into a specific address and execute part of it. The code I want to run does only arithmetics, so there are no hardware dependencies involved.

I would start qemu with something like

qemu-arm -singlestep -g8000

attach gdb, set initial register state and jump to my starting address to single step through it.

But how do I initially load binary data to a specific address and eventually set up an additional ram range?



Solution 1:[1]

It's in fact easy with the Unicorn framework which works on top of Qemu. Based on the example in the websites doc section I wrote a Python script which loads the data, sets the registers, adds a hook which prints important per step information and start execution at the desired address until a target address.

Solution 2:[2]

how to load a binary blob from an embedded device into a specific address and execute part of it.

You can load binary blob into softmmu QEMU by the generic loader (-device loader).

I would start qemu with something like qemu-arm -singlestep -g8000

This command line is for the linux-user QEMU invocation. It emulates userspace linux process of the guest architecture, it is unprivileged and does not provide support for any devices, including generic loader. Try using qemu-system-arm instead.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 user2011659
Solution 2 muradm