Re: changes in i386 and x86_64 assembrer

Felix von Leitner <[email protected]> Sat, 25 Dec 2010 19:15:32 +0100
Newsgroups gmane.linux.lib.dietlibc
Message-ID <[email protected]>
> There are also a population of errors at 521..530, defined in kernel
> source: include/linux/errno.h.  These are inside `#ifdef __KERNEL__' and
> commented "These should never be seen by user programs"; but they do
> leak into user space.

> One of the high values is ENOTSUPP (524), which is returned by a fair
> number of paths.  This simple program invokes one of them to demonstrate
> that something is wrong (requires SCTP protocol driver):

Please file that as a bug in the kernel.  The kernel should not return
those.

> 2: save 2 bytes of code:

> > 	neg	%eax
> > #ifdef WANT_THREAD_SAFE
> > -	movl	%eax,%ebx
> > -	call	__errno_location
> > -	movl	%ebx,(%eax)
> > +	/* we cannot use anymore %ebp; it is recovered already above! */
> > +	push	%eax
> > +	call	__errno_location
> > +	pop	(%eax)
> > 	orl	$-1,%eax
> > #else
> > 	mov	%eax,errno
> > 	sbb	%eax,%eax               # eax = eax - eax - CY = -1
> > #endif
> > .Lnoerror:

> Setting %eax to return -1 can be shortened:

>    	...
>    	pop	(%eax)
>   	stc
>   #else
>   	mov	%eax,errno
>   #endif
>   	sbb	%eax,%eax               # eax = eax - eax - CY = -1

How do you know the carry flag is not set in the non-stc case?

I think this is too obfuscating for this small of a gain.

Felix