nptl: Remove __ASSUME_PRIVATE_FUTEX
[glibc.git] / sysdeps / unix / sysv / linux / i386 / ____longjmp_chk.S
blob34524331122c237f3095a4169b3c7070f03be5ce
1 /* Copyright (C) 2001-2018 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
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.
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.
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    <http://www.gnu.org/licenses/>.  */
18 #include <sysdep.h>
19 #include <jmpbuf-offsets.h>
20 #include <asm-syntax.h>
21 #include <stap-probe.h>
24         .section .rodata.str1.1,"aMS",@progbits,1
25         .type   longjmp_msg,@object
26 longjmp_msg:
27         .string "longjmp causes uninitialized stack frame"
28         .size   longjmp_msg, .-longjmp_msg
31 #ifdef PIC
32 # define CALL_FAIL      movl    %ebx, %ecx;                                   \
33                         cfi_register(%ebx,%ecx);                              \
34                         LOAD_PIC_REG (bx);                                    \
35                         leal    longjmp_msg@GOTOFF(%ebx), %eax;               \
36                         movl    %eax, (%esp);                                 \
37                         call    HIDDEN_JUMPTARGET(__fortify_fail)
38 #else
39 # define CALL_FAIL      movl    $longjmp_msg, %eax;                           \
40                         movl    %eax, (%esp);                                 \
41                         call    HIDDEN_JUMPTARGET(__fortify_fail)
42 #endif
45         .text
46 ENTRY (____longjmp_chk)
47         movl    4(%esp), %ecx   /* User's jmp_buf in %ecx.  */
49         /* Save the return address now.  */
50         movl    (JB_PC*4)(%ecx), %edx
51         /* Get the stack pointer.  */
52         movl    (JB_SP*4)(%ecx), %edi
53         cfi_undefined(%edi)
54         PTR_DEMANGLE (%edx)
55         PTR_DEMANGLE (%edi)
57         cmpl    %edi, %esp
58         jbe     .Lok
60         subl    $12, %esp
61         cfi_adjust_cfa_offset(12)
62         xorl    %ebx, %ebx
63         movl    %esp, %ecx
64         movl    $__NR_sigaltstack, %eax
65         ENTER_KERNEL
66         /* Without working sigaltstack we cannot perform the test.  */
67         test    %eax, %eax
68         jne     .Lok2
69         testl   $1, 4(%esp)
70         jz      .Lfail
72         movl    (%esp), %eax
73         addl    8(%esp), %eax
74         subl    %edi, %eax
75         cmpl    8(%esp), %eax
76         jae     .Lok2
78 .Lfail: CALL_FAIL
80 .Lok2:  addl    $12, %esp
81         cfi_adjust_cfa_offset(-12)
82         movl    4(%esp), %ecx
84 .Lok:
85         LIBC_PROBE (longjmp, 3, 4@%ecx, -4@8(%esp), 4@%edx)
86         /* We add unwind information for the target here.  */
87         cfi_def_cfa(%ecx, 0)
88         cfi_register(%eip, %edx)
89         cfi_register(%esp, %edi)
90         cfi_offset(%ebx, JB_BX*4)
91         cfi_offset(%esi, JB_SI*4)
92         cfi_offset(%edi, JB_DI*4)
93         cfi_offset(%ebp, JB_BP*4)
95         movl    8(%esp), %eax   /* Second argument is return value.  */
96         movl    %edi, %esp
98         /* Restore registers.  */
99         movl    (JB_BX*4)(%ecx), %ebx
100         movl    (JB_SI*4)(%ecx), %esi
101         movl    (JB_DI*4)(%ecx), %edi
102         movl    (JB_BP*4)(%ecx), %ebp
103         cfi_restore(%ebx)
104         cfi_restore(%esi)
105         cfi_restore(%edi)
106         cfi_restore(%ebp)
108         /* Jump to saved PC.  */
109         LIBC_PROBE (longjmp_target, 3, 4@%ecx, -4@%eax, 4@%edx)
110         jmp     *%edx
111 END (____longjmp_chk)