xref: /PHP-8.3/Zend/asm/jump_i386_sysv_elf_gas.S (revision 49551d7c)
1/*
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)
6*/
7
8/****************************************************************************************
9 *                                                                                      *
10 *  ----------------------------------------------------------------------------------  *
11 *  |    0    |    1    |    2    |    3    |    4     |    5    |    6    |    7    |  *
12 *  ----------------------------------------------------------------------------------  *
13 *  |   0x0   |   0x4   |   0x8   |   0xc   |   0x10   |   0x14  |   0x18  |   0x1c  |  *
14 *  ----------------------------------------------------------------------------------  *
15 *  | fc_mxcsr|fc_x87_cw|  guard  |   EDI   |   ESI    |   EBX   |   EBP   |   EIP   |  *
16 *  ----------------------------------------------------------------------------------  *
17 *  ----------------------------------------------------------------------------------  *
18 *  |    8    |    9    |    10   |    11   |    12    |    13   |    14   |    15   |  *
19 *  ----------------------------------------------------------------------------------  *
20 *  |   0x20  |   0x24  |   0x28  |                                                  |  *
21 *  ----------------------------------------------------------------------------------  *
22 *  |  hidden |    to   |   data  |                                                  |  *
23 *  ----------------------------------------------------------------------------------  *
24 *                                                                                      *
25 ****************************************************************************************/
26
27.file "jump_i386_sysv_elf_gas.S"
28.text
29.globl jump_fcontext
30.align 2
31.type jump_fcontext,@function
32jump_fcontext:
33    leal  -0x1c(%esp), %esp  /* prepare stack */
34
35#if !defined(BOOST_USE_TSX)
36    stmxcsr  (%esp)     /* save MMX control- and status-word */
37    fnstcw   0x4(%esp)  /* save x87 control-word */
38#endif
39
40#if defined(BOOST_CONTEXT_TLS_STACK_PROTECTOR)
41    movl  %gs:0x14, %ecx    /* read stack guard from TLS record */
42    movl  %ecx, 0x8(%esp)   /* save stack guard */
43#endif
44
45    movl  %edi, 0xc(%esp)   /* save EDI */
46    movl  %esi, 0x10(%esp)  /* save ESI */
47    movl  %ebx, 0x14(%esp)  /* save EBX */
48    movl  %ebp, 0x18(%esp)  /* save EBP */
49
50    /* store ESP (pointing to context-data) in ECX */
51    movl  %esp, %ecx
52
53    /* first arg of jump_fcontext() == fcontext to jump to */
54    movl  0x24(%esp), %eax
55
56    /* second arg of jump_fcontext() == data to be transferred */
57    movl  0x28(%esp), %edx
58
59    /* restore ESP (pointing to context-data) from EAX */
60    movl  %eax, %esp
61
62    /* address of returned transport_t */
63    movl 0x20(%esp), %eax
64    /* return parent fcontext_t */
65    movl  %ecx, (%eax)
66    /* return data */
67    movl %edx, 0x4(%eax)
68
69    movl  0x1c(%esp), %ecx  /* restore EIP */
70
71#if !defined(BOOST_USE_TSX)
72    ldmxcsr  (%esp)     /* restore MMX control- and status-word */
73    fldcw    0x4(%esp)  /* restore x87 control-word */
74#endif
75
76#if defined(BOOST_CONTEXT_TLS_STACK_PROTECTOR)
77    movl  0x8(%esp), %edx  /* load stack guard */
78    movl  %edx, %gs:0x14   /* restore stack guard to TLS record */
79#endif
80
81    movl  0xc(%esp), %edi  /* restore EDI */
82    movl  0x10(%esp), %esi  /* restore ESI */
83    movl  0x14(%esp), %ebx  /* restore EBX */
84    movl  0x18(%esp), %ebp  /* restore EBP */
85
86    leal  0x24(%esp), %esp  /* prepare stack */
87
88    /* jump to context */
89    jmp *%ecx
90.size jump_fcontext,.-jump_fcontext
91
92/* Mark that we don't need executable stack.  */
93.section .note.GNU-stack,"",%progbits
94