|
Packit |
6c4009 |
/* Install given context.
|
|
Packit |
6c4009 |
Copyright (C) 2001-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
Contributed by Ulrich Drepper <drepper@redhat.com>, 2001.
|
|
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 |
|
|
Packit |
6c4009 |
#include "ucontext_i.h"
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ENTRY(__setcontext)
|
|
Packit |
6c4009 |
/* Load address of the context data structure. */
|
|
Packit |
6c4009 |
movl 4(%esp), %eax
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Get the current signal mask. Note that we preserve EBX in case
|
|
Packit |
6c4009 |
the system call fails and we return from the function with an
|
|
Packit |
6c4009 |
error. */
|
|
Packit |
6c4009 |
pushl %ebx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4)
|
|
Packit |
6c4009 |
xorl %edx, %edx
|
|
Packit |
6c4009 |
leal oSIGMASK(%eax), %ecx
|
|
Packit |
6c4009 |
movl $SIG_SETMASK, %ebx
|
|
Packit |
6c4009 |
cfi_rel_offset (ebx, 0)
|
|
Packit |
6c4009 |
movl $__NR_sigprocmask, %eax
|
|
Packit |
6c4009 |
ENTER_KERNEL
|
|
Packit |
6c4009 |
popl %ebx
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-4)
|
|
Packit |
6c4009 |
cfi_restore (ebx)
|
|
Packit |
6c4009 |
cmpl $-4095, %eax /* Check %eax for error. */
|
|
Packit |
6c4009 |
jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* EAX was modified, reload it. */
|
|
Packit |
6c4009 |
movl 4(%esp), %eax
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Restore the floating-point context. Not the registers, only the
|
|
Packit |
6c4009 |
rest. */
|
|
Packit |
6c4009 |
movl oFPREGS(%eax), %ecx
|
|
Packit |
6c4009 |
fldenv (%ecx)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Restore the FS segment register. We don't touch the GS register
|
|
Packit |
6c4009 |
since it is used for threads. */
|
|
Packit |
6c4009 |
movl oFS(%eax), %ecx
|
|
Packit |
6c4009 |
movw %cx, %fs
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Fetch the address to return to. */
|
|
Packit |
6c4009 |
movl oEIP(%eax), %ecx
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Load the new stack pointer. */
|
|
Packit |
6c4009 |
cfi_def_cfa (eax, 0)
|
|
Packit |
6c4009 |
cfi_offset (edi, oEDI)
|
|
Packit |
6c4009 |
cfi_offset (esi, oESI)
|
|
Packit |
6c4009 |
cfi_offset (ebp, oEBP)
|
|
Packit |
6c4009 |
cfi_offset (ebx, oEBX)
|
|
Packit |
6c4009 |
cfi_offset (edx, oEDX)
|
|
Packit |
6c4009 |
cfi_offset (ecx, oECX)
|
|
Packit |
6c4009 |
movl oESP(%eax), %esp
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Push the return address on the new stack so we can return there. */
|
|
Packit |
6c4009 |
pushl %ecx
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* Load the values of all the 32-bit registers (except ESP).
|
|
Packit |
6c4009 |
Since we are loading from EAX, it must be last. */
|
|
Packit |
6c4009 |
movl oEDI(%eax), %edi
|
|
Packit |
6c4009 |
movl oESI(%eax), %esi
|
|
Packit |
6c4009 |
movl oEBP(%eax), %ebp
|
|
Packit |
6c4009 |
movl oEBX(%eax), %ebx
|
|
Packit |
6c4009 |
movl oEDX(%eax), %edx
|
|
Packit |
6c4009 |
movl oECX(%eax), %ecx
|
|
Packit |
6c4009 |
movl oEAX(%eax), %eax
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* End FDE here, we fall into another context. */
|
|
Packit |
6c4009 |
cfi_endproc
|
|
Packit |
6c4009 |
cfi_startproc
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
/* The following 'ret' will pop the address of the code and jump
|
|
Packit |
6c4009 |
to it. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
ret
|
|
Packit |
6c4009 |
PSEUDO_END(__setcontext)
|
|
Packit |
6c4009 |
libc_hidden_def (__setcontext)
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
weak_alias (__setcontext, setcontext)
|