1/* POSIX.1 `sigaction' call for Linux/i386.
2 Copyright (C) 1991-2024 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19#include <signal.h>
20#include <ldsodefs.h>
21
22#define SA_RESTORER 0x04000000
23
24extern void restore_rt (void) asm ("__restore_rt") attribute_hidden;
25extern void restore (void) asm ("__restore") attribute_hidden;
26
27#define SET_SA_RESTORER(kact, act) \
28 ({ \
29 if (GLRO(dl_sysinfo_dso) == NULL) \
30 { \
31 (kact)->sa_flags |= SA_RESTORER; \
32 (kact)->sa_restorer = (((act)->sa_flags & SA_SIGINFO) \
33 ? &restore_rt : &restore); \
34 } \
35 else \
36 (kact)->sa_restorer = NULL; \
37 })
38
39#define RESET_SA_RESTORER(act, kact) \
40 (act)->sa_restorer = (kact)->sa_restorer
41
42#include <sysdeps/unix/sysv/linux/libc_sigaction.c>
43
44/* NOTE: Please think twice before making any changes to the bits of
45 code below. GDB needs some intimate knowledge about it to
46 recognize them as signal trampolines, and make backtraces through
47 signal handlers work right. Important are both the names
48 (__restore and __restore_rt) and the exact instruction sequence.
49 If you ever feel the need to make any changes, please notify the
50 appropriate GDB maintainer. */
51
52#define RESTORE(name, syscall) RESTORE2 (name, syscall)
53#define RESTORE2(name, syscall) \
54asm \
55 ( \
56 ".text\n" \
57 " .align 16\n" \
58 "__" #name ":\n" \
59 " movl $" #syscall ", %eax\n" \
60 " int $0x80" \
61 );
62
63/* The return code for realtime-signals. */
64RESTORE (restore_rt, __NR_rt_sigreturn)
65
66/* For the boring old signals. */
67#undef RESTORE2
68#define RESTORE2(name, syscall) \
69asm \
70 ( \
71 ".text\n" \
72 " .align 8\n" \
73 "__" #name ":\n" \
74 " popl %eax\n" \
75 " movl $" #syscall ", %eax\n" \
76 " int $0x80" \
77 );
78
79RESTORE (restore, __NR_sigreturn)
80

source code of glibc/sysdeps/unix/sysv/linux/i386/libc_sigaction.c