Message board for the users of flat assembler.
> Unix > Syscall convention for FreeBSD (AMD64)
Chewy509 07 Nov 2006, 04:15
I'm about to start porting an app from Linux to FreeBSD, and haven't been able to confirm the kernel calling convention for FreeBSD apps?
Reading the output from gcc, it looks like the normal x86-64 ABI (with rax = function number and 'syscall' to invoke), but gcc seems to be taking some short-cuts with it's generated code?
So does FreeBSD use the standard x86-64 ABI with 'syscall' to invoke the kernel and rax = the function number? (with function numbers from syscalls.master).
mov rax, 4 ; write mov rdi, 1; stdout file handle mov rsi, hello_world; pointer to string mov rdx, 11 ; 11 chars syscall
|07 Nov 2006, 04:15||
Chewy509 07 Nov 2006, 23:24
After a lot of testing, FreeBSD uses the x86-64 SYSV ABI, with rax being the function call, and 'syscall' to invoke the call...
|07 Nov 2006, 23:24||
codsna 09 Aug 2007, 22:07
Many thanks, Chewy509
I have written a modified elf64 your code. Works fine.
(FreeBSD 6.2 AMD64, fasm 32 bit elf_i386_fbsd libc)
mov rax, 4 ; write
mov rdi, 1; stdout file handle
mov rsi, hello_world; pointer to string
mov rdx, len ; string len
xor rax, rax ; sys_exit
hello_world db "Hello World ", 10
len = $-hello_world
|09 Aug 2007, 22:07||
codsna 09 Aug 2007, 22:11
gcc hello64.o -o hello64
gcc -m64 hello64.o -o hello64
easier than build (ld link) 32 bit in FreeBSD AMD64
|09 Aug 2007, 22:11||
< Last Thread | Next Thread >
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.