[patch] For BZ #17328, mark __errno_location with __attribute__((returns_nonnull)) for gcc >=4.9.0

Florian Weimer fweimer@redhat.com
Tue Mar 3 10:48:00 GMT 2015


On 03/02/2015 11:46 PM, Roland McGrath wrote:

> Something that we could consider as a middle road is exporting errno with a
> proper symbol version (it's currently GLIBC_PRIVATE, which nothing residing
> outside the libc source tree should ever use) and then having errno.h do:
> 
> 	extern __thread int errno;

Can we make the TLS offset part of the ABI instead and somehow teach GCC
about it?  Then there would at least be an unquestionable improvement.

Right now, we have (in PIC code):

	call	__errno_location@PLT
	movl	(%rax), %eax

This turns into:

	data32
	leaq	errcode@tlsgd(%rip), %rdi
	data32
	data32
	rex64
	call	__tls_get_addr@PLT
	movl	(%rax), %eax

errno is mostly used on error paths, so this just bloats the code and is
probably even slower, too.

-- 
Florian Weimer / Red Hat Product Security



More information about the Libc-alpha mailing list