1 | /* Copyright (C) 2002-2016 Free Software Foundation, Inc. |
2 | This file is part of the GNU C Library. |
3 | Contributed by Andreas Jaeger <aj@suse.de>, 2002. |
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 | <http://www.gnu.org/licenses/>. */ |
18 | |
19 | #include <sysdep.h> |
20 | |
21 | /* This is the helper code which gets called if a function which is |
22 | registered with 'makecontext' returns. In this case we have to |
23 | install the context listed in the uc_link element of the context |
24 | 'makecontext' manipulated at the time of the 'makecontext' call. |
25 | If the pointer is NULL the process must terminate. */ |
26 | |
27 | |
28 | ENTRY(__start_context) |
29 | /* This removes the parameters passed to the function given to |
30 | 'makecontext' from the stack. RBX contains the address |
31 | on the stack pointer for the next context. */ |
32 | movq %rbx, %rsp |
33 | |
34 | /* Don't use pop here so that stack is aligned to 16 bytes. */ |
35 | movq (%rsp), %rdi /* This is the next context. */ |
36 | testq %rdi, %rdi |
37 | je 2f /* If it is zero exit. */ |
38 | |
39 | call __setcontext |
40 | /* If this returns (which can happen if the syscall fails) we'll |
41 | exit the program with the return error value (-1). */ |
42 | movq %rax,%rdi |
43 | |
44 | 2: |
45 | call HIDDEN_JUMPTARGET(exit) |
46 | /* The 'exit' call should never return. In case it does cause |
47 | the process to terminate. */ |
48 | hlt |
49 | END(__start_context) |
50 | |