Subject: NetBSD ABI and library calls
To: None <tech-kern@netbsd.org>
From: software.au@gmail.com <software.au@gmail.com>
List: tech-kern
Date: 10/30/2005 14:20:03
Hi all,

In FreeBSD if you want to call the kernel with assembler, the kernel
expects a function that does the software interrupt, instead of
pushing arguments on the stack or in registers and directly calling
the interrupt like Linux.

E.g. the Linux way:

push dword foo
push dword bar
push dword syscallnr      /* or in %eax or whatever */
int 0x80
add esp, 12

E.g. the FreeBSD way:

kernel:
   int 0x80
   ret

push dword foo
push dword bar
push dword syscallnr      /* or however it's done */
call kernel
add esp, 12


How is it done in NetBSD?  Is there some kind of "ABI" like the SysV
ABI, or is this called a calling convention?  Where in the sources
could I take a look to see how it's done?  Are syscall stubs for the C
library somewhere in the syssrc or elsewhere?

When the NetBSD kernel is built, after linking is it just an ELF
program or are there any special tweaks that are done?

Thanks,
James