1/* Copyright (C) 2009-2021 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, see 16 <https://www.gnu.org/licenses/>. */ 17 18#include <sysdep.h> 19#include <rtld-global-offsets.h> 20 21 .section .rodata.str1.4,"aMS",@progbits,1 22 .align 2 23.LC0: 24 .string "longjmp causes uninitialized stack frame" 25 .text 26 27#define __longjmp_symbol ____longjmp_chk 28 29#ifdef PIC 30# define LOAD_ARG \ 31 SETUP_GOT_ACCESS(r3,got_label2); \ 32 addis r3,r3,_GLOBAL_OFFSET_TABLE_-got_label2@ha; \ 33 addi r3,r3,_GLOBAL_OFFSET_TABLE_-got_label2@l; \ 34 lwz r3,.LC0@got(r3) 35#else 36# define LOAD_ARG \ 37 lis r3,.LC0@ha; \ 38 la r3,.LC0@l(r3) 39#endif 40 41#define CHECK_SP(reg) \ 42 cmplw reg, r1; \ 43 bge+ .Lok; \ 44 mflr r0; \ 45 stwu r1,-32(r1); \ 46 cfi_remember_state; \ 47 cfi_adjust_cfa_offset (32); \ 48 stw r0,36(r1); \ 49 cfi_offset (lr, 4); \ 50 mr r31,r3; \ 51 mr r30,r4; \ 52 li r3,0; \ 53 addi r4,r1,8; \ 54 li r0,__NR_sigaltstack; \ 55 sc; \ 56 /* Without working sigaltstack we cannot perform the test. */ \ 57 bso .Lok2; \ 58 lwz r0,12(r1); \ 59 andi. r3,r0,1; \ 60 beq .Lfail; \ 61 lwz r0,16(r1); \ 62 lwz r3,8(r1); \ 63 add r3,r3,r0; \ 64 sub r3,r3,reg; \ 65 cmplw r3,r0; \ 66 bge+ .Lok2; \ 67.Lfail: \ 68 LOAD_ARG; \ 69 bl HIDDEN_JUMPTARGET (__fortify_fail); \ 70.Lok2: \ 71 mr r3,r31; \ 72 mr r4,r30; \ 73 cfi_restore_state; \ 74.Lok: 75 76#include <__longjmp-common.S> 77