$ sudo apt install qemu-user
$ sudo apt-get install gcc-10-aarch64-linux-gnu
$ sudo apt install gcc-arm-none-eabi
$ sudo apt install gdb-multiarch
Compile with the -static flag to avoid dynamic linking errors. (e.g. /lib/ld-linux-aarch64.so.1: No such file or director
)
$ aarch64-linux-gnu-gcc-10 -static hello.c -o hello
$ qemu-aarch64 ./hello
.section .data
message:
.asciz "Hello\n"
.section .text
.global _start
_start:
# write(stdout, "Hello\n")
mov x0, #1
ldr x1, =message
mov x2, #6
mov x8, #64
svc #0
# exit(123)
mov x0, #123
mov x8, #93
svc #0
$ aarch64-linux-gnu-as hello.s -o hello.o
$ aarch64-linux-gnu-ld hello.o -o hello
$ aarch64-linux-gnu-objdump -D hello
$ qemu-aarch64 -g 9999 ./hello
$ gdb-multiarch -q ./hello
Reading symbols from ./hello...
(No debugging symbols found in ./hello)
(gdb) target remote :9999
Remote debugging using :9999
0x00000000004000b0 in _start ()
(gdb) set disassemble-next-line on