2019-01-01 00:11:28 +00:00
|
|
|
/* Copyright (C) 1992-2019 Free Software Foundation, Inc.
|
2010-03-26 20:17:02 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
2012-03-09 23:56:38 +00:00
|
|
|
License along with the GNU C Library. If not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2010-03-26 20:17:02 +00:00
|
|
|
|
|
|
|
#include <sysdep.h>
|
|
|
|
#include <jmpbuf-offsets.h>
|
|
|
|
|
|
|
|
|
|
|
|
.section .rodata.str1.1,"aMS",@progbits,1
|
|
|
|
.type longjmp_msg,@object
|
|
|
|
longjmp_msg:
|
|
|
|
.string "longjmp causes uninitialized stack frame"
|
|
|
|
.size longjmp_msg, .-longjmp_msg
|
|
|
|
|
|
|
|
|
|
|
|
/* Jump to the position specified by ENV, causing the
|
|
|
|
setjmp call there to return VAL, or 1 if VAL is 0.
|
|
|
|
void __longjmp (__jmp_buf env, int val). */
|
|
|
|
.text
|
|
|
|
.align 4
|
|
|
|
.globl ____longjmp_chk
|
|
|
|
.type ____longjmp_chk, @function
|
|
|
|
.usepv ____longjmp_chk, std
|
|
|
|
|
|
|
|
cfi_startproc
|
|
|
|
____longjmp_chk:
|
|
|
|
ldgp gp, 0(pv)
|
|
|
|
#ifdef PROF
|
|
|
|
.set noat
|
|
|
|
lda AT, _mcount
|
|
|
|
jsr AT, (AT), _mcount
|
|
|
|
.set at
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ldq s2, JB_PC*8(a0)
|
|
|
|
mov a0, s0
|
|
|
|
ldq fp, JB_FP*8(a0)
|
|
|
|
mov a1, s1
|
|
|
|
ldq s3, JB_SP*8(a0)
|
|
|
|
cmoveq s1, 1, s1
|
|
|
|
|
|
|
|
#ifdef PTR_DEMANGLE
|
|
|
|
PTR_DEMANGLE(s2, t1)
|
|
|
|
PTR_DEMANGLE2(s3, t1)
|
|
|
|
PTR_DEMANGLE2(fp, t1)
|
|
|
|
#endif
|
2011-03-28 21:44:49 +00:00
|
|
|
/* ??? While this is a proper test for detecting a longjmp to an
|
|
|
|
invalid frame within any given stack, the main thread stack is
|
|
|
|
located *below* almost everything in the address space. Which
|
|
|
|
means that the test at Lfail vs the signal stack will almost
|
|
|
|
certainly never pass. We ought bounds check top and bottom of
|
|
|
|
the current thread's stack. */
|
|
|
|
cmpule s3, sp, t1
|
|
|
|
bne t1, $Lfail
|
2010-03-26 20:17:02 +00:00
|
|
|
|
|
|
|
.align 4
|
2011-03-28 21:44:49 +00:00
|
|
|
$Lok:
|
2010-03-26 20:17:02 +00:00
|
|
|
mov s0, a0
|
|
|
|
mov s1, v0
|
|
|
|
mov s3, t0
|
|
|
|
mov s2, ra
|
|
|
|
cfi_remember_state
|
|
|
|
cfi_def_cfa(a0, 0)
|
|
|
|
cfi_register(sp, t0)
|
|
|
|
cfi_offset(s0, JB_S0*8)
|
|
|
|
cfi_offset(s1, JB_S1*8)
|
|
|
|
cfi_offset(s2, JB_S2*8)
|
|
|
|
cfi_offset(s3, JB_S3*8)
|
|
|
|
cfi_offset(s4, JB_S4*8)
|
|
|
|
cfi_offset(s5, JB_S5*8)
|
|
|
|
cfi_offset(s3, JB_S3*8)
|
|
|
|
cfi_offset($f2, JB_F2*8)
|
|
|
|
cfi_offset($f3, JB_F3*8)
|
|
|
|
cfi_offset($f4, JB_F4*8)
|
|
|
|
cfi_offset($f5, JB_F5*8)
|
|
|
|
cfi_offset($f6, JB_F6*8)
|
|
|
|
cfi_offset($f7, JB_F7*8)
|
|
|
|
cfi_offset($f8, JB_F8*8)
|
|
|
|
cfi_offset($f9, JB_F9*8)
|
|
|
|
ldq s0, JB_S0*8(a0)
|
|
|
|
ldq s1, JB_S1*8(a0)
|
|
|
|
ldq s2, JB_S2*8(a0)
|
|
|
|
ldq s3, JB_S3*8(a0)
|
|
|
|
ldq s4, JB_S4*8(a0)
|
|
|
|
ldq s5, JB_S5*8(a0)
|
|
|
|
ldt $f2, JB_F2*8(a0)
|
|
|
|
ldt $f3, JB_F3*8(a0)
|
|
|
|
ldt $f4, JB_F4*8(a0)
|
|
|
|
ldt $f5, JB_F5*8(a0)
|
|
|
|
ldt $f6, JB_F6*8(a0)
|
|
|
|
ldt $f7, JB_F7*8(a0)
|
|
|
|
ldt $f8, JB_F8*8(a0)
|
|
|
|
ldt $f9, JB_F9*8(a0)
|
|
|
|
mov t0, sp
|
|
|
|
ret
|
|
|
|
|
|
|
|
.align 4
|
2011-03-28 21:44:49 +00:00
|
|
|
$Lfail:
|
2010-03-26 20:17:02 +00:00
|
|
|
cfi_restore_state
|
|
|
|
lda v0, __NR_sigaltstack
|
|
|
|
lda a0, 0
|
|
|
|
lda a1, -32(sp)
|
|
|
|
lda sp, -32(sp)
|
|
|
|
cfi_adjust_cfa_offset(32)
|
|
|
|
callsys
|
|
|
|
ldq t0, 0(sp) /* ss_sp */
|
|
|
|
ldl t1, 8(sp) /* ss_flags */
|
|
|
|
ldq t2, 16(sp) /* ss_size */
|
|
|
|
lda sp, 32(sp)
|
|
|
|
cfi_adjust_cfa_offset(-32)
|
|
|
|
|
|
|
|
/* Without working sigaltstack we cannot perform the test. */
|
2011-03-28 21:44:49 +00:00
|
|
|
bne a3, $Lok
|
2010-03-26 20:17:02 +00:00
|
|
|
|
|
|
|
addq t0, t2, t0 /* t0 = ss_sp + ss_size */
|
|
|
|
subq t0, s3, t0 /* t0 = (ss_sp + ss_size) - new_sp */
|
|
|
|
cmpule t2, t0, t0 /* t0 = (t0 >= ss_size) */
|
|
|
|
and t0, t1, t0 /* t0 = (t0 >= ss_size) & (ss_flags & SS_ONSTACK) */
|
2011-03-28 21:44:49 +00:00
|
|
|
bne t0, $Lok
|
2010-03-26 20:17:02 +00:00
|
|
|
|
|
|
|
ldah a0, longjmp_msg(gp) !gprelhigh
|
|
|
|
lda a0, longjmp_msg(a0) !gprellow
|
|
|
|
#ifdef PIC
|
|
|
|
jsr ra, HIDDEN_JUMPTARGET(__fortify_fail)
|
|
|
|
#else
|
|
|
|
bsr ra, HIDDEN_JUMPTARGET(__fortify_fail) !samegp
|
|
|
|
#endif
|
|
|
|
bugchk
|
|
|
|
|
|
|
|
cfi_endproc
|
|
|
|
.size ____longjmp_chk, .-____longjmp_chk
|