Last active
June 6, 2020 09:46
-
-
Save jasperla/76f29c069ca4d0756d9fd12bb8acceed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; nasm -D OpenBSD -f elf64 exit.nasm -o exit.o && ld.bfd -nopie -e _start exit.o -o exit && ./exit ; echo $? | |
%ifdef OpenBSD | |
section .note.openbsd.ident | |
align 2 | |
dd 8,4,1 | |
db "OpenBSD",0 | |
dd 0 | |
align 2 | |
%define SYS_EXIT 1 | |
%define SYS_WRITE 4 | |
%endif | |
global _start | |
section .text | |
_start: | |
mov rax, SYS_WRITE | |
mov rsi, hello_world ; *buf | |
mov rdx, length ; nbytes | |
mov rdi, 0x1 ; fd | |
syscall | |
mov rax, SYS_EXIT | |
mov rdi, 42 | |
syscall | |
section .data | |
hello_world: db 'Hello World', 0xa | |
length: equ $-hello_world |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment