On Fri, Dec 31, 2010 at 8:50 AM, H.J. Lu <hjl.to...@gmail.com> wrote: > On Fri, Dec 31, 2010 at 2:03 AM, Jakub Jelinek <ja...@redhat.com> wrote: >> On Thu, Dec 30, 2010 at 01:42:05PM -0800, H. Peter Anvin wrote: >>> On 12/30/2010 11:57 AM, Jakub Jelinek wrote: >>> >> >>> >> Would be nice if LFS would be mandatory on the new ABI, thus >>> >> off_t being 64bits. >>> > >>> > And avoid ambiguous cases that x86-64 ABI has, e.g. whether >>> > caller or callee is responsible for sign/zero extension of arguments, to >>> > avoid the need to sign/zero extend twice, etc. >>> > >>> >>> Ehwhat? x86-64 is completely unambiguous on that point; the i386 one is >>> not. >> >> It is not, sadly, see http://gcc.gnu.org/PR46942 >> From what I can see the psABI doesn't talk about it, GCC usually sign/zero >> extends on both sides (exception is 32-bit arguments into 64-bit isn't >> apparently sign/zero extended on the caller side when doing tail calls), >> from what I gathered LLVM expects the caller to sign/zero extend (which is >> incompatible with GCC tail calls then), not sure about ICC, and kernel >> probably expects for security reasons that the callee sign/zero extends. >> >> Jakub >> > > I added > > --- > When a value of type signed/unsigned char or short is returned or passed > in a register or on the stack, it should be sign/zero extended to > signed/unsigned > int. > --- > > to hjl/extension branch at > > http://git.kernel.org/?p=devel/binutils/hjl/x86-64-psabi.git;a=summary >
According to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42324 all compilers clears bits 1-31 when passing _Bool to a function. Also GCC doesn't sign/zero extend on char/short return. I updated x86-64 psABI to ---- When a value of type _Bool is returned in a register, bit 0 contains the truth value and bits 1 to 7 shall be zero. When an argument of type _Bool is passed in a register or on the stack, bit 0 contains the truth value and bits 1 to 31 shall be zero. When a value of type signed/unsigned char or short is returned in a register, bits 0 to 7 for char and bits 0 to 15 for short contain the value and other bits are left unspecified. When an argument of signed/unsigned type char or short is passed in a register or on the stack, it shall be sign/zero extended to signed/unsigned int. --- on hjl/extension branch at http://git.kernel.org/?p=devel/binutils/hjl/x86-64-psabi.git;a=summary -- H.J.