]> git.ipfire.org Git - thirdparty/glibc.git/blob - sysdeps/unix/sysv/linux/powerpc/powerpc32/____longjmp_chk.S
Simplify code for accessing powerpc GOT
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / powerpc / powerpc32 / ____longjmp_chk.S
1 /* Copyright (C) 2009, 2011 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19 #include <sysdep.h>
20 #include <rtld-global-offsets.h>
21
22 .section .rodata.str1.4,"aMS",@progbits,1
23 .align 2
24 .LC0:
25 .string "longjmp causes uninitialized stack frame"
26 .text
27
28 #define __longjmp ____longjmp_chk
29
30 #ifdef PIC
31 # define LOAD_ARG \
32 SETUP_GOT_ACCESS(r3,got_label2); \
33 addis r3,r3,_GLOBAL_OFFSET_TABLE_-got_label2@ha; \
34 addi r3,r3,_GLOBAL_OFFSET_TABLE_-got_label2@l; \
35 lwz r3,.LC0@got(r3)
36 #else
37 # define LOAD_ARG \
38 lis r3,.LC0@ha; \
39 la r3,.LC0@l(r3)
40 #endif
41
42 #define CHECK_SP(reg) \
43 cmplw reg, r1; \
44 bge+ .Lok; \
45 mflr r0; \
46 stwu r1,-32(r1); \
47 cfi_remember_state; \
48 cfi_adjust_cfa_offset (32); \
49 stw r0,36(r1); \
50 cfi_offset (lr, 4); \
51 mr r31,r3; \
52 mr r30,r4; \
53 li r3,0; \
54 addi r4,r1,8; \
55 li r0,__NR_sigaltstack; \
56 sc; \
57 /* Without working sigaltstack we cannot perform the test. */ \
58 bso .Lok2; \
59 lwz r0,12(r1); \
60 andi. r3,r0,1; \
61 beq .Lfail; \
62 lwz r0,16(r1); \
63 lwz r3,8(r1); \
64 add r3,r3,r0; \
65 sub r3,r3,reg; \
66 cmplw r3,r0; \
67 bge+ .Lok2; \
68 .Lfail: \
69 LOAD_ARG; \
70 bl HIDDEN_JUMPTARGET (__fortify_fail); \
71 .Lok2: \
72 mr r3,r31; \
73 mr r4,r30; \
74 cfi_restore_state; \
75 .Lok:
76
77 #include <__longjmp-common.S>