From owner-freebsd-amd64@FreeBSD.ORG Sat Apr 9 22:59:38 2011 Return-Path: Delivered-To: freebsd-amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D39B7106566B for ; Sat, 9 Apr 2011 22:59:38 +0000 (UTC) (envelope-from peter@wemm.org) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 955C08FC08 for ; Sat, 9 Apr 2011 22:59:38 +0000 (UTC) Received: by vws18 with SMTP id 18so4252223vws.13 for ; Sat, 09 Apr 2011 15:59:37 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.176.34 with SMTP id cf2mr1854874vdc.81.1302388629592; Sat, 09 Apr 2011 15:37:09 -0700 (PDT) Received: by 10.52.159.2 with HTTP; Sat, 9 Apr 2011 15:37:09 -0700 (PDT) In-Reply-To: <20110405224913.GF78089@deviant.kiev.zoral.com.ua> References: <4D9B935D.4010705@delphij.net> <20110405224913.GF78089@deviant.kiev.zoral.com.ua> Date: Sat, 9 Apr 2011 15:37:09 -0700 Message-ID: From: Peter Wemm To: Kostik Belousov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: d@delphij.net, freebsd-amd64@freebsd.org, freebsd-arch@freebsd.org Subject: Re: Where to find amd64 ABI information for FreeBSD? X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 09 Apr 2011 22:59:38 -0000 On Tue, Apr 5, 2011 at 3:49 PM, Kostik Belousov 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? >> =A0Specifically, I'm looking for which registers has to be preserved >> across function call? =A0(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. --=20 Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@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