On 2025/03/14 13:20, Alnoman Kamil wrote: > Save as hello.S file > ``` > data > msg: > .ascii "Hello, ARM64!\n" > len = . - msg > .text > > .globl _start > _start: > mov x0, #1 /* fd := STDOUT_FILENO */ > ldr x1, =msg /* buf := msg */ > ldr x2, =len /* count := len */ > mov w8, #64 /* write is syscall #64 */ > svc #0 /* invoke syscall */ > > mov x0, #0 /* status := 0 */ > mov w8, #93 /* exit is syscall #93 */ > svc #0 /* invoke syscall */ > ``` > > Then execute these commands: > > as -o hello.o hello.S > ld -s -o hello hello.o > > Mind you thats what I done on asahi arch linux, not sure if its different on > OpenBSD.
It is different: - not all openbsd architectures have as(1) - on amd64 we have it from binutils - on arm64 we don't (it is available in packages as "gas" though) - the elf file must be marked as an openbsd executable in a PT_NOTE section, see /sys/kern/exec_elf.c - syscall 64 is fstatfs not write, 93 is accept4 not exit - system calls can't be invoked except from certain addresses known to the kernel (informed by ld.so for dynamically linked programs or a different mechanism for static binaries), you would either need to invoke them via the wrappers in libc or replicate the same mechanism. read around starting at pinsyscalls(9) for more