diff --git a/tools/run.py b/tools/run.py index 77b6538d41c..8530d422f86 100755 --- a/tools/run.py +++ b/tools/run.py @@ -21,6 +21,16 @@ if cmd and cmd[0] == '--redirect-stdout': kwargs = dict(stdout=subprocess.PIPE) cmd = cmd[2:] +# --- POC harness: run ia32 ELF binaries under qemu-i386 on x64 host. --- +try: + with open(cmd[0], 'rb') as _f: + _hdr = _f.read(20) + if _hdr[:4] == b'\x7fELF' and _hdr[4] == 1 and _hdr[18] == 3: # ELFCLASS32, EM_386 + cmd = ['/tmp/qemu-i386-static', '-L', '/tmp/i386-rt/root'] + cmd +except (OSError, IndexError): + pass +# ----------------------------------------------------------------------- + process = subprocess.Popen(cmd, **kwargs) stdout, _ = process.communicate() if stdout_file: