OpenBSD – Hello World in x64 Assembly

This past week I’ve been learning x86 assembly language on an old laptop, purely because I couldn’t get anything running on my x64 OpenBSD machine. My 64 bit helloworld.s was as follows:

section .data

 msg db "Hello world!", 10
 len equ $-msg

 %define SYS_exit 1
 %define SYS_write 4

section .text

global _start

 mov rax, SYS_write
 mov rdi, 1 ;stdout
 mov rsi, msg
 mov rdx, len


 mov rax, SYS_exit
 xor rdi, rdi


Giving the errors:

jon@OpenBsD:~/dev/asm;$ nasm -f elf64 -o helloworld.o helloworld.s
jon@OpenBsD:~/dev/asm;$ ld -o helloworld helloworld.o
ld: warning: creating a DT_TEXTREL in a shared object.
jon@OpenBsD:~/dev/asm;$ yasm -f elf64 -o helloworld.o helloworld.s
jon@OpenBsD:~/dev/asm;$ ld -o helloworld helloworld.o 
ld: helloworld.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
helloworld.o: could not read symbols: Bad value

I did search /usr/src for any assembly files I could straight up copy and test, but I didn’t find anything suitable, however the code looks fine and as the assembler didn’t throw out any errors I’m thinking this to be an issue with the linker.

Running ld with the verbose flag we are shown the options for available architectures:

jon@OpenBsD:~>$ ld -V
GNU ld version 2.17
  Supported emulations:

Continue reading “OpenBSD – Hello World in x64 Assembly”

OpenBSD (6.0) Home Router

Something about using the black box my ISP provided to control my whole network just didn’t sit right with me, so I decided to ditch it and make my own using the  industrie’s go-to firewall operating system: OpenBSD.

I started with an Alix2d2, a single board x86 machine with low power consumption, and a BT OpenReach modem. Both pre-owned and picked up on Ebay for very reasonable prices, I also had to buy a null modem cable to connect to the Alix, a Ralink RT2561T MiniPCI WLAN module and antenna  for wireless connectivity.

The only way to  install the operating system onto the Alix (apart from copying a snapshot onto the memory card) is a network install, so we will need to setup tftpd and dhcpd.


38400 in the default baud rate for the alix2d2 so I’ve set that in the boot.conf

# mkdir -p /tftpboot/etc
# cd /tftpdboot
# wget
# wget
# echo "stty com0 38400
set tty com0
boot tftp:/bsd.rd" >> etc/boot.conf
# tftpd /tftpboot


The box we’re installing from is

 option domain-name-servers;
subnet netmask {
 filename "pxeboot";
 option routers;
 option broadcast-address;
 option subnet-mask;

After restarting  dhcpd we are ready to start installing, connect the Alix to the box you’re installing from, connect the null modem cable and boot it up.

Continue reading “OpenBSD (6.0) Home Router”