Where to find amd64 ABI information for FreeBSD?

Peter Wemm peter at wemm.org
Sat Apr 9 22:59:38 UTC 2011


On Tue, Apr 5, 2011 at 3:49 PM, Kostik Belousov <kostikbel at gmail.com> wrote:
> On Tue, Apr 05, 2011 at 03:10:37PM -0700, Xin LI wrote:
>> -----BEGIN PGP SIGNED MESSAGE-----
>> Hash: SHA256
>>
>> Hi,
>>
>> Is there a place to find ABI information for GCC on FreeBSD?
>>  Specifically, I'm looking for which registers has to be preserved
>> across function call?  (Or do we follow System V Application Binary
>> Interface AMD64 Architecture Processor Supplement Draft Version 0.99.5?)
>
> The parts of the mentioned document that depend on compiler and
> toolchain, are fully valid for FreeBSD. Our non-compliance is mostly
> in the specified bits of the kernel/usermode interface.
>

There is also an accidental deviation with register usage in the way
we start up applications.

But as far as calling conventions go for preserved/scratch registers,
we are compliant.

Of note our i386 syscall abi is not consistent with i386 calling
conventions.  In particular, i386 syscalls save/restore ALL registers
except for those used in return values.  eg: %eax is changed, and %edx
is changed for SOME syscalls that have a 64 bit or dual return (and
preserved otherwise).

Unlike i386, our amd64 syscalls do not preserve registers that are
designated as scratch in the abi.  There is an inconsistency between
the syscall instruction and the ABI, but that is "repaired" in the
libc syscall wrappers.

-- 
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com; KI6FJV
"All of this is for nothing if we don't go to the stars" - JMS/B5
"If Java had true garbage collection, most programs would delete
themselves upon execution." -- Robert Sewell


More information about the freebsd-amd64 mailing list