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>
diff --git a/scripts/qemu-machine-hack.py b/scripts/qemu-machine-hack.py
new file mode 100644
index 0000000..1412ed8
--- /dev/null
+++ b/scripts/qemu-machine-hack.py
@@ -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()
+