ontop.S 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
  11. * ----------------------------------------------------------------------------------- *
  12. * | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
  13. * ----------------------------------------------------------------------------------- *
  14. * | EDI | ESI | EBX | EBP | EIP | hidden | to | data | *
  15. * ----------------------------------------------------------------------------------- *
  16. * *
  17. *****************************************************************************************/
  18. .text
  19. .globl ontop_fcontext
  20. .align 2
  21. .type ontop_fcontext,@function
  22. ontop_fcontext:
  23. pushl %ebp /* save EBP */
  24. pushl %ebx /* save EBX */
  25. pushl %esi /* save ESI */
  26. pushl %edi /* save EDI */
  27. /* store fcontext_t in ECX */
  28. movl %esp, %ecx
  29. /* first arg of ontop_fcontext() == fcontext to jump to */
  30. movl 0x18(%esp), %eax
  31. /* pass parent fcontext_t */
  32. movl %ecx, 0x18(%eax)
  33. /* second arg of ontop_fcontext() == data to be transferred */
  34. movl 0x1c(%esp), %ecx
  35. /* pass data */
  36. movl %ecx, 0x1c(%eax)
  37. /* third arg of ontop_fcontext() == ontop-function */
  38. movl 0x20(%esp), %ecx
  39. /* restore ESP (pointing to context-data) from EDX */
  40. movl %eax, %esp
  41. popl %edi /* restore EDI */
  42. popl %esi /* restore ESI */
  43. popl %ebx /* restore EBX */
  44. popl %ebp /* restore EBP */
  45. /* jump to context */
  46. jmp *%ecx
  47. .size ontop_fcontext,.-ontop_fcontext
  48. /* Mark that we don't need executable stack. */
  49. .section .note.GNU-stack,"",%progbits