ABI question, porting ports to amd64
peter at wemm.org
Sun May 16 16:07:22 PDT 2004
On Sunday 16 May 2004 02:08 pm, Marco van de Voort wrote:
> y> > 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)
> I was always curious why the (basic) *nix syscalls weren't inlined?
> Can't gcc do that?
The errno handling is the sticky point. Error return is indicated by
the 'carry' bit set in the flags register. At which point the return
value of the syscall is copied to the 'errno' variable and the function
Peter Wemm - peter at wemm.org; peter at FreeBSD.org; peter at yahoo-inc.com
"All of this is for nothing if we don't go to the stars" - JMS/B5
More information about the freebsd-amd64