arm-unwind-resume.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright (C) 2003, 2005, 2010 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Jakub Jelinek <jakub@redhat.com>.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public License as
  6. published by the Free Software Foundation; either version 2.1 of the
  7. License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; see the file COPYING.LIB. If
  14. not, see <http://www.gnu.org/licenses/>. */
  15. /* It's vitally important that _Unwind_Resume not have a stack frame; the
  16. ARM unwinder relies on register state at entrance. So we write this in
  17. assembly. */
  18. #include <sysdep.h>
  19. __asm__ (
  20. " .globl _Unwind_Resume\n"
  21. " .hidden _Unwind_Resume\n"
  22. " .type _Unwind_Resume, %function\n"
  23. "_Unwind_Resume:\n"
  24. " " CFI_SECTIONS (.debug_frame) "\n"
  25. " " CFI_STARTPROC "\n"
  26. " stmfd sp!, {r4, r5, r6, lr}\n"
  27. " " CFI_ADJUST_CFA_OFFSET (16)" \n"
  28. " " CFI_REL_OFFSET (r4, 0) "\n"
  29. " " CFI_REL_OFFSET (r5, 4) "\n"
  30. " " CFI_REL_OFFSET (r6, 8) "\n"
  31. " " CFI_REL_OFFSET (lr, 12) "\n"
  32. " " CFI_REMEMBER_STATE "\n"
  33. " ldr r4, 1f\n"
  34. " ldr r5, 2f\n"
  35. "3: add r4, pc, r4\n"
  36. " ldr r3, [r4, r5]\n"
  37. " mov r6, r0\n"
  38. " cmp r3, #0\n"
  39. " beq 4f\n"
  40. "5: mov r0, r6\n"
  41. " ldmfd sp!, {r4, r5, r6, lr}\n"
  42. " " CFI_ADJUST_CFA_OFFSET (-16) "\n"
  43. " " CFI_RESTORE (r4) "\n"
  44. " " CFI_RESTORE (r5) "\n"
  45. " " CFI_RESTORE (r6) "\n"
  46. " " CFI_RESTORE (lr) "\n"
  47. " bx r3\n"
  48. " " CFI_RESTORE_STATE "\n"
  49. "4: bl __libgcc_s_init\n"
  50. " ldr r3, [r4, r5]\n"
  51. " b 5b\n"
  52. " " CFI_ENDPROC "\n"
  53. " .align 2\n"
  54. #ifdef __thumb2__
  55. "1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 4\n"
  56. #else
  57. "1: .word _GLOBAL_OFFSET_TABLE_ - 3b - 8\n"
  58. #endif
  59. "2: .word __libgcc_s_resume(GOTOFF)\n"
  60. " .size _Unwind_Resume, .-_Unwind_Resume\n"
  61. );