2 Copyright Oliver Kowalke 2009.
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
8 /****************************************************************************************
10 * ---------------------------------------------------------------------------------- *
11 * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
12 * ---------------------------------------------------------------------------------- *
13 * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
14 * ---------------------------------------------------------------------------------- *
15 * | R12 | R13 | R14 | R15 | *
16 * ---------------------------------------------------------------------------------- *
17 * ---------------------------------------------------------------------------------- *
18 * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
19 * ---------------------------------------------------------------------------------- *
20 * | 0x20 | 0x24 | 0x28 | 0x2c | 0x30 | 0x34 | 0x38 | 0x3c | *
21 * ---------------------------------------------------------------------------------- *
22 * | RBX | RBP | RIP | EXIT | *
23 * ---------------------------------------------------------------------------------- *
25 ****************************************************************************************/
29 .type jump_fcontext,@function
32 pushq %rbp /* save RBP */
33 pushq %rbx /* save RBX */
34 pushq %r15 /* save R15 */
35 pushq %r14 /* save R14 */
36 pushq %r13 /* save R13 */
37 pushq %r12 /* save R12 */
39 /* store RSP (pointing to context-data) in RAX */
42 /* restore RSP (pointing to context-data) from RDI */
45 popq %r12 /* restrore R12 */
46 popq %r13 /* restrore R13 */
47 popq %r14 /* restrore R14 */
48 popq %r15 /* restrore R15 */
49 popq %rbx /* restrore RBX */
50 popq %rbp /* restrore RBP */
52 /* restore return-address */
55 /* return transfer_t from jump */
56 /* RAX == fctx, RDX == data */
58 /* pass transfer_t as first arg in context function */
59 /* RDI == fctx, RSI == data */
62 /* indirect jump to context */
64 .size jump_fcontext,.-jump_fcontext
66 /* Mark that we don't need executable stack. */
67 .section .note.GNU-stack,"",%progbits