This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Saving errno around signal handlers
- From: Rich Felker <dalias at aerifal dot cx>
- To: Florian Weimer <fweimer at redhat dot com>
- Cc: Richard Henderson <rth at twiddle dot net>, GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 3 Mar 2014 17:06:44 -0500
- Subject: Re: Saving errno around signal handlers
- Authentication-results: sourceware.org; auth=none
- References: <531077D9 dot 2000308 at redhat dot com> <5310BE05 dot 7090606 at twiddle dot net> <5310C04E dot 9090009 at redhat dot com> <20140301003141 dot GY184 at brightrain dot aerifal dot cx> <5314402A dot 7070809 at redhat dot com>
On Mon, Mar 03, 2014 at 09:41:14AM +0100, Florian Weimer wrote:
> On 03/01/2014 01:31 AM, Rich Felker wrote:
> >On Fri, Feb 28, 2014 at 05:58:54PM +0100, Florian Weimer wrote:
> >>On 02/28/2014 05:49 PM, Richard Henderson wrote:
> >>>On 02/28/2014 03:49 AM, Florian Weimer wrote:
> >>>>
> >>>>In all cases (kernel and glibc implementation), we can use a tail call to make
> >>>>sure that the stack layout looks like it is at present (at least on
> >>>>architectures with an available callee-saved register), and we would not have
> >>>>to adjust GDB and other tools.
> >>>
> >>>How's that? A tail call would not be able to "restore" anything afterward.
> >>
> >>We already have the restorer that calls sigreturn, and could add
> >>
> >> movq errno@gottpoff(%rip), %rdi
> >> movl %r12d, %fs:(%rdi)
> >>
> >>right before that.
> >
> >This does not support nested signal handlers. The saved errno must be
> >on the stack frame of the trampoline calling the real signal handler,
> >not a fixed TLS location.
>
> In this example, the saved errno value is in the %r12d register,
> which is callee-saved, and I suppose that should address your
> concern.
Oh, I misread the code's use of %fs-relative addressing as storing the
saved errno there rather than accessing the thread-local errno. Never
mind.
Rich