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/unistd.h>
10 #include <sysdep/ptrace_user.h>
12 extern void stub_segv_handler(int sig);
13 extern void stub_clone_handler(void);
15 #define STUB_SYSCALL_RET PT_INDEX(RAX)
16 #define STUB_MMAP_NR __NR_mmap
17 #define MMAP_OFFSET(o) (o)
19 #define __syscall_clobber "r11","rcx","memory"
20 #define __syscall "syscall"
22 static inline long stub_syscall0(long syscall)
26 __asm__ volatile (__syscall
28 : "0" (syscall) : __syscall_clobber );
33 static inline long stub_syscall2(long syscall, long arg1, long arg2)
37 __asm__ volatile (__syscall
39 : "0" (syscall), "D" (arg1), "S" (arg2) : __syscall_clobber );
44 static inline long stub_syscall3(long syscall, long arg1, long arg2, long arg3)
48 __asm__ volatile (__syscall
50 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3)
51 : __syscall_clobber );
56 static inline long stub_syscall4(long syscall, long arg1, long arg2, long arg3,
61 __asm__ volatile ("movq %5,%%r10 ; " __syscall
63 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
65 : __syscall_clobber, "r10" );
70 static inline long stub_syscall5(long syscall, long arg1, long arg2, long arg3,
75 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; " __syscall
77 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
78 "g" (arg4), "g" (arg5)
79 : __syscall_clobber, "r10", "r8" );
84 static inline long stub_syscall6(long syscall, long arg1, long arg2, long arg3,
85 long arg4, long arg5, long arg6)
89 __asm__ volatile ("movq %5,%%r10 ; movq %6,%%r8 ; "
90 "movq %7, %%r9; " __syscall : "=a" (ret)
91 : "0" (syscall), "D" (arg1), "S" (arg2), "d" (arg3),
92 "g" (arg4), "g" (arg5), "g" (arg6)
93 : __syscall_clobber, "r10", "r8", "r9" );
98 static inline void trap_myself(void)