Regenerate libc.pot for 2.22 release.
[glibc.git] / sysdeps / unix / sysv / linux / x86_64 / ____longjmp_chk.S
Commit [+]AuthorDateLineData
b168057a Joseph Myers2015-01-02 16:28:19 +00001/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
98b1e6c8
UD
Ulrich Drepper2009-07-30 21:42:27 -07002 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
59ba27a6
PE
Paul Eggert2012-02-09 23:18:22 +000015 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
98b1e6c8
UD
Ulrich Drepper2009-07-30 21:42:27 -070017
18#include <sysdep.h>
19#include <jmpbuf-offsets.h>
20#include <asm-syntax.h>
8422c9a5 Roland McGrath2012-05-25 13:31:57 -070021#include <stap-probe.h>
98b1e6c8 Ulrich Drepper2009-07-30 21:42:27 -070022
85736dc7
L
H.J. Lu2012-05-15 16:43:11 -070023#include <sigaltstack-offsets.h>
24
98b1e6c8
UD
Ulrich Drepper2009-07-30 21:42:27 -070025 .section .rodata.str1.1,"aMS",@progbits,1
26 .type longjmp_msg,@object
27longjmp_msg:
28 .string "longjmp causes uninitialized stack frame"
29 .size longjmp_msg, .-longjmp_msg
30
31
32//#define __longjmp ____longjmp_chk
33
34#ifdef PIC
85736dc7 H.J. Lu2012-05-15 16:43:11 -070035# define CALL_FAIL sub $8, %RSP_LP; \
e451d22b
AS
Andreas Schwab2011-04-07 16:23:52 -040036 cfi_remember_state; \
37 cfi_def_cfa_offset(16); \
85736dc7 H.J. Lu2012-05-15 16:43:11 -070038 lea longjmp_msg(%rip), %RDI_LP; \
b402e91a Roland McGrath2011-09-15 12:26:08 -070039 call HIDDEN_JUMPTARGET(__fortify_fail); \
e451d22b
AS
Andreas Schwab2011-04-07 16:23:52 -040040 nop; \
41 cfi_restore_state
98b1e6c8 Ulrich Drepper2009-07-30 21:42:27 -070042#else
85736dc7 H.J. Lu2012-05-15 16:43:11 -070043# define CALL_FAIL sub $8, %RSP_LP; \
e451d22b
AS
Andreas Schwab2011-04-07 16:23:52 -040044 cfi_remember_state; \
45 cfi_def_cfa_offset(16); \
85736dc7 H.J. Lu2012-05-15 16:43:11 -070046 mov $longjmp_msg, %RDI_LP; \
b402e91a Roland McGrath2011-09-15 12:26:08 -070047 call HIDDEN_JUMPTARGET(__fortify_fail); \
e451d22b
AS
Andreas Schwab2011-04-07 16:23:52 -040048 nop; \
49 cfi_restore_state
98b1e6c8
UD
Ulrich Drepper2009-07-30 21:42:27 -070050#endif
51
98b1e6c8
UD
Ulrich Drepper2009-07-30 21:42:27 -070052/* Jump to the position specified by ENV, causing the
53 setjmp call there to return VAL, or 1 if VAL is 0.
54 void __longjmp (__jmp_buf env, int val). */
55 .text
56ENTRY(____longjmp_chk)
57 /* Restore registers. */
85736dc7 H.J. Lu2012-05-15 16:43:11 -070058 mov (JB_RSP*8)(%rdi), %R8_LP
6c7fb145 Roland McGrath2012-05-18 15:32:08 -070059 mov (JB_RBP*8)(%rdi),%R9_LP
85736dc7 H.J. Lu2012-05-15 16:43:11 -070060 mov (JB_PC*8)(%rdi), %RDX_LP
98b1e6c8 Ulrich Drepper2009-07-30 21:42:27 -070061#ifdef PTR_DEMANGLE
85736dc7 H.J. Lu2012-05-15 16:43:11 -070062 PTR_DEMANGLE (%R8_LP)
6c7fb145 Roland McGrath2012-05-18 15:32:08 -070063 PTR_DEMANGLE (%R9_LP)
85736dc7 H.J. Lu2012-05-15 16:43:11 -070064 PTR_DEMANGLE (%RDX_LP)
6c7fb145
RM
Roland McGrath2012-05-18 15:32:08 -070065# ifdef __ILP32__
66 /* We ignored the high bits of the %rbp value because only the low
67 bits are mangled. But we cannot presume that %rbp is being used
68 as a pointer and truncate it, so recover the high bits. */
69 movl (JB_RBP*8 + 4)(%rdi), %eax
70 shlq $32, %rax
71 orq %rax, %r9
72# endif
98b1e6c8
UD
Ulrich Drepper2009-07-30 21:42:27 -070073#endif
74
85736dc7 H.J. Lu2012-05-15 16:43:11 -070075 cmp %R8_LP, %RSP_LP
e4143e7a
UD
Ulrich Drepper2009-07-31 17:27:38 -070076 jbe .Lok
77
98b1e6c8
UD
Ulrich Drepper2009-07-30 21:42:27 -070078 /* Save function parameters. */
79 movq %rdi, %r10
c044aa75
CLT
Chung-Lin Tang2010-09-08 15:49:50 -070080 cfi_register (%rdi, %r10)
81 movl %esi, %ebx
82 cfi_register (%rsi, %rbx)
98b1e6c8 Ulrich Drepper2009-07-30 21:42:27 -070083
98b1e6c8 Ulrich Drepper2009-07-30 21:42:27 -070084 xorl %edi, %edi
85736dc7 H.J. Lu2012-05-15 16:43:11 -070085 lea -sizeSS(%rsp), %RSI_LP
98b1e6c8
UD
Ulrich Drepper2009-07-30 21:42:27 -070086 movl $__NR_sigaltstack, %eax
87 syscall
e4143e7a Ulrich Drepper2009-07-31 17:27:38 -070088 /* Without working sigaltstack we cannot perform the test. */
98b1e6c8 Ulrich Drepper2009-07-30 21:42:27 -070089 testl %eax, %eax
e4143e7a Ulrich Drepper2009-07-31 17:27:38 -070090 jne .Lok2
85736dc7 H.J. Lu2012-05-15 16:43:11 -070091 testl $1, (-sizeSS + oSS_FLAGS)(%rsp)
e4143e7a Ulrich Drepper2009-07-31 17:27:38 -070092 jz .Lfail
98b1e6c8 Ulrich Drepper2009-07-30 21:42:27 -070093
85736dc7
L
H.J. Lu2012-05-15 16:43:11 -070094 mov (-sizeSS + oSS_SP)(%rsp), %RAX_LP
95 add (-sizeSS + oSS_SIZE)(%rsp), %RAX_LP
96 sub %R8_LP, %RAX_LP
97 cmp (-sizeSS + oSS_SIZE)(%rsp), %RAX_LP
e4143e7a
UD
Ulrich Drepper2009-07-31 17:27:38 -070098 jae .Lok2
99
100.Lfail: CALL_FAIL
101
102.Lok2: movq %r10, %rdi
c044aa75
CLT
Chung-Lin Tang2010-09-08 15:49:50 -0700103 cfi_restore (%rdi)
104 movl %ebx, %esi
105 cfi_restore (%rsi)
e4143e7a Ulrich Drepper2009-07-31 17:27:38 -0700106
8422c9a5
RM
Roland McGrath2012-05-25 13:31:57 -0700107.Lok:
108 LIBC_PROBE (longjmp, 3, LP_SIZE@%RDI_LP, -4@%esi, LP_SIZE@%RDX_LP)
109 /* We add unwind information for the target here. */
e4143e7a Ulrich Drepper2009-07-31 17:27:38 -0700110 cfi_def_cfa(%rdi, 0)
98b1e6c8
UD
Ulrich Drepper2009-07-30 21:42:27 -0700111 cfi_register(%rsp,%r8)
112 cfi_register(%rbp,%r9)
113 cfi_register(%rip,%rdx)
114 cfi_offset(%rbx,JB_RBX*8)
115 cfi_offset(%r12,JB_R12*8)
116 cfi_offset(%r13,JB_R13*8)
117 cfi_offset(%r14,JB_R14*8)
118 cfi_offset(%r15,JB_R15*8)
c044aa75
CLT
Chung-Lin Tang2010-09-08 15:49:50 -0700119 movq (JB_RBX*8)(%rdi), %rbx
120 movq (JB_R12*8)(%rdi), %r12
121 movq (JB_R13*8)(%rdi), %r13
122 movq (JB_R14*8)(%rdi), %r14
123 movq (JB_R15*8)(%rdi), %r15
98b1e6c8 Ulrich Drepper2009-07-30 21:42:27 -0700124 /* Set return value for setjmp. */
e4143e7a Ulrich Drepper2009-07-31 17:27:38 -0700125 movl %esi, %eax
85736dc7 H.J. Lu2012-05-15 16:43:11 -0700126 mov %R8_LP, %RSP_LP
e4143e7a Ulrich Drepper2009-07-31 17:27:38 -0700127 movq %r9,%rbp
8422c9a5
RM
Roland McGrath2012-05-25 13:31:57 -0700128 LIBC_PROBE (longjmp_target, 3,
129 LP_SIZE@%RDI_LP, -4@%eax, LP_SIZE@%RDX_LP)
98b1e6c8 Ulrich Drepper2009-07-30 21:42:27 -0700130 jmpq *%rdx
9663bb3e Ulrich Drepper2009-08-01 14:18:58 -0700131END (____longjmp_chk)