]>
Commit | Line | Data |
---|---|---|
e3726b05 | 1 | /* setjmp for i386. |
2b778ceb | 2 | Copyright (C) 1995-2021 Free Software Foundation, Inc. |
e61abf83 | 3 | This file is part of the GNU C Library. |
e3726b05 | 4 | |
e61abf83 | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
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. | |
e3726b05 | 9 | |
e61abf83 UD |
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 | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
e3726b05 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
e3726b05 RM |
18 | |
19 | #include <sysdep.h> | |
a7140723 | 20 | #include <jmpbuf-offsets.h> |
faaee1f0 | 21 | #include <jmp_buf-ssp.h> |
dfd2257a | 22 | #include <asm-syntax.h> |
8422c9a5 | 23 | #include <stap-probe.h> |
e3726b05 | 24 | |
2366713d | 25 | #define PARMS 4 /* no space for saved regs */ |
e5f88e0c | 26 | #define JMPBUF PARMS |
2366713d | 27 | #define SIGMSK JMPBUF+4 |
e5f88e0c | 28 | |
faaee1f0 L |
29 | /* Don't save shadow stack register if shadow stack isn't enabled. */ |
30 | #if !SHSTK_ENABLED | |
31 | # undef SHADOW_STACK_POINTER_OFFSET | |
32 | #endif | |
33 | ||
2366713d | 34 | ENTRY (__sigsetjmp) |
e5f88e0c GM |
35 | |
36 | movl JMPBUF(%esp), %eax | |
e5f88e0c | 37 | |
350635a5 | 38 | /* Save registers. */ |
44c8d1a2 RM |
39 | movl %ebx, (JB_BX*4)(%eax) |
40 | movl %esi, (JB_SI*4)(%eax) | |
41 | movl %edi, (JB_DI*4)(%eax) | |
e5f88e0c | 42 | leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */ |
272b2898 UD |
43 | #ifdef PTR_MANGLE |
44 | PTR_MANGLE (%ecx) | |
45 | #endif | |
350635a5 | 46 | movl %ecx, (JB_SP*4)(%eax) |
2366713d | 47 | movl 0(%esp), %ecx /* Save PC we are returning to now. */ |
8422c9a5 | 48 | LIBC_PROBE (setjmp, 3, 4@%eax, -4@SIGMSK(%esp), 4@%ecx) |
827b7087 UD |
49 | #ifdef PTR_MANGLE |
50 | PTR_MANGLE (%ecx) | |
51 | #endif | |
350635a5 | 52 | movl %ecx, (JB_PC*4)(%eax) |
eb48f491 GM |
53 | movl %ebp, (JB_BP*4)(%eax) /* Save caller's frame pointer. */ |
54 | ||
faaee1f0 L |
55 | #ifdef SHADOW_STACK_POINTER_OFFSET |
56 | # if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET | |
57 | /* Check if Shadow Stack is enabled. */ | |
58 | testl $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET | |
59 | jz L(skip_ssp) | |
60 | # else | |
61 | xorl %ecx, %ecx | |
62 | # endif | |
63 | /* Get the current Shadow-Stack-Pointer and save it. */ | |
64 | rdsspd %ecx | |
65 | movl %ecx, SHADOW_STACK_POINTER_OFFSET(%eax) | |
66 | # if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET | |
67 | L(skip_ssp): | |
68 | # endif | |
69 | #endif | |
a3848485 | 70 | #if IS_IN (rtld) |
827b7087 UD |
71 | /* In ld.so we never save the signal mask. */ |
72 | xorl %eax, %eax | |
73 | ret | |
74 | #else | |
44c8d1a2 | 75 | /* Make a tail call to __sigjmp_save; it takes the same args. */ |
827b7087 UD |
76 | jmp __sigjmp_save |
77 | #endif | |
2366713d | 78 | END (__sigsetjmp) |
6e45e6ef | 79 | hidden_def (__sigsetjmp) |