1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 #define FROM_0_TO_15 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
12 #define FROM_16_TO_31 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
14 #define FROM_0_TO_31 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
15 #define FROM_32_TO_63 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
23 #if !defined(__USING_SJLJ_EXCEPTIONS__)
28 # extern int __unw_getcontext(unw_context_t* thread_state)
32 # +-----------------------+
33 # + thread_state pointer +
34 # +-----------------------+
36 # +-----------------------+ <-- SP
39 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
52 movl %edx, 28(%eax) # store what sp was at call site as esp
56 movl %edx, 40(%eax) # store return address as eip
63 movl %edx, (%eax) # store original eax
65 xorl %eax, %eax # return UNW_ESUCCESS
68 #elif defined(__x86_64__)
71 # extern int __unw_getcontext(unw_context_t* thread_state)
74 # thread_state pointer is in rdi
76 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
104 movq TMP,128(PTR) # store return address as rip
111 movdqu %xmm0,176(PTR)
112 movdqu %xmm1,192(PTR)
113 movdqu %xmm2,208(PTR)
114 movdqu %xmm3,224(PTR)
115 movdqu %xmm4,240(PTR)
116 movdqu %xmm5,256(PTR)
117 movdqu %xmm6,272(PTR)
118 movdqu %xmm7,288(PTR)
119 movdqu %xmm8,304(PTR)
120 movdqu %xmm9,320(PTR)
121 movdqu %xmm10,336(PTR)
122 movdqu %xmm11,352(PTR)
123 movdqu %xmm12,368(PTR)
124 movdqu %xmm13,384(PTR)
125 movdqu %xmm14,400(PTR)
126 movdqu %xmm15,416(PTR)
128 xorl %eax, %eax # return UNW_ESUCCESS
131 #elif defined(__mips__) && defined(_ABIO32) && _MIPS_SIM == _ABIO32
134 # extern int __unw_getcontext(unw_context_t* thread_state)
137 # thread_state pointer is in a0 ($4)
139 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
175 # Store return address to pc
177 #if __mips_isa_rev < 6
184 #ifdef __mips_hard_float
186 sdc1 $f0, (4 * 36 + 8 * 0)($4)
187 sdc1 $f2, (4 * 36 + 8 * 2)($4)
188 sdc1 $f4, (4 * 36 + 8 * 4)($4)
189 sdc1 $f6, (4 * 36 + 8 * 6)($4)
190 sdc1 $f8, (4 * 36 + 8 * 8)($4)
191 sdc1 $f10, (4 * 36 + 8 * 10)($4)
192 sdc1 $f12, (4 * 36 + 8 * 12)($4)
193 sdc1 $f14, (4 * 36 + 8 * 14)($4)
194 sdc1 $f16, (4 * 36 + 8 * 16)($4)
195 sdc1 $f18, (4 * 36 + 8 * 18)($4)
196 sdc1 $f20, (4 * 36 + 8 * 20)($4)
197 sdc1 $f22, (4 * 36 + 8 * 22)($4)
198 sdc1 $f24, (4 * 36 + 8 * 24)($4)
199 sdc1 $f26, (4 * 36 + 8 * 26)($4)
200 sdc1 $f28, (4 * 36 + 8 * 28)($4)
201 sdc1 $f30, (4 * 36 + 8 * 30)($4)
203 sdc1 $f0, (4 * 36 + 8 * 0)($4)
204 sdc1 $f1, (4 * 36 + 8 * 1)($4)
205 sdc1 $f2, (4 * 36 + 8 * 2)($4)
206 sdc1 $f3, (4 * 36 + 8 * 3)($4)
207 sdc1 $f4, (4 * 36 + 8 * 4)($4)
208 sdc1 $f5, (4 * 36 + 8 * 5)($4)
209 sdc1 $f6, (4 * 36 + 8 * 6)($4)
210 sdc1 $f7, (4 * 36 + 8 * 7)($4)
211 sdc1 $f8, (4 * 36 + 8 * 8)($4)
212 sdc1 $f9, (4 * 36 + 8 * 9)($4)
213 sdc1 $f10, (4 * 36 + 8 * 10)($4)
214 sdc1 $f11, (4 * 36 + 8 * 11)($4)
215 sdc1 $f12, (4 * 36 + 8 * 12)($4)
216 sdc1 $f13, (4 * 36 + 8 * 13)($4)
217 sdc1 $f14, (4 * 36 + 8 * 14)($4)
218 sdc1 $f15, (4 * 36 + 8 * 15)($4)
219 sdc1 $f16, (4 * 36 + 8 * 16)($4)
220 sdc1 $f17, (4 * 36 + 8 * 17)($4)
221 sdc1 $f18, (4 * 36 + 8 * 18)($4)
222 sdc1 $f19, (4 * 36 + 8 * 19)($4)
223 sdc1 $f20, (4 * 36 + 8 * 20)($4)
224 sdc1 $f21, (4 * 36 + 8 * 21)($4)
225 sdc1 $f22, (4 * 36 + 8 * 22)($4)
226 sdc1 $f23, (4 * 36 + 8 * 23)($4)
227 sdc1 $f24, (4 * 36 + 8 * 24)($4)
228 sdc1 $f25, (4 * 36 + 8 * 25)($4)
229 sdc1 $f26, (4 * 36 + 8 * 26)($4)
230 sdc1 $f27, (4 * 36 + 8 * 27)($4)
231 sdc1 $f28, (4 * 36 + 8 * 28)($4)
232 sdc1 $f29, (4 * 36 + 8 * 29)($4)
233 sdc1 $f30, (4 * 36 + 8 * 30)($4)
234 sdc1 $f31, (4 * 36 + 8 * 31)($4)
238 # return UNW_ESUCCESS
242 #elif defined(__mips64)
245 # extern int __unw_getcontext(unw_context_t* thread_state)
248 # thread_state pointer is in a0 ($4)
250 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
255 .irp i,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
258 # Store return address to pc
260 #if __mips_isa_rev < 6
267 #ifdef __mips_hard_float
269 sdc1 $f\i, (280+8*\i)($4)
273 # return UNW_ESUCCESS
277 # elif defined(__mips__)
280 # extern int __unw_getcontext(unw_context_t* thread_state)
282 # Just trap for the time being.
283 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
286 #elif defined(__powerpc64__)
289 // extern int __unw_getcontext(unw_context_t* thread_state)
292 // thread_state pointer is in r3
295 DEFINE_LIBUNWIND_FUNCTION_AND_WEAK_ALIAS(__unw_getcontext, unw_getcontext)
297 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
299 // store register (GPR)
300 #define PPC64_STR(n) \
301 std n, (8 * (n + 2))(3)
306 std 0, PPC64_OFFS_SRR0(3) // store lr as ssr0
308 PPC64_STR(4) // Save r4 first since it will be used for fixing r2.
310 // The TOC register (r2) was changed by the glue code if unw_getcontext
311 // is called from a different module. Save the original TOC register
312 // in the context if this is the case.
314 lwz 4, 0(4) // Get the first instruction at the return address.
315 xoris 0, 4, 0xe841 // Is it reloading the TOC register "ld 2,40(1)"?
317 bne 0, LnoR2Fix // No need to fix up r2 if it is not.
318 ld 2, 40(1) // Use the saved TOC register in the stack.
352 std 0, PPC64_OFFS_CR(3)
354 std 0, PPC64_OFFS_XER(3)
356 // LR value saved from the register is not used, initialize it to 0.
361 std 0, PPC64_OFFS_LR(3)
363 std 0, PPC64_OFFS_CTR(3)
365 std 0, PPC64_OFFS_VRSAVE(3)
369 // (note that this also saves floating point registers and V registers,
370 // because part of VS is mapped to these registers)
372 addi 4, 3, PPC64_OFFS_FP
375 #ifdef __LITTLE_ENDIAN__
376 // For little-endian targets, we need a swap since stxvd2x will store the
377 // register in the incorrect doubleword order.
378 // FIXME: when supporting targets older than Power9 on LE is no longer required
379 // this can be changed to simply `stxv n, 16 * n(4)`.
380 #define PPC64_STVS(n) \
385 #define PPC64_STVS(n) \
458 #define PPC64_STF(n) \
459 stfd n, (PPC64_OFFS_FP + n * 16)(3)
461 // save float registers
495 #if defined(__ALTIVEC__)
496 // save vector registers
498 // Use 16-bytes below the stack pointer as an
499 // aligned buffer to save each vector register.
500 // Note that the stack pointer is always 16-byte aligned.
503 #define PPC64_STV_UNALIGNED(n) \
506 std 5, (PPC64_OFFS_V + n * 16)(3) ;\
508 std 5, (PPC64_OFFS_V + n * 16 + 8)(3)
510 PPC64_STV_UNALIGNED(0)
511 PPC64_STV_UNALIGNED(1)
512 PPC64_STV_UNALIGNED(2)
513 PPC64_STV_UNALIGNED(3)
514 PPC64_STV_UNALIGNED(4)
515 PPC64_STV_UNALIGNED(5)
516 PPC64_STV_UNALIGNED(6)
517 PPC64_STV_UNALIGNED(7)
518 PPC64_STV_UNALIGNED(8)
519 PPC64_STV_UNALIGNED(9)
520 PPC64_STV_UNALIGNED(10)
521 PPC64_STV_UNALIGNED(11)
522 PPC64_STV_UNALIGNED(12)
523 PPC64_STV_UNALIGNED(13)
524 PPC64_STV_UNALIGNED(14)
525 PPC64_STV_UNALIGNED(15)
526 PPC64_STV_UNALIGNED(16)
527 PPC64_STV_UNALIGNED(17)
528 PPC64_STV_UNALIGNED(18)
529 PPC64_STV_UNALIGNED(19)
530 PPC64_STV_UNALIGNED(20)
531 PPC64_STV_UNALIGNED(21)
532 PPC64_STV_UNALIGNED(22)
533 PPC64_STV_UNALIGNED(23)
534 PPC64_STV_UNALIGNED(24)
535 PPC64_STV_UNALIGNED(25)
536 PPC64_STV_UNALIGNED(26)
537 PPC64_STV_UNALIGNED(27)
538 PPC64_STV_UNALIGNED(28)
539 PPC64_STV_UNALIGNED(29)
540 PPC64_STV_UNALIGNED(30)
541 PPC64_STV_UNALIGNED(31)
546 li 3, 0 // return UNW_ESUCCESS
550 #elif defined(__powerpc__)
553 // extern int unw_getcontext(unw_context_t* thread_state)
556 // thread_state pointer is in r3
559 DEFINE_LIBUNWIND_FUNCTION_AND_WEAK_ALIAS(__unw_getcontext, unw_getcontext)
561 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
565 stw 0, 0(3) // store lr as ssr0
567 stw 4, 24(3) // Save r4 first since it will be used for fixing r2.
569 // The TOC register (r2) was changed by the glue code if unw_getcontext
570 // is called from a different module. Save the original TOC register
571 // in the context if this is the case.
573 lwz 4, 0(4) // Get the instruction at the return address.
574 xoris 0, 4, 0x8041 // Is it reloading the TOC register "lwz 2,20(1)"?
576 bne 0, LnoR2Fix // No need to fix up r2 if it is not.
577 lwz 2, 20(1) // Use the saved TOC register in the stack.
610 #if defined(__ALTIVEC__)
611 // save VRSave register
619 // LR value from the register is not used, initialize it to 0.
627 #if !defined(__NO_FPRS__)
628 // save float registers
663 #if defined(__ALTIVEC__)
664 // save vector registers
667 rlwinm 4, 4, 0, 0, 27 // mask low 4-bits
668 // r4 is now a 16-byte aligned pointer into the red zone
670 #define SAVE_VECTOR_UNALIGNED(_vec, _offset) \
671 stvx _vec, 0, 4 SEPARATOR \
672 lwz 5, 0(4) SEPARATOR \
673 stw 5, _offset(3) SEPARATOR \
674 lwz 5, 4(4) SEPARATOR \
675 stw 5, _offset+4(3) SEPARATOR \
676 lwz 5, 8(4) SEPARATOR \
677 stw 5, _offset+8(3) SEPARATOR \
678 lwz 5, 12(4) SEPARATOR \
681 SAVE_VECTOR_UNALIGNED( 0, 424+0x000)
682 SAVE_VECTOR_UNALIGNED( 1, 424+0x010)
683 SAVE_VECTOR_UNALIGNED( 2, 424+0x020)
684 SAVE_VECTOR_UNALIGNED( 3, 424+0x030)
685 SAVE_VECTOR_UNALIGNED( 4, 424+0x040)
686 SAVE_VECTOR_UNALIGNED( 5, 424+0x050)
687 SAVE_VECTOR_UNALIGNED( 6, 424+0x060)
688 SAVE_VECTOR_UNALIGNED( 7, 424+0x070)
689 SAVE_VECTOR_UNALIGNED( 8, 424+0x080)
690 SAVE_VECTOR_UNALIGNED( 9, 424+0x090)
691 SAVE_VECTOR_UNALIGNED(10, 424+0x0A0)
692 SAVE_VECTOR_UNALIGNED(11, 424+0x0B0)
693 SAVE_VECTOR_UNALIGNED(12, 424+0x0C0)
694 SAVE_VECTOR_UNALIGNED(13, 424+0x0D0)
695 SAVE_VECTOR_UNALIGNED(14, 424+0x0E0)
696 SAVE_VECTOR_UNALIGNED(15, 424+0x0F0)
697 SAVE_VECTOR_UNALIGNED(16, 424+0x100)
698 SAVE_VECTOR_UNALIGNED(17, 424+0x110)
699 SAVE_VECTOR_UNALIGNED(18, 424+0x120)
700 SAVE_VECTOR_UNALIGNED(19, 424+0x130)
701 SAVE_VECTOR_UNALIGNED(20, 424+0x140)
702 SAVE_VECTOR_UNALIGNED(21, 424+0x150)
703 SAVE_VECTOR_UNALIGNED(22, 424+0x160)
704 SAVE_VECTOR_UNALIGNED(23, 424+0x170)
705 SAVE_VECTOR_UNALIGNED(24, 424+0x180)
706 SAVE_VECTOR_UNALIGNED(25, 424+0x190)
707 SAVE_VECTOR_UNALIGNED(26, 424+0x1A0)
708 SAVE_VECTOR_UNALIGNED(27, 424+0x1B0)
709 SAVE_VECTOR_UNALIGNED(28, 424+0x1C0)
710 SAVE_VECTOR_UNALIGNED(29, 424+0x1D0)
711 SAVE_VECTOR_UNALIGNED(30, 424+0x1E0)
712 SAVE_VECTOR_UNALIGNED(31, 424+0x1F0)
715 li 3, 0 // return UNW_ESUCCESS
719 #elif defined(__aarch64__)
722 // extern int __unw_getcontext(unw_context_t* thread_state)
725 // thread_state pointer is in x0
728 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
729 stp x0, x1, [x0, #0x000]
730 stp x2, x3, [x0, #0x010]
731 stp x4, x5, [x0, #0x020]
732 stp x6, x7, [x0, #0x030]
733 stp x8, x9, [x0, #0x040]
734 stp x10,x11, [x0, #0x050]
735 stp x12,x13, [x0, #0x060]
736 stp x14,x15, [x0, #0x070]
737 stp x16,x17, [x0, #0x080]
738 stp x18,x19, [x0, #0x090]
739 stp x20,x21, [x0, #0x0A0]
740 stp x22,x23, [x0, #0x0B0]
741 stp x24,x25, [x0, #0x0C0]
742 stp x26,x27, [x0, #0x0D0]
743 stp x28,x29, [x0, #0x0E0]
744 str x30, [x0, #0x0F0]
747 str x30, [x0, #0x100] // store return address as pc
749 stp d0, d1, [x0, #0x110]
750 stp d2, d3, [x0, #0x120]
751 stp d4, d5, [x0, #0x130]
752 stp d6, d7, [x0, #0x140]
753 stp d8, d9, [x0, #0x150]
754 stp d10,d11, [x0, #0x160]
755 stp d12,d13, [x0, #0x170]
756 stp d14,d15, [x0, #0x180]
757 stp d16,d17, [x0, #0x190]
758 stp d18,d19, [x0, #0x1A0]
759 stp d20,d21, [x0, #0x1B0]
760 stp d22,d23, [x0, #0x1C0]
761 stp d24,d25, [x0, #0x1D0]
762 stp d26,d27, [x0, #0x1E0]
763 stp d28,d29, [x0, #0x1F0]
764 str d30, [x0, #0x200]
765 str d31, [x0, #0x208]
766 mov x0, #0 // return UNW_ESUCCESS
769 #elif defined(__arm__) && !defined(__APPLE__)
771 #if !defined(__ARM_ARCH_ISA_ARM)
772 #if (__ARM_ARCH_ISA_THUMB == 2)
779 @ extern int __unw_getcontext(unw_context_t* thread_state)
782 @ thread_state pointer is in r0
784 @ Per EHABI #4.7 this only saves the core integer registers.
785 @ EHABI #7.4.5 notes that in general all VRS registers should be restored
786 @ however this is very hard to do for VFP registers because it is unknown
787 @ to the library how many registers are implemented by the architecture.
788 @ Instead, VFP registers are demand saved by logic external to __unw_getcontext.
791 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
792 #if !defined(__ARM_ARCH_ISA_ARM) && __ARM_ARCH_ISA_THUMB == 1
801 str r1, [r0, #0] @ r11
802 @ r12 does not need storing, it it the intra-procedure-call scratch register
803 str r2, [r0, #8] @ sp
804 str r3, [r0, #12] @ lr
805 str r3, [r0, #16] @ store return address as pc
806 @ T1 does not have a non-cpsr-clobbering register-zeroing instruction.
807 @ It is safe to use here though because we are about to return, and cpsr is
808 @ not expected to be preserved.
809 movs r0, #0 @ return UNW_ESUCCESS
811 @ 32bit thumb-2 restrictions for stm:
812 @ . the sp (r13) cannot be in the list
813 @ . the pc (r15) cannot be in the list in an STM instruction
817 str lr, [r0, #60] @ store return address as pc
818 mov r0, #0 @ return UNW_ESUCCESS
823 @ static void libunwind::Registers_arm::saveVFPWithFSTMD(unw_fpreg_t* values)
826 @ values pointer is in r0
832 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMDEPv)
837 @ static void libunwind::Registers_arm::saveVFPWithFSTMX(unw_fpreg_t* values)
840 @ values pointer is in r0
846 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveVFPWithFSTMXEPv)
847 vstmia r0, {d0-d15} @ fstmiax is deprecated in ARMv7+ and now behaves like vstmia
851 @ static void libunwind::Registers_arm::saveVFPv3(unw_fpreg_t* values)
854 @ values pointer is in r0
860 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveVFPv3EPv)
861 @ VFP and iwMMX instructions are only available when compiling with the flags
862 @ that enable them. We do not want to do that in the library (because we do not
863 @ want the compiler to generate instructions that access those) but this is
864 @ only accessed if the personality routine needs these registers. Use of
865 @ these registers implies they are, actually, available on the target, so
866 @ it's ok to execute.
867 @ So, generate the instructions using the corresponding coprocessor mnemonic.
871 #if defined(_LIBUNWIND_ARM_WMMX)
874 @ static void libunwind::Registers_arm::saveiWMMX(unw_fpreg_t* values)
877 @ values pointer is in r0
883 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm9saveiWMMXEPv)
884 stcl p1, cr0, [r0], #8 @ wstrd wR0, [r0], #8
885 stcl p1, cr1, [r0], #8 @ wstrd wR1, [r0], #8
886 stcl p1, cr2, [r0], #8 @ wstrd wR2, [r0], #8
887 stcl p1, cr3, [r0], #8 @ wstrd wR3, [r0], #8
888 stcl p1, cr4, [r0], #8 @ wstrd wR4, [r0], #8
889 stcl p1, cr5, [r0], #8 @ wstrd wR5, [r0], #8
890 stcl p1, cr6, [r0], #8 @ wstrd wR6, [r0], #8
891 stcl p1, cr7, [r0], #8 @ wstrd wR7, [r0], #8
892 stcl p1, cr8, [r0], #8 @ wstrd wR8, [r0], #8
893 stcl p1, cr9, [r0], #8 @ wstrd wR9, [r0], #8
894 stcl p1, cr10, [r0], #8 @ wstrd wR10, [r0], #8
895 stcl p1, cr11, [r0], #8 @ wstrd wR11, [r0], #8
896 stcl p1, cr12, [r0], #8 @ wstrd wR12, [r0], #8
897 stcl p1, cr13, [r0], #8 @ wstrd wR13, [r0], #8
898 stcl p1, cr14, [r0], #8 @ wstrd wR14, [r0], #8
899 stcl p1, cr15, [r0], #8 @ wstrd wR15, [r0], #8
903 @ static void libunwind::Registers_arm::saveiWMMXControl(unw_uint32_t* values)
906 @ values pointer is in r0
912 DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_arm16saveiWMMXControlEPj)
913 stc2 p1, cr8, [r0], #4 @ wstrw wCGR0, [r0], #4
914 stc2 p1, cr9, [r0], #4 @ wstrw wCGR1, [r0], #4
915 stc2 p1, cr10, [r0], #4 @ wstrw wCGR2, [r0], #4
916 stc2 p1, cr11, [r0], #4 @ wstrw wCGR3, [r0], #4
921 #elif defined(__or1k__)
924 # extern int __unw_getcontext(unw_context_t* thread_state)
927 # thread_state pointer is in r3
929 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
967 #elif defined(__hexagon__)
969 # extern int unw_getcontext(unw_context_t* thread_state)
972 # thread_state pointer is in r0
974 #define OFFSET(offset) (offset/4)
975 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1005 r1 = c4 // Predicate register
1007 r1 = memw(r30) // *FP == Saved FP
1013 #elif defined(__sparc__) && defined(__arch64__)
1016 # extern int __unw_getcontext(unw_context_t* thread_state)
1019 # thread_state pointer is in %o0
1021 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1022 .register %g2, #scratch
1023 .register %g3, #scratch
1024 .register %g6, #scratch
1025 .register %g7, #scratch
1026 stx %g1, [%o0 + 0x08]
1027 stx %g2, [%o0 + 0x10]
1028 stx %g3, [%o0 + 0x18]
1029 stx %g4, [%o0 + 0x20]
1030 stx %g5, [%o0 + 0x28]
1031 stx %g6, [%o0 + 0x30]
1032 stx %g7, [%o0 + 0x38]
1033 stx %o0, [%o0 + 0x40]
1034 stx %o1, [%o0 + 0x48]
1035 stx %o2, [%o0 + 0x50]
1036 stx %o3, [%o0 + 0x58]
1037 stx %o4, [%o0 + 0x60]
1038 stx %o5, [%o0 + 0x68]
1039 stx %o6, [%o0 + 0x70]
1040 stx %o7, [%o0 + 0x78]
1041 stx %l0, [%o0 + 0x80]
1042 stx %l1, [%o0 + 0x88]
1043 stx %l2, [%o0 + 0x90]
1044 stx %l3, [%o0 + 0x98]
1045 stx %l4, [%o0 + 0xa0]
1046 stx %l5, [%o0 + 0xa8]
1047 stx %l6, [%o0 + 0xb0]
1048 stx %l7, [%o0 + 0xb8]
1049 stx %i0, [%o0 + 0xc0]
1050 stx %i1, [%o0 + 0xc8]
1051 stx %i2, [%o0 + 0xd0]
1052 stx %i3, [%o0 + 0xd8]
1053 stx %i4, [%o0 + 0xe0]
1054 stx %i5, [%o0 + 0xe8]
1055 stx %i6, [%o0 + 0xf0]
1056 stx %i7, [%o0 + 0xf8]
1058 # save StackGhost cookie
1061 # register window flush necessary even without StackGhost
1064 ldx [%sp + 2047 + 0x78], %g5
1066 stx %g4, [%o0 + 0x100]
1068 # return UNW_ESUCCESS
1071 #elif defined(__sparc__)
1074 # extern int __unw_getcontext(unw_context_t* thread_state)
1077 # thread_state pointer is in o0
1079 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1095 std %i2, [%o0 + 104]
1096 std %i4, [%o0 + 112]
1097 std %i6, [%o0 + 120]
1099 clr %o0 // return UNW_ESUCCESS
1101 #elif defined(__riscv)
1104 # extern int __unw_getcontext(unw_context_t* thread_state)
1107 # thread_state pointer is in a0
1109 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1110 ISTORE x1, (RISCV_ISIZE * 0)(a0) // store ra as pc
1111 .irp i,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
1112 ISTORE x\i, (RISCV_ISIZE * \i)(a0)
1115 # if defined(__riscv_flen)
1117 FSTORE f\i, (RISCV_FOFFSET + RISCV_FSIZE * \i)(a0)
1121 li a0, 0 // return UNW_ESUCCESS
1124 #elif defined(__s390x__)
1127 // extern int __unw_getcontext(unw_context_t* thread_state)
1130 // thread_state pointer is in r2
1132 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1135 stmg %r0, %r15, 16(%r2)
1139 stm %r0, %r1, 0(%r2)
1141 // Store return address as PSWA
1146 std %f\i, (144+8*\i)(%r2)
1149 // Return UNW_ESUCCESS
1153 #elif defined(__loongarch__) && __loongarch_grlen == 64
1156 # extern int __unw_getcontext(unw_context_t* thread_state)
1159 # thread_state pointer is in $a0($r4)
1161 DEFINE_LIBUNWIND_FUNCTION(__unw_getcontext)
1162 .irp i,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
1163 st.d $r\i, $a0, (8*\i)
1165 st.d $r1, $a0, (8 * 32) // store $ra to pc
1167 # if __loongarch_frlen == 64
1169 fst.d $f\i, $a0, (8 * 33 + 8 * \i)
1173 move $a0, $zero // UNW_ESUCCESS
1178 WEAK_ALIAS(__unw_getcontext, unw_getcontext)
1180 #endif /* !defined(__USING_SJLJ_EXCEPTIONS__) */
1182 NO_EXEC_STACK_DIRECTIVE