mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-04 19:00:09 +00:00
b33e946fbb
It seems that some gcc versions might generates a stack frame for the sigreturn stub requires on sparc signal handling. For instance: $ cat test.c #define _GNU_SOURCE #include <sys/syscall.h> __attribute__ ((__optimize__ ("-fno-stack-protector"))) void __sigreturn_stub (void) { __asm__ ("mov %0, %%g1\n\t" "ta 0x10\n\t" : /* no outputs */ : "i" (SYS_rt_sigreturn)); } $ gcc -v [...] gcc version 9.2.1 20200224 (Debian 9.2.1-30) $ gcc -O2 -m64 test.c -S -o - [...] __sigreturn_stub: save %sp, -176, %sp #APP ! 9 "t.c" 1 mov 101, %g1 ta 0x10 ! 0 "" 2 #NO_APP .size __sigreturn_stub, .-__sigreturn_stub As indicated by kernel developers [1], the sigreturn stub can not change the register window or the stack pointer since the kernel has setup the restore frame at a precise location relative to the stack pointer when the stub is invoked. I tried to play with some compiler flags and even with _Noreturn and __builtin_unreachable after the asm does not help (and Sparc does not support naked functions). To avoid similar issues, as the stack-protector support also have stumbled, this patch moves the implementation of the sigreturn stubs to assembly. Checked on sparcv9-linux-gnu and sparc64-linux-gnu with gcc 9.2.1 and gcc 7.5.0. [1] https://lkml.org/lkml/2016/5/27/465
38 lines
1.3 KiB
C
38 lines
1.3 KiB
C
/* POSIX.1 sigaction call for Linux/SPARC.
|
|
Copyright (C) 1997-2020 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
Contributed by Miguel de Icaza <miguel@nuclecu.unam.mx>, 1997.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<https://www.gnu.org/licenses/>. */
|
|
|
|
#include <string.h>
|
|
#include <syscall.h>
|
|
#include <sys/signal.h>
|
|
#include <errno.h>
|
|
#include <kernel_sigaction.h>
|
|
#include <sysdep.h>
|
|
|
|
void __rt_sigreturn_stub (void);
|
|
void __sigreturn_stub (void);
|
|
|
|
#define STUB(act, sigsetsize) \
|
|
(act) ? ((unsigned long)((act->sa_flags & SA_SIGINFO) \
|
|
? &__rt_sigreturn_stub \
|
|
: &__sigreturn_stub) - 8) \
|
|
: 0, \
|
|
(sigsetsize)
|
|
|
|
#include <sysdeps/unix/sysv/linux/sigaction.c>
|