AArch64 assembly - part 4

Author: Carmelo C.
Published: May 29, 2023 (updated)
assembly arm64 aarch64 coding

AArch64

Index

  1. Home
  2. Let’s break the ice
  3. Under the surface
  4. Under the microscope
  5. Cross-compilation
  6. Resources

Cross-compilation

Interestingly, one does not need to own an ARM64 processor. With the help of QEMU user mode emulation (qemu-user) and the GNU C compiler for AArch64 (gcc-aarch64-linux-gnu), assembling and linking native code is a breeze. Starting from exactly the source code let’s run:

$ <b>aarch64-linux-gnu-as answer.s</b>

$ <b>aarch64-linux-gnu-gcc -static -o answer a.out</b>

$ <b>./answer</b>

$ <b>echo $?</b>
42

Of course, no tricks, the output above has been collected on:

$ <b>uname -m</b>
x86_64

$ <b>file a.out</b>
a.out: ELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV), not stripped

$ <b>file answer</b>
answer: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, not stripped