|
Packit |
6c4009 |
/* setjmp for i386.
|
|
Packit |
6c4009 |
Copyright (C) 1995-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
#include <jmpbuf-offsets.h>
|
|
Packit |
6c4009 |
#include <jmp_buf-ssp.h>
|
|
Packit |
6c4009 |
#include <asm-syntax.h>
|
|
Packit |
6c4009 |
#include <stap-probe.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define PARMS 4 /* no space for saved regs */
|
|
Packit |
6c4009 |
#define JMPBUF PARMS
|
|
Packit |
6c4009 |
#define SIGMSK JMPBUF+4
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Don't save shadow stack register if shadow stack isn't enabled. */
|
|
Packit |
6c4009 |
#if !SHSTK_ENABLED
|
|
Packit |
6c4009 |
# undef SHADOW_STACK_POINTER_OFFSET
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ENTRY (__sigsetjmp)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
movl JMPBUF(%esp), %eax
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Save registers. */
|
|
Packit |
6c4009 |
movl %ebx, (JB_BX*4)(%eax)
|
|
Packit |
6c4009 |
movl %esi, (JB_SI*4)(%eax)
|
|
Packit |
6c4009 |
movl %edi, (JB_DI*4)(%eax)
|
|
Packit |
6c4009 |
leal JMPBUF(%esp), %ecx /* Save SP as it will be after we return. */
|
|
Packit |
6c4009 |
#ifdef PTR_MANGLE
|
|
Packit |
6c4009 |
PTR_MANGLE (%ecx)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
movl %ecx, (JB_SP*4)(%eax)
|
|
Packit |
6c4009 |
movl 0(%esp), %ecx /* Save PC we are returning to now. */
|
|
Packit |
6c4009 |
LIBC_PROBE (setjmp, 3, 4@%eax, -4@SIGMSK(%esp), 4@%ecx)
|
|
Packit |
6c4009 |
#ifdef PTR_MANGLE
|
|
Packit |
6c4009 |
PTR_MANGLE (%ecx)
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
movl %ecx, (JB_PC*4)(%eax)
|
|
Packit |
6c4009 |
movl %ebp, (JB_BP*4)(%eax) /* Save caller's frame pointer. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef SHADOW_STACK_POINTER_OFFSET
|
|
Packit |
6c4009 |
# if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
|
|
Packit |
6c4009 |
/* Check if Shadow Stack is enabled. */
|
|
Packit |
6c4009 |
testl $X86_FEATURE_1_SHSTK, %gs:FEATURE_1_OFFSET
|
|
Packit |
6c4009 |
jz L(skip_ssp)
|
|
Packit |
6c4009 |
# else
|
|
Packit |
6c4009 |
xorl %ecx, %ecx
|
|
Packit |
6c4009 |
# endif
|
|
Packit |
6c4009 |
/* Get the current Shadow-Stack-Pointer and save it. */
|
|
Packit |
6c4009 |
rdsspd %ecx
|
|
Packit |
6c4009 |
movl %ecx, SHADOW_STACK_POINTER_OFFSET(%eax)
|
|
Packit |
6c4009 |
# if IS_IN (libc) && defined SHARED && defined FEATURE_1_OFFSET
|
|
Packit |
6c4009 |
L(skip_ssp):
|
|
Packit |
6c4009 |
# endif
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
#if IS_IN (rtld)
|
|
Packit |
6c4009 |
/* In ld.so we never save the signal mask. */
|
|
Packit |
6c4009 |
xorl %eax, %eax
|
|
Packit |
6c4009 |
ret
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
/* Make a tail call to __sigjmp_save; it takes the same args. */
|
|
Packit |
6c4009 |
jmp __sigjmp_save
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
END (__sigsetjmp)
|
|
Packit |
6c4009 |
hidden_def (__sigsetjmp)
|