siglongjmp.S 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2004 Hewlett-Packard Co
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. Copyright (C) 2011 Konstantin Belousov <kib@FreeBSD.org>
  5. This file is part of libunwind.
  6. Permission is hereby granted, free of charge, to any person obtaining
  7. a copy of this software and associated documentation files (the
  8. "Software"), to deal in the Software without restriction, including
  9. without limitation the rights to use, copy, modify, merge, publish,
  10. distribute, sublicense, and/or sell copies of the Software, and to
  11. permit persons to whom the Software is furnished to do so, subject to
  12. the following conditions:
  13. The above copyright notice and this permission notice shall be
  14. included in all copies or substantial portions of the Software.
  15. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  22. .globl _UI_siglongjmp_cont
  23. #if defined(__linux__)
  24. #define SIG_SETMASK 2
  25. #elif defined(__FreeBSD__)
  26. #define SIG_SETMASK 3
  27. #endif
  28. /* Stack layout at this point:
  29. +------------+ <- original $esp (at time of setjmp() call)
  30. | sigmask[1] |
  31. +------------+
  32. | sigmask[0] |
  33. +------------+
  34. */
  35. .type _UI_siglongjmp_cont, @function
  36. _UI_siglongjmp_cont:
  37. .cfi_startproc
  38. #ifdef __linux__
  39. .cfi_register 8, 0 /* IP saved in EAX */
  40. .cfi_def_cfa_offset 8
  41. mov %esp, %ecx /* pass address of signal mask in 3rd sc arg */
  42. push %eax /* save target IP */
  43. .cfi_adjust_cfa_offset 4
  44. .cfi_offset 8, -12
  45. push %edx /* save return value */
  46. .cfi_adjust_cfa_offset 4
  47. push %ebx /* save %ebx (preserved) */
  48. .cfi_adjust_cfa_offset 4
  49. .cfi_offset 3, -20
  50. mov $SIG_SETMASK, %ebx /* 1st syscall arg (how) */
  51. xor %edx, %edx /* pass NULL as 3rd syscall arg (old maskp) */
  52. int $0x80
  53. pop %ebx /* restore %ebx */
  54. .cfi_adjust_cfa_offset -4
  55. .cfi_restore 3
  56. pop %eax /* fetch return value */
  57. .cfi_adjust_cfa_offset -4
  58. pop %edx /* pop target IP */
  59. .cfi_adjust_cfa_offset -4
  60. .cfi_register 8, 2 /* saved IP is now n EDX */
  61. lea 8(%esp), %esp /* pop sigmask */
  62. .cfi_adjust_cfa_offset -4
  63. jmp *%edx
  64. #elif defined(__FreeBSD__)
  65. pushl %eax
  66. pushl %edx
  67. pushl $0
  68. pushl %ecx
  69. pushl $SIG_SETMASK
  70. movl $340,%eax
  71. pushl %eax
  72. int $0x80
  73. addl $16,%esp
  74. popl %eax
  75. popl %edx
  76. jmp *%edx
  77. #else
  78. #error Port me
  79. #endif
  80. .cfi_endproc
  81. .size _UI_siglongjmp_cont, .-_UI_siglongjmp_cont
  82. /* We do not need executable stack. */
  83. .section .note.GNU-stack,"",@progbits