/* Load address of the context data structure. */
movl 4(%esp), %eax
- /* Save the preserved register values and the return address. */
+ /* Return value of getcontext. EAX is the only register whose
+ value is not preserved. */
+ movl $0, oEAX(%eax)
+
+ /* Save the 32-bit register values and the return address. */
+ movl %ecx, oECX(%eax)
+ movl %edx, oEDX(%eax)
movl %edi, oEDI(%eax)
movl %esi, oESI(%eax)
movl %ebp, oEBP(%eax)
cfi_offset (esi, oESI)
cfi_offset (ebp, oEBP)
cfi_offset (ebx, oEBX)
+ cfi_offset (edx, oEDX)
+ cfi_offset (ecx, oECX)
movl oESP(%eax), %esp
#if SHSTK_ENABLED
/* Push the return address on the new stack so we can return there. */
pushl %ecx
- /* Load the values of all the preserved registers (except ESP). */
+ /* Load the values of all the 32-bit registers (except ESP).
+ Since we are loading from EAX, it must be last. */
movl oEDI(%eax), %edi
movl oESI(%eax), %esi
movl oEBP(%eax), %ebp
movl oEBX(%eax), %ebx
-
- /* All done, return 0 for success. */
- xorl %eax, %eax
+ movl oEDX(%eax), %edx
+ movl oECX(%eax), %ecx
+ movl oEAX(%eax), %eax
/* End FDE here, we fall into another context. */
cfi_endproc
/* Load address of the context data structure we save in. */
movl 4(%esp), %eax
- /* Save the preserved register values and the return address. */
+ /* Return value of swapcontext. EAX is the only register whose
+ value is not preserved. */
+ movl $0, oEAX(%eax)
+
+ /* Save the 32-bit register values and the return address. */
+ movl %ecx, oECX(%eax)
+ movl %edx, oEDX(%eax)
movl %edi, oEDI(%eax)
movl %esi, oESI(%eax)
movl %ebp, oEBP(%eax)
/* Push the return address on the new stack so we can return there. */
pushl %ecx
- /* Load the values of all the preserved registers (except ESP). */
+ /* Load the values of all the 32-bit registers (except ESP).
+ Since we are loading from EAX, it must be last. */
movl oEDI(%eax), %edi
movl oESI(%eax), %esi
movl oEBP(%eax), %ebp
movl oEBX(%eax), %ebx
-
- /* All done, return 0 for success. */
- xorl %eax, %eax
+ movl oEDX(%eax), %edx
+ movl oECX(%eax), %ecx
+ movl oEAX(%eax), %eax
/* The following 'ret' will pop the address of the code and jump
to it. */