|
Packit Service |
82fcde |
/* Copyright (C) 2009-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <sigaltstack-offsets.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.section .rodata.str1.8,"aMS",@progbits,1
|
|
Packit Service |
82fcde |
.align 8
|
|
Packit Service |
82fcde |
.LC0:
|
|
Packit Service |
82fcde |
.string "longjmp causes uninitialized stack frame"
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
.section .sdata,"aws",@progbits
|
|
Packit Service |
82fcde |
.align 8
|
|
Packit Service |
82fcde |
.type longjmp_msg,@object
|
|
Packit Service |
82fcde |
longjmp_msg:
|
|
Packit Service |
82fcde |
data8 .LC0
|
|
Packit Service |
82fcde |
.size longjmp_msg, .-longjmp_msg
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#define __longjmp ____longjmp_chk
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* We use 32 bytes (rather than sizeof(stack_t)) so that we keep the stack
|
|
Packit Service |
82fcde |
properly aligned. But we still want a sanity check to make sure 32 is
|
|
Packit Service |
82fcde |
actually enough. */
|
|
Packit Service |
82fcde |
#define STACK_SPACE ((sizeSS + 31) & -32)
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Check the stack pointer held in the jumpbuf. Make sure it's in either the
|
|
Packit Service |
82fcde |
current stack (r12) or in the signal stack. */
|
|
Packit Service |
82fcde |
#define CHECK_RSP \
|
|
Packit Service |
82fcde |
ld8 loc0 = [in0]; \
|
|
Packit Service |
82fcde |
;; \
|
|
Packit Service |
82fcde |
/* First see if target stack is within current one. */ \
|
|
Packit Service |
82fcde |
cmp.ltu p0, p8 = loc0, r12; \
|
|
Packit Service |
82fcde |
(p8) br.cond.dptk.many .Lok; \
|
|
Packit Service |
82fcde |
\
|
|
Packit Service |
82fcde |
/* Check if it's an alternative signal stack. */ \
|
|
Packit Service |
82fcde |
mov out0 = r0; \
|
|
Packit Service |
82fcde |
add out1 = -STACK_SPACE, r12; \
|
|
Packit Service |
82fcde |
;; \
|
|
Packit Service |
82fcde |
mov r12 = out1; \
|
|
Packit Service |
82fcde |
DO_CALL_VIA_BREAK (SYS_ify (sigaltstack)); \
|
|
Packit Service |
82fcde |
;; \
|
|
Packit Service |
82fcde |
/* If the syscall failed, then assume it's OK. */ \
|
|
Packit Service |
82fcde |
cmp.eq p8, p0 = -1, r10; \
|
|
Packit Service |
82fcde |
(p8) br.cond.spnt .Lok; \
|
|
Packit Service |
82fcde |
/* Move stack_t into regs. */ \
|
|
Packit Service |
82fcde |
add r14 = oSS_FLAGS, r12; /* ss_flags */ \
|
|
Packit Service |
82fcde |
add r15 = oSS_SIZE, r12; /* ss_size */ \
|
|
Packit Service |
82fcde |
ld8 r16 = [r12]; /* ss_sp */ \
|
|
Packit Service |
82fcde |
;; \
|
|
Packit Service |
82fcde |
ld4 r17 = [r14]; /* ss_flags */ \
|
|
Packit Service |
82fcde |
ld8 r18 = [r15]; /* ss_size */ \
|
|
Packit Service |
82fcde |
;; \
|
|
Packit Service |
82fcde |
sub r19 = r16, r18; /* sp - size */ \
|
|
Packit Service |
82fcde |
/* See if we're currently on the altstack. */ \
|
|
Packit Service |
82fcde |
tbit.nz p0, p8 = r17, 0; /* SS_ONSTACK */ \
|
|
Packit Service |
82fcde |
(p8) br.cond.spnt .Lfail; \
|
|
Packit Service |
82fcde |
/* Verify target is within alternative stack. */ \
|
|
Packit Service |
82fcde |
cmp.gtu p7, p0 = loc0, r16; \
|
|
Packit Service |
82fcde |
(p7) br.cond.spnt .Lfail; \
|
|
Packit Service |
82fcde |
;; \
|
|
Packit Service |
82fcde |
cmp.ltu p0, p8 = loc0, r19; \
|
|
Packit Service |
82fcde |
(p8) br.cond.sptk.many .Lok; \
|
|
Packit Service |
82fcde |
;; \
|
|
Packit Service |
82fcde |
\
|
|
Packit Service |
82fcde |
/* Still here? Abort! */ \
|
|
Packit Service |
82fcde |
.Lfail: \
|
|
Packit Service |
82fcde |
add r12 = STACK_SPACE, r12; \
|
|
Packit Service |
82fcde |
addl loc0 = @ltoffx(longjmp_msg#), r1;; \
|
|
Packit Service |
82fcde |
ld8.mov loc0 = [loc0], longjmp_msg#;; \
|
|
Packit Service |
82fcde |
ld8 out0 = [loc0]; \
|
|
Packit Service |
82fcde |
br.call.sptk.many b0 = HIDDEN_JUMPTARGET(__fortify_fail)#;; \
|
|
Packit Service |
82fcde |
.Lok: \
|
|
Packit Service |
82fcde |
add r12 = STACK_SPACE, r12;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include "__longjmp.S"
|