Master the fundamental concepts of arm assembly (aarch64) through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksCross-compilation targets a different ISA than the host CPU. Docker buildx and GitHub Actions arm64 runners use the same toolchain flow: aarch64-linux-gnu-gcc emits arm64 ELF, qemu-aarch64 translates instructions and forwards syscalls to the host kernel.
bashLoading…
Failures often show up as wrong syscall numbers or linker scripts meant for x86.
For this exercise, you will cross-assemble a small program and run it under QEMU. This task asks you to verify output matches native expectations, because Raspberry Pi OS images and arm64 containers on Docker Hub are built exactly this way when CI lacks bare metal.
Keep the relevant man page, ABI doc, or Rust reference chapter open while you work. When your output disagrees with the reference implementation on the same machine, the mismatch is usually an alignment rule, an off-by-one terminator, or a register slot you misread in GDB. Skim the official documentation for the tool or ABI named in the exercise; the prose changes, but register roles, syscall numbers, and ownership rules stay stable across releases.
Cross-development means building a binary on one machine for another, then running it under emulation: aarch64-linux-gnu-gcc -static hello.c -o hello && qemu-aarch64 ./hello. When a build hands you a mystery file, the first 32 bytes of its ELF header tell you everything you need: word size, byte order, file type, target machine and entry point. Write the file-plus-advice tool: decode the header, name the cross compiler that targets it, and say how to run it on the current host.
cLoading…
| Offset | Field |
|---|---|
| 0-3 | magic 7f 45 4c 46 ("\x7fELF") |
| 4 | class: 1 = 32-bit, 2 = 64-bit |
| 5 | data: 1 = LSB (little-endian), 2 = MSB (big-endian); every later field uses this byte order |
| 16-17 | e_type: 1 relocatable, 2 executable, 3 shared object, 4 core file |
| 18-19 | e_machine |
| 24 | e_entry: 4 bytes (32-bit) or 8 bytes (64-bit) |
| e_machine | Name | Variant | qemu | cross gcc |
|---|---|---|---|---|
| 62 | x86-64 | qemu-x86_64 | x86_64-linux-gnu-gcc | |
| 3 | Intel 80386 | qemu-i386 | i686-linux-gnu-gcc | |
| 183 | ARM aarch64 | LSB / MSB | qemu-aarch64 / qemu-aarch64_be | aarch64-linux-gnu-gcc / aarch64_be-linux-gnu-gcc |
| 40 | ARM | LSB / MSB | qemu-arm / qemu-armeb | arm-linux-gnueabihf-gcc / armeb-linux-gnueabihf-gcc |
| 243 | UCB RISC-V | 64 / 32-bit | qemu-riscv64 / qemu-riscv32 | riscv64-linux-gnu-gcc / riscv32-linux-gnu-gcc |
| 8 | MIPS | 32-bit LSB / MSB | qemu-mipsel / qemu-mips | mipsel-linux-gnu-gcc / mips-linux-gnu-gcc |
| 8 | MIPS | 64-bit LSB / MSB | qemu-mips64el / qemu-mips64 | mips64el-linux-gnuabi64-gcc / mips64-linux-gnuabi64-gcc |
| 20 | PowerPC | qemu-ppc | powerpc-linux-gnu-gcc | |
| 21 | 64-bit PowerPC | LSB / MSB | qemu-ppc64le / qemu-ppc64 | powerpc64le-linux-gnu-gcc / powerpc64-linux-gnu-gcc |
| 22 | IBM S/390 | qemu-s390x | s390x-linux-gnu-gcc |
Native: an x86_64 host runs 64-bit x86-64 and 32-bit Intel 80386 directly. An aarch64 host runs only 64-bit LSB ARM aarch64. Everything else needs qemu.
cLoading…
not runnable: link it into an executable first, core files not runnable: a core dump is loaded by a debugger, and other types (type N in the first line) not runnable: unknown file type.machine N in the first line and then only no cross toolchain or qemu mapping for machine N.host prints host: NAME.NAME: error: bad hex (odd length or a non-hex digit);NAME: error: truncated header (N bytes) if there are under 4 bytes;NAME: error: not an ELF file (magic aa bb cc dd);NAME: error: bad class N, then NAME: error: bad data encoding N;error: host must be x86_64 or aarch64 and error: bad command: LINE.Input:
cLoading…
Output:
cLoading…
Hidden tests cover 32-bit ARM, big-endian PowerPC, MIPS and S/390, 32- and 64-bit RISC-V, big-endian AArch64 on an ARM host, core files, unknown types and machines, a Mach-O and a PE file, truncated headers and malformed commands.