I compiled a simple "Hello World" C program on Raspberry Pi 3, which was then transferred to an AMD64 laptop. Out of curiosity, I executed it, and it runs even though I did not expect it to:
$ uname -a
Linux 15ud490-gx76k 6.5.0-25-generic #25~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue Feb 20 16:09:15 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
$ file hello64
hello64: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=486ee1cde035cd704b49c037a32fb77239b6a1c2, for GNU/Linux 3.7.0, not stripped
$ ./hello64
Hello World!
Like that, how can it execute?
QEMU User Emulation is installed, but I don't know whether it is playing a part in this or not.
qemu-user-binfmt
, which IIRC gets pulled in by default if you install either the regular or statically linked user-mode emulation binaries, and the package enables this functionality by default when installed. – Austin Hemmelgarn Mar 10 '24 at 17:42qemu-user-static
(see this previous answer, also linked in the answer, for details).qemu-user-static
does its own registration;qemu-user-binfmt
is only used withqemu-user
. – Stephen Kitt Mar 10 '24 at 17:52