1 | /* setjmp for s390, ELF version. |
2 | Copyright (C) 2000-2024 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 | <https://www.gnu.org/licenses/>. */ |
18 | |
19 | #include <sysdep.h> |
20 | #include <pointer_guard.h> |
21 | #define _ASM |
22 | #define _SETJMP_H |
23 | #include <bits/setjmp.h> |
24 | #include <shlib-compat.h> |
25 | #include <stap-probe.h> |
26 | |
27 | #if !IS_IN (rtld) && defined SHARED \ |
28 | && SHLIB_COMPAT (libc, GLIBC_2_19, GLIBC_2_20) |
29 | # define NEED_COMPAT_SYMBOLS 1 |
30 | /* We need a unique name in case of symbol versioning. */ |
31 | # define setjmp __v1setjmp |
32 | # define _setjmp __v1_setjmp |
33 | # define __sigsetjmp __v1__sigsetjmp |
34 | #else |
35 | # define NEED_COMPAT_SYMBOLS 0 |
36 | #endif |
37 | |
38 | /* We include the BSD entry points here as well. */ |
39 | ENTRY (setjmp) |
40 | lhi %r3,1 /* second argument of one */ |
41 | j .Linternal_sigsetjmp /* branch relative to __sigsetjmp */ |
42 | END (setjmp) |
43 | |
44 | /* Binary compatibility entry point. */ |
45 | ENTRY(_setjmp) |
46 | lhi %r3,0 /* second argument of zero */ |
47 | j .Linternal_sigsetjmp /* branch relative to __sigsetjmp */ |
48 | END (_setjmp) |
49 | #if NEED_COMPAT_SYMBOLS |
50 | strong_alias (_setjmp, __GI__setjmp) |
51 | #else |
52 | libc_hidden_def (_setjmp) |
53 | #endif |
54 | |
55 | ENTRY(__setjmp) |
56 | lhi %r3,0 /* second argument of zero */ |
57 | j .Linternal_sigsetjmp /* branch relative to __sigsetjmp */ |
58 | END (__setjmp) |
59 | |
60 | ENTRY(__sigsetjmp) |
61 | .Linternal_sigsetjmp: |
62 | /* setjmp probe expects sig/setjmp first argument (4@%r2), second |
63 | argument (-4@%r3) and target address (4@%r14). */ |
64 | LIBC_PROBE (setjmp, 3, 4@%r2, -4@%r3, 4@%r14) |
65 | #ifdef PTR_MANGLE |
66 | stm %r6,%r13,0(%r2) /* store registers in jmp_buf */ |
67 | lr %r4,%r14 |
68 | lr %r5,%r15 |
69 | PTR_MANGLE (%r4, %r1) |
70 | PTR_MANGLE2 (%r5, %r1) |
71 | stm %r4,%r5,32(%r2) |
72 | #else |
73 | stm %r6,%r15,0(%r2) /* store registers in jmp_buf */ |
74 | #endif |
75 | std %f4,40(%r2) |
76 | std %f6,48(%r2) |
77 | #if IS_IN (rtld) |
78 | /* In ld.so we never save the signal mask. */ |
79 | lhi %r2,0 |
80 | br %r14 |
81 | #elif defined PIC |
82 | /* We cannot use the PLT, because it requires that %r12 be set, but |
83 | we can't save and restore our caller's value. Instead, we do an |
84 | indirect jump through the GOT. */ |
85 | basr %r1,0 |
86 | .L0: al %r1,.L1 - .L0(0,%r1) /* get address of global offset table */ |
87 | /* get address of __sigjmp_save from got */ |
88 | l %r1,__sigjmp_save@GOT(%r1) |
89 | br %r1 |
90 | .L1: .long _GLOBAL_OFFSET_TABLE_ - .L0 |
91 | #else |
92 | basr %r1,0 |
93 | .L0: l %r1,.L1-.L0(0,%r1) /* load address of __sigjmp_save */ |
94 | br %r1 /* tail-call __sigjmp_save */ |
95 | .L1: .long __sigjmp_save |
96 | #endif |
97 | END (__sigsetjmp) |
98 | #if NEED_COMPAT_SYMBOLS |
99 | strong_alias (__sigsetjmp, __GI___sigsetjmp) |
100 | #else |
101 | libc_hidden_def (__sigsetjmp) |
102 | #endif |
103 | |
104 | #if NEED_COMPAT_SYMBOLS |
105 | /* In glibc release 2.19 new versions of setjmp-functions were introduced, |
106 | but were reverted before 2.20. Thus both versions are the same function. */ |
107 | |
108 | # undef setjmp |
109 | # undef _setjmp |
110 | # undef __sigsetjmp |
111 | |
112 | strong_alias (__v1setjmp, __v2setjmp); |
113 | versioned_symbol (libc, __v1setjmp, setjmp, GLIBC_2_0); |
114 | compat_symbol (libc, __v2setjmp, setjmp, GLIBC_2_19); |
115 | |
116 | strong_alias (__v1_setjmp, __v2_setjmp); |
117 | versioned_symbol (libc, __v1_setjmp, _setjmp, GLIBC_2_0); |
118 | compat_symbol (libc, __v2_setjmp, _setjmp, GLIBC_2_19); |
119 | |
120 | strong_alias (__v1__sigsetjmp, __v2__sigsetjmp); |
121 | versioned_symbol (libc, __v1__sigsetjmp, __sigsetjmp, GLIBC_2_0); |
122 | compat_symbol (libc, __v2__sigsetjmp, __sigsetjmp, GLIBC_2_19); |
123 | #endif /* NEED_COMPAT_SYMBOLS */ |
124 | |