2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
6 #ifndef __SYSDEP_STUB_H
7 #define __SYSDEP_STUB_H
9 #include <asm/ptrace.h>
10 #include <asm/unistd.h>
11 #include <sysdep/ptrace_user.h>
13 extern void stub_segv_handler(int sig);
14 extern void stub_clone_handler(void);
16 #define STUB_SYSCALL_RET PT_INDEX(RAX)
17 #define STUB_MMAP_NR __NR_mmap
18 #define MMAP_OFFSET(o) (o)
20 #define __syscall_clobber "r11","rcx","memory"
21 #define __syscall "syscall"
23 static inline long stub_syscall2(long syscall, long arg1, long arg2)
27 __asm__ volatile (__syscall
29 : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber );
34 static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
38 __asm__ volatile (__syscall
40 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3)
41 : __syscall_clobber );
46 static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
51 __asm__ volatile ("movq %5,%%r10 ; " __syscall
53 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
55 : __syscall_clobber, "r10" );
60 static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
65 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
67 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
68 "g" (arg4), "g" (arg5)
69 : __syscall_clobber, "r10", "r8" );
74 static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3,
75 long arg4, long arg5, long arg6)
79 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; "
80 "movq %7, %%r9; " __syscall : "=a" (ret)
81 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
82 "g" (arg4), "g" (arg5), "g" (arg6)
83 : __syscall_clobber, "r10", "r8", "r9" );
88 static inline void trap_myself(void)