Syscall x86 convention in Devlopers' Handbook

John Baldwin jhb at freebsd.org
Mon Sep 8 17:09:10 UTC 2014


On Saturday, September 06, 2014 02:40:33 PM Seo Townsend wrote:
> Hey guys, this is my first time in this mailing list so I’m not fully aware
> of all the procedures…
> 
> I was looking through the developer handbook and noticed that the
> Developer’s Handbook section on Assembly for x86 doesn’t make any mention
> of the change in the syscall calling convention from i386 to x86-64 and I
> can’t seem to find this documented anywhere.  The documentation does
> mention “FreeBSD kernel uses the C calling convention” (11.3.1) but doesn’t
> point out that the C calling convention changed from i386 to x86-64; and
> the architecture listed for 11 is generically (x86 Assembly Language
> Programming).

Arguably, the "C calling convention" on x86-64 is to pass by register since 
that is what C uses on x86-64, so I'm not sure the statement is wrong.

> Thoughts?  Some ideas I had are:
> (1). Change “x86 Assembly Language Programming” to “i386 Assembly” - This
> would clear up the disambiguity of the 32bit architecture and 64bit
> architecture.

I think this is probably a fine thing to do.

> (2). Add a footnote to (11.3.1) with “If you are using
> x86-64, please note that the calling convention for both C and syscall
> changed from pushing arguments on the stack to using a list of ordered
> registered as outlined in the System V AMD64 ABI specification”

I don't really think this is the proper place to document the well-known 
x86-64 calling conventions. :)  If you are programming 64-bit assembly you 
should already know those.

> (3). I would not mind eventually adding a section for “x86-64 assembly” for
> (11.3.2) if I could get someone to help mentor me.

I suspect it would be more useful to just replace the current 32-bit example
with only a 64-bit example and not try to keep both.

-- 
John Baldwin


More information about the freebsd-doc mailing list