]>
Commit | Line | Data |
---|---|---|
52b2a80f RA |
1 | /* Shared object part of test for setjmp interoperability with static |
2 | dlopen BZ #21895. | |
d614a753 | 3 | Copyright (C) 2017-2020 Free Software Foundation, Inc. |
52b2a80f RA |
4 | This file is part of the GNU C Library. |
5 | ||
6 | The GNU C Library is free software; you can redistribute it and/or | |
7 | modify it under the terms of the GNU Lesser General Public | |
8 | License as published by the Free Software Foundation; either | |
9 | version 2.1 of the License, or (at your option) any later version. | |
10 | ||
11 | The GNU C Library is distributed in the hope that it will be useful, | |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | Lesser General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU Lesser General Public | |
17 | License along with the GNU C Library; if not, see | |
5a82c748 | 18 | <https://www.gnu.org/licenses/>. */ |
52b2a80f RA |
19 | |
20 | #include <string.h> | |
21 | #include <setjmp.h> | |
22 | ||
23 | /* Copy r1 adress to a local variable. */ | |
24 | #define GET_STACK_POINTER(sp) \ | |
25 | ({ \ | |
26 | asm volatile ("mr %0, 1\n\t" \ | |
27 | : "=r" (sp)); \ | |
28 | }) | |
29 | ||
30 | jmp_buf jb; | |
31 | void (*bar)(jmp_buf, unsigned long); | |
32 | ||
33 | void | |
34 | lbar (unsigned long sp) | |
35 | { | |
36 | bar(jb, sp); | |
37 | for(;;); | |
38 | } | |
39 | ||
40 | void | |
41 | foo (void) | |
42 | { | |
43 | unsigned long sp; | |
44 | /* Copy r1 (stack pointer) to sp. It will be use later to get | |
45 | TOC area. */ | |
46 | GET_STACK_POINTER(sp); | |
47 | setjmp(jb); | |
48 | lbar(sp); | |
49 | ||
50 | for(;;); | |
51 | } |