this post was submitted on 13 Jan 2025
152 points (92.2% liked)
Linux
49050 readers
725 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
If it coukd be baked before rather than at run time it feels like there might be some nuance there
It's a very difficult problem to solve.
Different architectures are more than just translating op codes. They have different ways to address memory, different types, sizes and number of registers. Compiled binaries use offsets within the code to jump, loop, etc. which all changes when you start changing instructions. It's much easier to emulate the platform at runtime.
No doubt. Software emulation of different arches is still magic to me. Being able to run qemu to run just one program on the CLI as an arm bin was so neat
It requires a near obsessive understanding of the architecture being emulated, but generally the process is "relatively straightforward" (though not necessarily "easy"). A CPU is a relatively simple device compared to the software built on it. Your basic steps are:
Throw that in a loop and voilà! You have an emulator. Granted I've handwaved over a lot of complexity (I don't mean to trivialize the effort)...
To translate a binary is very different. Compilers optimize output to behave in a specific way for the target CPU that simply may not work on the new CPU. What do you do, for example, if the code was compiled for a platform that had 12 registers but the new one only has 6? You'd need to re-write the logic to work with fewer registers. That's difficult to do in a way that is generic for any program. An emulator can just present the program with the 12 registers it expects (emulated in memory at the expense of performance).