Kernel: Add support for SA_SIGINFO
This commit is contained in:
@@ -2,15 +2,41 @@
|
||||
|
||||
// stack contains
|
||||
// return address
|
||||
// return stack
|
||||
// return rflags
|
||||
// siginfo_t
|
||||
// signal number
|
||||
// signal handler
|
||||
|
||||
.global signal_trampoline
|
||||
signal_trampoline:
|
||||
pusha
|
||||
pushl %esi // gregs
|
||||
pushl %edi
|
||||
pushl %edx
|
||||
pushl %ecx
|
||||
pushl %ebx
|
||||
pushl %eax
|
||||
pushl %ebp
|
||||
|
||||
movl 40(%esp), %edi
|
||||
movl 36(%esp), %eax
|
||||
movl 76(%esp), %eax // return sp
|
||||
addl $4, %eax // return address
|
||||
movl 80(%esp), %ebx // return ip
|
||||
pushl %eax;
|
||||
pushl %ebx
|
||||
|
||||
// FIXME: populate these
|
||||
xorl %eax, %eax
|
||||
pushl %eax // stack
|
||||
pushl %eax
|
||||
pushl %eax
|
||||
pushl %eax // sigset
|
||||
pushl %eax
|
||||
pushl %eax // link
|
||||
|
||||
movl %esp, %edx // ucontext
|
||||
leal 68(%esp), %esi // siginfo
|
||||
movl 64(%esp), %edi // signal number
|
||||
movl 60(%esp), %eax // handlers
|
||||
|
||||
// align stack to 16 bytes
|
||||
movl %esp, %ebp
|
||||
@@ -19,7 +45,9 @@ signal_trampoline:
|
||||
subl $512, %esp
|
||||
fxsave (%esp)
|
||||
|
||||
subl $12, %esp
|
||||
subl $4, %esp
|
||||
pushl %edx
|
||||
pushl %esi
|
||||
pushl %edi
|
||||
call *%eax
|
||||
addl $16, %esp
|
||||
@@ -29,9 +57,21 @@ signal_trampoline:
|
||||
|
||||
// restore stack
|
||||
movl %ebp, %esp
|
||||
popa
|
||||
addl $32, %esp
|
||||
|
||||
addl $8, %esp
|
||||
// restore registers
|
||||
popl %ebp
|
||||
popl %eax
|
||||
popl %ebx
|
||||
popl %ecx
|
||||
popl %edx
|
||||
popl %edi
|
||||
popl %esi
|
||||
|
||||
// skip handler, number, siginfo_t
|
||||
addl $44, %esp
|
||||
|
||||
// restore flags
|
||||
popf
|
||||
|
||||
movl (%esp), %esp
|
||||
|
||||
@@ -2,29 +2,48 @@
|
||||
|
||||
// stack contains
|
||||
// return address
|
||||
// return stack
|
||||
// return rflags
|
||||
// siginfo_t
|
||||
// signal number
|
||||
// signal handler
|
||||
|
||||
.global signal_trampoline
|
||||
signal_trampoline:
|
||||
pushq %rax
|
||||
pushq %rbx
|
||||
pushq %rcx
|
||||
pushq %rdx
|
||||
pushq %rbp
|
||||
pushq %rdi
|
||||
pushq %rsi
|
||||
pushq %r8
|
||||
pushq %r9
|
||||
pushq %r10
|
||||
pushq %r11
|
||||
pushq %r12
|
||||
pushq %r13
|
||||
pushq %r15 // gregs
|
||||
pushq %r14
|
||||
pushq %r15
|
||||
pushq %r13
|
||||
pushq %r12
|
||||
pushq %r11
|
||||
pushq %r10
|
||||
pushq %r9
|
||||
pushq %r8
|
||||
pushq %rsi
|
||||
pushq %rdi
|
||||
pushq %rdx
|
||||
pushq %rcx
|
||||
pushq %rbx
|
||||
pushq %rax
|
||||
pushq %rbp
|
||||
|
||||
movq 128(%rsp), %rdi
|
||||
movq 120(%rsp), %rax
|
||||
movq 200(%rsp), %rax // return sp
|
||||
addq $(128 + 8), %rax // red-zone and return address
|
||||
movq 208(%rsp), %rbx // return ip
|
||||
pushq %rax;
|
||||
pushq %rbx
|
||||
|
||||
// FIXME: populate these
|
||||
xorq %rax, %rax
|
||||
pushq %rax // stack
|
||||
pushq %rax
|
||||
pushq %rax
|
||||
pushq %rax // sigset
|
||||
pushq %rax // link
|
||||
|
||||
movq %rsp, %rdx // ucontext
|
||||
leaq 192(%rsp), %rsi // siginfo
|
||||
movq 184(%rsp), %rdi // signal number
|
||||
movq 176(%rsp), %rax // handler
|
||||
|
||||
// align stack to 16 bytes
|
||||
movq %rsp, %rbp
|
||||
@@ -40,26 +59,32 @@ signal_trampoline:
|
||||
|
||||
// restore stack
|
||||
movq %rbp, %rsp
|
||||
popq %r15
|
||||
popq %r14
|
||||
popq %r13
|
||||
popq %r12
|
||||
popq %r11
|
||||
popq %r10
|
||||
popq %r9
|
||||
popq %r8
|
||||
popq %rsi
|
||||
popq %rdi
|
||||
popq %rbp
|
||||
popq %rdx
|
||||
popq %rcx
|
||||
popq %rbx
|
||||
popq %rax
|
||||
addq $56, %rsp
|
||||
|
||||
addq $16, %rsp
|
||||
// restore registers
|
||||
popq %rbp
|
||||
popq %rax
|
||||
popq %rbx
|
||||
popq %rcx
|
||||
popq %rdx
|
||||
popq %rdi
|
||||
popq %rsi
|
||||
popq %r8
|
||||
popq %r9
|
||||
popq %r10
|
||||
popq %r11
|
||||
popq %r12
|
||||
popq %r13
|
||||
popq %r14
|
||||
popq %r15
|
||||
|
||||
// skip handler, number, siginfo_t
|
||||
addq $72, %rsp
|
||||
|
||||
// restore flags
|
||||
popfq
|
||||
|
||||
movq (%rsp), %rsp
|
||||
|
||||
// return over red-zone
|
||||
// return over red-zone and siginfo_t
|
||||
ret $128
|
||||
|
||||
Reference in New Issue
Block a user