Run AMD64 Linux elf binaries on Windows, Linux, MacOS on arbitrary ISAs. Also, run x64 Linux elf binaries on Windows, Linux, MacOS on arbitrary ISAs.
The x64os emulator runs binaries built for an AMD64 Linux machine on other machines. The x32os emulator runs binaries built for an x86 Linux machine on other machines.
Only a subset of the Linux syscalls are implemented including memory allocation and file I/O.
AMD64 emulation is limited to real-mode 64-bit long mode only. Integer, x87, and SSE2 instructions are partially implemented. Other vector extensions including MMX and AVX are not implemented. The only instructions implemented are those used by glibc and those generated by the gcc, clang, Rust, and gfortran compilers at various optimization levels for the test cases that are part of this repo.
x64 emulation has similar limitations -- real-mode only and just the subset of instructions required to run the test suite.
80-bit x87 floating point works via software emulation or emulation built on native amd64/x64 x87 if the gnu g++ compiler is used on x86 or amd64.
Files:
- x64os.cxx + linuxem.h: Main app that loads ELF binaries and provides basic Linux syscall emulation
- x64.cxx + x64.hxx: AMD64 and 32-bit x86 emulation
- *.hxx: support functionality
- x87.hxx and f80_double.h: x87 emulation helpers written by ChatGPT 5.2.
- m.bat, mr.bat, m32.bat m32r.bat: builds x64os and x32os for release and debug using msvc on Windows
- mg.bat, mgr.bat, m32g.bat m32gr.bat: builds x64os and x32os for release and debug using gcc on Windows
- m.sh, mr.sh, m32.sh m32r.sh: builds x64os and x32os for release and debug using gcc on Linux
- mrmac.sh and m32rmac.sh build on macOS
Test folders:
- c_tests: a variety of assembly and C test cases with scripts to build with gcc and clang at optimization levels 0, 1, 2, 3, and fast
- f_tests: a varity of GNU Fortran test cases and scripts to build them
- rust_tests: a varity of Rust test cases with scripts to build at optimization levels 0, 1, 2, and 3.
- ow: build and test scripts for Open Watcom 2.0 on Windows and Linux. Builds and runs a subset of tests in c_tests in x32os
I've only validated x32os with the c_tests and Fortran test cases, not Rust. I've validated x64os with some Zig apps as well.
Go apps won't run since the Go runtime requires at least 5 threads and this emulator only supports one.
In addition to the test cases above, all of the test cases were run in x64os and x32os built for Sparc v8, 68000, Arm64, and RISC-V64 in emulators for each of those ISAs. Those can be found in sister repos sparcos, m68, armos, and rvos. x64os and x32os were also tested recursively by running itself running each test case.
Also, each of the emulators mentioned above were built for AMD64 and run nested in x64os and x32os with all of their respective test cases for validation.
These emulators were built and tested on AMD64, Arm64, Arm32, x86, and RISC-V 64 physical hardware including standard Windows/Linux AMD64 machines, Arm64 Windows/Linux, Raspberry PI 5, 32-bit Raspberry PI 4, an M3 macBook, and a RISC-V 64 SBC.
This emulator is about 2x slower than other 64- and 32-bit emulators in sister repos because AMD/Intel instruction decoding is complex.
0 comments
log in to comment.