Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 16 May 2004 13:16:30 -0700
From:      Peter Wemm <peter@wemm.org>
To:        freebsd-amd64@freebsd.org
Subject:   Re: ABI question, porting ports to amd64
Message-ID:  <200405161316.30635.peter@wemm.org>
In-Reply-To: <20040516123139.79BC594@toad.stack.nl>
References:  <20040516123139.79BC594@toad.stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sunday 16 May 2004 05:31 am, Marco van de Voort wrote:
> > I read the ABI info on x86-64.org, and objdumped some linux and
> > freebsd code, and I ran into a linux<->freebsd difference something
> > I can't figure out:
>
> Answering my own question:
>
> FreeBSD uses the gcc mechanism to build the same parameterlist for a
> syscall like for a normal procedure. (to avoid having to shift
> params)
>
> The register for the 4th parameter for gcc is %rcx, for the kernel it
> is %r10. So gcc puts the 4th param in %rcx, and the move moves it to
> %r10 for the kernel.

Correct.  We use the ABI argument ordering since that is what gcc gave 
us when calling the stub funtions, but the syscall instruction clobbers 
%rcx as it enters the kernel.

If we were smarter, we'd only do this move if we know the syscall had 4 
or more arguments.  But unfortunately, we don't have this information 
when building libc.

Or, we'd declare the syscall prototypes with an explicit override of the 
register parameter assignments or something.  (bad luck though if you 
neglect to use the right #includes for your code and miss out a 
prototype)
-- 
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200405161316.30635.peter>