Hi all,


I'm trying to learn x86-64 assembly on OpenBSD starting with a little
"Hello OpenBSD!" to the console.  I'm also not using libc because I
want to understand what writing assembly is like at the syscall level.

My main issue is with pinsyscalls and I'm not sure how
to implement it with handwritten assembly and I could not find any
examples of it online.

My current assembly looks like this:


.section ".note.openbsd.ident", "a"
  .p2align 2
  .long 8
  .long 4
  .long 1
  .ascii "OpenBSD\0"
  .long 0
  .p2align 2


.section .data

  msg: .ascii "Hello OpenBSD!"
       .byte 10


.section .text
.globl _start

_start:
  movq $4, %rax # write opcode
  movq $1, %rdi # stdout
  movq $msg, %rsi # msg buffer
  movq $15, %rdx # msg length
  syscall

  movq $1, %rax # exit opcode
  movq $0, %rdi # error code 0
  syscall


I assemble and link it with these commands (main.s is the src file):


OpenBSD-is-king$ as main.s -o main.o
OpenBSD-is-king$ ld --no-pie main.o -o main


Once I ran the final executable, that's where I got the error:


OpenBSD-is-king$ ./main
main[28033]: pinsyscalls addr 2011c4 code 4, pinoff 0xffffffff
(pin 0 0-0 0) (libcpin 0 0-0 0) error 78
Abort trap (core dumped)


Reading the pinsyscalls man page (man pinsyscalls) says that the
syscalls all need to be in some certain memory block or program will
abort.  I dont know how to implement this in assembly, perhaps a
separate section or something like that??

Any help, explanations, docs, or source code solutions would be
appreciated.



Thanks in advance for the time 'n help

Reply via email to