This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [patch] For BZ #17328, mark __errno_location with __attribute__((returns_nonnull)) for gcc >=4.9.0
- From: Florian Weimer <fweimer at redhat dot com>
- To: Roland McGrath <roland at hack dot frob dot com>, Zack Weinberg <zackw at panix dot com>
- Cc: Paul Pluzhnikov <ppluzhnikov at gmail dot com>, Rich Felker <dalias at libc dot org>, GLIBC Devel <libc-alpha at sourceware dot org>
- Date: Tue, 03 Mar 2015 11:48:43 +0100
- Subject: Re: [patch] For BZ #17328, mark __errno_location with __attribute__((returns_nonnull)) for gcc >=4.9.0
- Authentication-results: sourceware.org; auth=none
- References: <CALoOobOuAEpw+zxRrrDyHB7UVbAZMzreXqpujzZOWNLS7+aRUA at mail dot gmail dot com> <20150301011753 dot GV23507 at brightrain dot aerifal dot cx> <CAPC3xapQBMH+DJdup2Y8_tt6xdcFAnQLB_K8VpT3ouCavvzXXA at mail dot gmail dot com> <CAKCAbMgyAEueVsYB=avfUg0pK49YiY-Qyi8w1qXvfTCzfPbUiQ at mail dot gmail dot com> <20150302224606 dot 9C97F2C3A08 at topped-with-meat dot com>
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