getcontext.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2008 CodeSourcery
  3. This file is part of libunwind.
  4. Permission is hereby granted, free of charge, to any person obtaining
  5. a copy of this software and associated documentation files (the
  6. "Software"), to deal in the Software without restriction, including
  7. without limitation the rights to use, copy, modify, merge, publish,
  8. distribute, sublicense, and/or sell copies of the Software, and to
  9. permit persons to whom the Software is furnished to do so, subject to
  10. the following conditions:
  11. The above copyright notice and this permission notice shall be
  12. included in all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  15. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  17. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  18. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  19. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  20. #include "offsets.h"
  21. .text
  22. .arm
  23. .global _Uarm_getcontext
  24. .type _Uarm_getcontext, %function
  25. @ This is a stub version of getcontext() for ARM which only stores core
  26. @ registers. It must be called in a special way, not as a regular
  27. @ function -- see also the libunwind-arm.h:unw_tdep_getcontext macro.
  28. _Uarm_getcontext:
  29. stmfd sp!, {r0, r1}
  30. @ store r0
  31. str r0, [r0, #LINUX_UC_MCONTEXT_OFF + LINUX_SC_R0_OFF]
  32. add r0, r0, #LINUX_UC_MCONTEXT_OFF + LINUX_SC_R0_OFF
  33. @ store r1 to r12
  34. stmib r0, {r1-r12}
  35. @ reconstruct r13 at call site, then store
  36. add r1, sp, #12
  37. str r1, [r0, #13 * 4]
  38. @ retrieve r14 from call site, then store
  39. ldr r1, [sp, #8]
  40. str r1, [r0, #14 * 4]
  41. @ point lr to instruction after call site's stack adjustment
  42. add r1, lr, #4
  43. str r1, [r0, #15 * 4]
  44. ldmfd sp!, {r0, r1}
  45. bx lr
  46. #ifdef __linux__
  47. /* We do not need executable stack. */
  48. .section .note.GNU-stack,"",%progbits
  49. #endif