]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/csky/abiv2/setcontext.S
C-SKY: mark lr as undefined to stop unwinding
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / csky / abiv2 / setcontext.S
1 /* Set saved user context to current context. C-SKY ABIV2 version.
2 Copyright (C) 2018-2019 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library. If not, see
17 <http://www.gnu.org/licenses/>. */
18
19 #include <sysdep.h>
20
21 #include "ucontext_i.h"
22
23 /* int setcontext (const ucontext_t *ucp) */
24
25 ENTRY (__setcontext)
26 mov t0, a0
27 subi sp, 8
28 stw a0, (sp, 0)
29
30 /* Set sigmask. */
31 movi a0, SIG_SETMASK
32 addi a1, t0, UCONTEXT_SIGMASK
33 movi a2, 0
34
35 /* Do sigprocmask syscall. */
36 #ifdef __PIC__
37 subi sp, 8
38 stw gb, (sp, 0)
39 grs gb, .Lgetpc1
40 .Lgetpc1:
41 lrw a3, .Lgetpc1@GOTPC
42 addu gb, gb, a3
43 lrw a3, __sigprocmask@PLT
44 ldr.w a3, (gb, a3 << 0)
45 jsr a3
46 ldw gb, (sp, 0)
47 addi sp, 8
48 #else
49 jsri __sigprocmask
50 #endif /* __PIC__ */
51
52 ldw t0, (sp, 0)
53 addi sp, 8
54 /* Set r0-r11. Load a0-a3, for makecontext requires. */
55 addi t1, t0, MCONTEXT_CSKY_A0
56 ldm r0-r11, (t1)
57 ldw sp, (t0, MCONTEXT_CSKY_SP) /* Load sp. */
58 ldw r15, (t0, MCONTEXT_CSKY_LR) /* Load lr. */
59 ldw t0, (t0, MCONTEXT_CSKY_PC) /* Load start addr. */
60 jmp t0
61 END (setcontext)
62 weak_alias (__setcontext, setcontext)
63
64 ENTRY (__startcontext)
65 .cfi_label .Ldummy
66 cfi_undefined (lr)
67 mov a0, r9
68 cmpnei r9, 0 /* r9 was set in makecontext. */
69 bf 1f /* null, then exit. */
70
71 /* Call setcontext. */
72 #ifdef __PIC__
73 grs t1, .Lgetpc2
74 .Lgetpc2:
75 lrw t0, .Lgetpc2@GOTPC
76 addu t1, t1, t0
77 lrw t0, __setcontext@GOT
78 ldr.w t0, (t1, t0 << 0)
79 #else
80 lrw t0, __setcontext
81 #endif
82 jsr t0
83
84 1:
85 /* Call _exit. */
86 #ifdef __PIC__
87 grs t1, .Lgetpc3
88 .Lgetpc3:
89 lrw t0, .Lgetpc3@GOTPC
90 addu t1, t1, t0
91 lrw t0, _exit@GOT
92 ldr.w t0, (t1, t0 << 0)
93 #else
94 lrw t0, _exit
95 #endif
96 jsr t0
97
98 END (__startcontext)