HACK: qemu: change e_machine for IAMCU binaries
For some strange reason IAMCU sets e_machine to 0x06 which causes QEMU to freak out. This is just x86 code with a different C calling convention, hack it back to 0x03 (EM_386) before running under the emulator. Change-Id: Ia5d51b771cad41f3013eb3d6a17912c8909c9bac Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
0509bf155b
commit
e79c960dd8
2 changed files with 12 additions and 0 deletions
1
Makefile
1
Makefile
|
@ -1136,6 +1136,7 @@ endif
|
||||||
qemu: zephyr
|
qemu: zephyr
|
||||||
$(if $(QEMU_PIPE),,@echo "To exit from QEMU enter: 'CTRL+a, x'")
|
$(if $(QEMU_PIPE),,@echo "To exit from QEMU enter: 'CTRL+a, x'")
|
||||||
@echo '[QEMU] CPU: $(QEMU_CPU_TYPE_$(ARCH))'
|
@echo '[QEMU] CPU: $(QEMU_CPU_TYPE_$(ARCH))'
|
||||||
|
$(if $(CONFIG_X86_IAMCU),python $(ZEPHYR_BASE)/scripts/qemu-machine-hack.py $(KERNEL_ELF_NAME))
|
||||||
$(Q)$(QEMU) $(QEMU_FLAGS) $(QEMU_EXTRA_FLAGS) -kernel $(KERNEL_ELF_NAME)
|
$(Q)$(QEMU) $(QEMU_FLAGS) $(QEMU_EXTRA_FLAGS) -kernel $(KERNEL_ELF_NAME)
|
||||||
|
|
||||||
-include $(srctree)/boards/$(BOARD_NAME)/Makefile.board
|
-include $(srctree)/boards/$(BOARD_NAME)/Makefile.board
|
||||||
|
|
11
scripts/qemu-machine-hack.py
Normal file
11
scripts/qemu-machine-hack.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# For some baffling reason IAMCU sets the instruction set architecture
|
||||||
|
# in the ELF header to 0x06 instead of 0x03 even though it is just
|
||||||
|
# 386 code. This gives QEMU fits. Hack it!
|
||||||
|
fd = open(sys.argv[1], "r+b")
|
||||||
|
fd.seek(0x12)
|
||||||
|
# Write 0x03 which is EM_386 to e_machine
|
||||||
|
fd.write(b'\x03')
|
||||||
|
fd.close()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue