I build a Docker container from the following Dockerfile:
FROM ubuntu:20.04
RUN apt-get update && apt-get -y install clang gcc-aarch64-linux-gnu
I'm on an x86_64 macOS v10.15.7 host system which means the Docker container will see an x86_64 CPU which I confirm by running this command inside the container:
$ lscpu
Architecture: x86_64
# remaining output omitted for brevity
I then compile and run an aarch64 assembly program using the following commands from inside the container:
$ clang -nostdlib -fno-integrated-as -target aarch64-linux-gnu -s hello_world.s -o hello_world.out
$ file hello_world.out
hello_world.out: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, BuildID[sha1]=a4622c2802958a4c37ae82ec21f510e9f823ca4a, stripped
$ ./hello_world.out
Hello world!
My question is: how does this work? How can I run an aarch64 ELF file on x86_64 Ubuntu? QEMU is not installed so what is providing the aarch64-to-x86_64 emulation layer? Is this maybe some feature of Docker or the underlying macOS host system?
0 Answers