|
Packit |
6c4009 |
/* Copyright (C) 2009-2018 Free Software Foundation, Inc.
|
|
Packit |
6c4009 |
This file is part of the GNU C Library.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit |
6c4009 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License as published by the Free Software Foundation; either
|
|
Packit |
6c4009 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit |
6c4009 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
6c4009 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
6c4009 |
Lesser General Public License for more details.
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit |
6c4009 |
License along with the GNU C Library; if not, see
|
|
Packit |
6c4009 |
<http://www.gnu.org/licenses/>. */
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sysdep.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <sigaltstack-offsets.h>
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
.section .rodata.str1.1,"aMS",@progbits,1
|
|
Packit |
6c4009 |
.type longjmp_msg,@object
|
|
Packit |
6c4009 |
longjmp_msg:
|
|
Packit |
6c4009 |
.string "longjmp causes uninitialized stack frame"
|
|
Packit |
6c4009 |
.size longjmp_msg, .-longjmp_msg
|
|
Packit |
6c4009 |
.text
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define __longjmp ____longjmp_chk
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#ifdef PIC
|
|
Packit |
6c4009 |
# define CALL_FAIL \
|
|
Packit |
6c4009 |
mov.l .Lfail, r1; \
|
|
Packit |
6c4009 |
mov.l .Lstr, r4; \
|
|
Packit |
6c4009 |
mov.l r12, @-r15; \
|
|
Packit |
6c4009 |
cfi_remember_state; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4); \
|
|
Packit |
6c4009 |
cfi_rel_offset (r12, 0); \
|
|
Packit |
6c4009 |
mova .Lgot, r0; \
|
|
Packit |
6c4009 |
mov.l .Lgot, r12; \
|
|
Packit |
6c4009 |
add r0, r12; \
|
|
Packit |
6c4009 |
sts.l pr, @-r15; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4); \
|
|
Packit |
6c4009 |
cfi_rel_offset (pr, 0); \
|
|
Packit |
6c4009 |
bsrf r1; \
|
|
Packit |
6c4009 |
add r12, r4; \
|
|
Packit |
6c4009 |
.Lfail0: \
|
|
Packit |
6c4009 |
/* Unreachable. */ \
|
|
Packit |
6c4009 |
.align 2; \
|
|
Packit |
6c4009 |
.Lgot: \
|
|
Packit |
6c4009 |
.long _GLOBAL_OFFSET_TABLE_; \
|
|
Packit |
6c4009 |
.Lstr: \
|
|
Packit |
6c4009 |
.long longjmp_msg@GOTOFF; \
|
|
Packit |
6c4009 |
.Lfail: \
|
|
Packit |
6c4009 |
.long __GI___fortify_fail@PLT-(.Lfail0-.); \
|
|
Packit |
6c4009 |
cfi_restore_state;
|
|
Packit |
6c4009 |
#else
|
|
Packit |
6c4009 |
# define CALL_FAIL \
|
|
Packit |
6c4009 |
mov.l .Lfail, r1; \
|
|
Packit |
6c4009 |
mov.l .Lstr, r4; \
|
|
Packit |
6c4009 |
sts.l pr, @-r15; \
|
|
Packit |
6c4009 |
cfi_remember_state; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4); \
|
|
Packit |
6c4009 |
cfi_rel_offset (pr, 0); \
|
|
Packit |
6c4009 |
jsr @r1; \
|
|
Packit |
6c4009 |
nop; \
|
|
Packit |
6c4009 |
/* Unreachable. */ \
|
|
Packit |
6c4009 |
.align 2; \
|
|
Packit |
6c4009 |
.Lstr: \
|
|
Packit |
6c4009 |
.long longjmp_msg; \
|
|
Packit |
6c4009 |
.Lfail: \
|
|
Packit |
6c4009 |
.long __fortify_fail; \
|
|
Packit |
6c4009 |
cfi_restore_state;
|
|
Packit |
6c4009 |
#endif
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#define CHECK_SP(reg) \
|
|
Packit |
6c4009 |
/* Jumping to a higher-address frame is always allowed. */ \
|
|
Packit |
6c4009 |
cmp/hs r15, reg; \
|
|
Packit |
6c4009 |
bt .Lok; \
|
|
Packit |
6c4009 |
\
|
|
Packit |
6c4009 |
mov.l r0, @-r15; /* The return value is already in here. */ \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4); \
|
|
Packit |
6c4009 |
mov.l r1, @-r15; /* PTR_DEMANGLE helper. */ \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4); \
|
|
Packit |
6c4009 |
mov.l r2, @-r15; /* The new SP value is already in here. */ \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4); \
|
|
Packit |
6c4009 |
mov.l r4, @-r15; /* We'll still need this one. */ \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (4); \
|
|
Packit |
6c4009 |
add #-sizeSS, r15; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (sizeSS); \
|
|
Packit |
6c4009 |
mov #0, r4; \
|
|
Packit |
6c4009 |
mov r15, r5; \
|
|
Packit |
6c4009 |
DO_CALL (sigaltstack, 2); \
|
|
Packit |
6c4009 |
/* Without working sigaltstack we cannot perform the test. */ \
|
|
Packit |
6c4009 |
tst r0, r0; \
|
|
Packit |
6c4009 |
bf .Lok2; \
|
|
Packit |
6c4009 |
mov.l @(oSS_FLAGS, r15), r0; \
|
|
Packit |
6c4009 |
tst #SS_ONSTACK, r0; \
|
|
Packit |
6c4009 |
bt .Lcall_fail; \
|
|
Packit |
6c4009 |
mov.l @(oSS_SIZE, r15), r2; \
|
|
Packit |
6c4009 |
mov.l @(oSS_SP, r15), r1; \
|
|
Packit |
6c4009 |
add r2, r1; \
|
|
Packit |
6c4009 |
sub r8, r1; \
|
|
Packit |
6c4009 |
cmp/hi r1, r2; \
|
|
Packit |
6c4009 |
bf .Lok2; \
|
|
Packit |
6c4009 |
.Lcall_fail: \
|
|
Packit |
6c4009 |
CALL_FAIL \
|
|
Packit |
6c4009 |
\
|
|
Packit |
6c4009 |
.Lok2: \
|
|
Packit |
6c4009 |
add #sizeSS, r15; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-sizeSS); \
|
|
Packit |
6c4009 |
mov.l @r15+, r4; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-4); \
|
|
Packit |
6c4009 |
mov.l @r15+, r2; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-4); \
|
|
Packit |
6c4009 |
mov.l @r15+, r1; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-4); \
|
|
Packit |
6c4009 |
mov.l @r15+, r0; \
|
|
Packit |
6c4009 |
cfi_adjust_cfa_offset (-4); \
|
|
Packit |
6c4009 |
.Lok:
|
|
Packit |
6c4009 |
|
|
Packit |
6c4009 |
#include <__longjmp.S>
|