by monus on 12/9/20, 10:27 AM with 4 comments
I know that's possible with recompiling from the source code, for example with Go, but I was wondering why can't we do this for arbitrary binaries? Are the calls not apparent in the binary form? From what I can tell Rosetta 2 does a similar thing when you run amd64 app on M1 for the first time[1]. What prevents us to have such a tool for all architectures? For example, I'd like to run an arbitrary amd64 binary on a RISC-V core without recompiling the source code.
[1]: https://www.computerworld.com/article/3597949/everything-you-need-to-know-about-rosetta-2-on-apple-silicon-macs.html
by tlb on 12/9/20, 10:48 AM
- Only executable code should be translated, data shouldn't be. Sometimes (like with jump tables) they are ambiguous.
- Different CPUs have different memory consistency models for parallel threads, leading to race conditions when translating
- Special instruction sets like AVX can be hard to translate
- Anything with a JIT compiler (including most web browsers) needs special handling.
That said, qemu works for the great majority of emulated & host CPUs.