3 Provide ____longjmp_chk, still WIP.
5 sysdeps/mach/hurd/i386/Makefile | 4 +
6 sysdeps/mach/hurd/i386/____longjmp_chk.S | 108 ++++++++++++++++++++++++++++++
7 sysdeps/mach/hurd/i386/signal-defines.sym | 10 ++
8 3 files changed, 122 insertions(+)
11 +++ b/sysdeps/mach/hurd/i386/____longjmp_chk.S
13 +/* Copyright (C) 2001,2004,2005,2006,2009 Free Software Foundation, Inc.
14 + This file is part of the GNU C Library.
16 + The GNU C Library is free software; you can redistribute it and/or
17 + modify it under the terms of the GNU Lesser General Public
18 + License as published by the Free Software Foundation; either
19 + version 2.1 of the License, or (at your option) any later version.
21 + The GNU C Library is distributed in the hope that it will be useful,
22 + but WITHOUT ANY WARRANTY; without even the implied warranty of
23 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 + Lesser General Public License for more details.
26 + You should have received a copy of the GNU Lesser General Public
27 + License along with the GNU C Library; if not, write to the Free
28 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
32 +#include <jmpbuf-offsets.h>
33 +#include <asm-syntax.h>
35 +#include <signal-defines.h>
36 +/* #include <signal.h> */
40 + .section .rodata.str1.1,"aMS",@progbits,1
41 + .type longjmp_msg,@object
43 + .string "longjmp causes uninitialized stack frame"
44 + .size longjmp_msg, .-longjmp_msg
48 +# define CALL_FAIL movl %ebx, %ecx; /* TODO: what's this mov good for? */ \
49 + cfi_register(%ebx,%ecx); \
50 + LOAD_PIC_REG (bx); \
51 + leal longjmp_msg@GOTOFF(%ebx), %eax; \
52 + call HIDDEN_JUMPTARGET(__fortify_fail)
54 +# define CALL_FAIL movl $longjmp_msg, %eax; \
55 + call HIDDEN_JUMPTARGET(__fortify_fail)
60 +ENTRY (____longjmp_chk)
61 + movl 4(%esp), %ecx /* User's jmp_buf in %ecx. */
63 + /* Save the return address now. */
64 + movl (JB_PC*4)(%ecx), %edx
65 + /* Get the stack pointer. */
66 + movl (JB_SP*4)(%ecx), %edi
72 + /* Jumping to a higher-address frame is always allowed. */
75 + /* Passing here, we're either about to do something invalid, or we're
76 + executing on an alternative signal stack. */
78 + /* TODO: need locking? */
79 + /* struct hurd_sigstate * _hurd_self_sigstate (void) */
80 + call _hurd_self_sigstate
81 + /* TODO: %eax and %eax->sigaltstack are always valid? */
83 + testl $SS_ONSTACK, (HURD_SIGSTATE__SIGALTSTACK__OFFSET + SIGALTSTACK__SS_FLAGS__OFFSET)(%eax)
84 + /* Fail if SS_ONSTACK is not set. */
87 + movl (HURD_SIGSTATE__SIGALTSTACK__OFFSET + SIGALTSTACK__SS_SP__OFFSET)(%eax), %ebx
88 + addl (HURD_SIGSTATE__SIGALTSTACK__OFFSET + SIGALTSTACK__SS_SIZE__OFFSET)(%eax), %ebx
90 + cmpl (HURD_SIGSTATE__SIGALTSTACK__OFFSET + SIGALTSTACK__SS_SIZE__OFFSET)(%eax), %ebx
91 + /* TODO: comment this calculation. */
96 +.Lok: /* We add unwind information for the target here. */
97 + cfi_def_cfa(%ecx, 0)
98 + cfi_register(%eip, %edx)
99 + cfi_register(%esp, %edi)
100 + cfi_offset(%ebx, JB_BX*4)
101 + cfi_offset(%esi, JB_SI*4)
102 + cfi_offset(%edi, JB_DI*4)
103 + cfi_offset(%ebp, JB_BP*4)
105 + movl 8(%esp), %eax /* Second argument is return value. */
108 + /* Restore registers. */
109 + movl (JB_BX*4)(%ecx), %ebx
110 + movl (JB_SI*4)(%ecx), %esi
111 + movl (JB_DI*4)(%ecx), %edi
112 + movl (JB_BP*4)(%ecx), %ebp
118 + /* Jump to saved PC. */
120 +END (____longjmp_chk)
122 +++ b/sysdeps/mach/hurd/i386/signal-defines.sym
124 +#include <hurd/signal.h>
129 +HURD_SIGSTATE__SIGALTSTACK__OFFSET offsetof(struct hurd_sigstate, sigaltstack)
131 +SIGALTSTACK__SS_SP__OFFSET offsetof(struct sigaltstack, ss_sp)
132 +SIGALTSTACK__SS_SIZE__OFFSET offsetof(struct sigaltstack, ss_size)
133 +SIGALTSTACK__SS_FLAGS__OFFSET offsetof(struct sigaltstack, ss_flags)
134 --- a/sysdeps/mach/hurd/i386/Makefile
135 +++ b/sysdeps/mach/hurd/i386/Makefile
137 sysdep_routines += ioperm
138 sysdep_headers += sys/io.h
141 +ifeq ($(subdir),debug)
142 +gen-as-const-headers += signal-defines.sym