//
//===----------------------------------------------------------------------===//
+#include "assembly.h"
.text
# +-----------------------+ <-- SP
# + +
#
- .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
push %eax
movl 8(%esp), %eax
movl %ebx, 4(%eax)
# On entry:
# thread_state pointer is in rdi
#
- .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
movq %rax, (%rdi)
movq %rbx, 8(%rdi)
movq %rcx, 16(%rdi)
; On entry:
; thread_state pointer is in r3
;
- .globl _unw_getcontext
-_unw_getcontext:
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
stw r0, 8(r3)
mflr r0
stw r0, 0(r3) ; store lr as ssr0
; On entry:
; thread_state pointer is in x0
;
- .globl _unw_getcontext
-_unw_getcontext:
+ .p2align 2
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
stp x0, x1, [x0, #0x000]
stp x2, x3, [x0, #0x010]
stp x4, x5, [x0, #0x020]
ldr x0, #0 ; return UNW_ESUCCESS
ret
-#endif
+#elif __arm__ && !__APPLE__
+
+@
+@ extern int unw_getcontext(unw_context_t* thread_state)
+@
+@ On entry:
+@ thread_state pointer is in r0
+@
+ .p2align 2
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+ @ 32bit thumb-2 restrictions for stm:
+ @ . the sp (r13) cannot be in the list
+ @ . the pc (r15) cannot be in the list in an STM instruction
+ stm r0, {r0-r12}
+ str sp, [r0, #52]
+ str lr, [r0, #56]
+ str lr, [r0, #60] @ store return address as pc
+ mov r0, #0 @ return UNW_ESUCCESS
+ mov pc, lr
+#endif