X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/32b9a6d76790c73d3d2d36d9081a2581cc65d184..28c176b668c841a3b7fb093faccf0efa39257603:/lunaix-os/usr/libc/arch/x86_64/trampoline.S diff --git a/lunaix-os/usr/libc/arch/x86_64/trampoline.S b/lunaix-os/usr/libc/arch/x86_64/trampoline.S new file mode 100644 index 0000000..86bdfd1 --- /dev/null +++ b/lunaix-os/usr/libc/arch/x86_64/trampoline.S @@ -0,0 +1,36 @@ +#include + +.section .text + /* + stack structure: + + ...saved_state \ + void* sighand; > struct siguctx + void* sigact; / + int sig_num; <--- %rsp + */ + .global sigtrampoline + sigtrampoline: + movq %rsp, %rax + andq $-16, %rsp + pushq %rax + + movl (%rax), %edi // signum + xorq %rsi, %rsi // siginfo = NULL + leaq 4(%rax), %rdx // (struct siguctx*)&sigact + call sig_dohandling + + movq $__SYSCALL_sigreturn, %rax + popq %rbx + int $33 + + .global th_trampoline + th_trampoline: + movq (%rsp), %rax + movq 8(%rsp), %rdi + + callq %rax + + movq %rax, %rbx + movq $__SYSCALL_th_exit, %rax + int $33 \ No newline at end of file