From fb09e1ff06cdc561167bf484a4daf747badef1ef Mon Sep 17 00:00:00 2001 From: Ziyao Date: Mon, 21 Mar 2022 16:50:35 +0800 Subject: [PATCH] Add syscall --- arch/x86_64/syscall_arch.h | 10 ++++++++ src/unistd/x86_64/syscall.S | 50 +++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/unistd/x86_64/syscall.S diff --git a/arch/x86_64/syscall_arch.h b/arch/x86_64/syscall_arch.h index 92d5c17..4afa63a 100644 --- a/arch/x86_64/syscall_arch.h +++ b/arch/x86_64/syscall_arch.h @@ -23,6 +23,7 @@ static __inline long __syscall2(long n, long a1, long a2) return ret; } + static __inline long __syscall3(long n, long a1, long a2, long a3) { unsigned long ret; @@ -31,6 +32,7 @@ static __inline long __syscall3(long n, long a1, long a2, long a3) return ret; } +/* static __inline long __syscall4(long n, long a1, long a2, long a3, long a4) { unsigned long ret; @@ -60,6 +62,14 @@ static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long "d"(a3), "r"(r10), "r"(r8), "r"(r9) : "rcx", "r11", "memory"); return ret; } +*/ + +long int __syscall4(long int n,long int a1,long int a2,long int a3, + long int a4); +long int __syscall5(long int n,long int a1,long int a2,long int a3, + long int a4,long int a5); +long int __syscall6(long int n,long int a1,long int a2,long int a3, + long int a4,long int a5,long int a6); #define VDSO_USEFUL #define VDSO_CGT_SYM "__vdso_clock_gettime" diff --git a/src/unistd/x86_64/syscall.S b/src/unistd/x86_64/syscall.S new file mode 100644 index 0000000..27d3d15 --- /dev/null +++ b/src/unistd/x86_64/syscall.S @@ -0,0 +1,50 @@ +/* + musl-tcc + File:/src/unistd/x86_64/syscall.S + Copyright(c) 2022 ziyao. +*/ + + .global __syscall4,__syscall5,__syscall6 + +/* + long int __syscall4(long int n, long int a1,long int a2, + long int a2,long int a3,long int a4); + n %rdi + a1 %rsi + a2 %rdx + a3 %rcx + a4 %r8 +*/ + + .type __syscall4,@function +__syscall4: + movq %rdi, %rax + movq %rsi, %rdi + movq %rdx, %rsi + movq %rcx, %rdx + movq %r8, %r10 + syscall + retq + + .type __syscall5,@function +__syscall5: + movq %rdi, %rax + movq %rsi, %rdi + movq %rdx, %rsi + movq %rcx, %rdx + movq %r8, %r10 + movq %r9, %r8 + syscall + retq + + .type __syscall6,@function +__syscall6: + movq %rdi, %rax + movq %rsi, %rdi + movq %rdx, %rsi + movq %rcx, %rdx + movq %r8, %r10 + movq %r9, %r8 + popq %r9 // The last argument is stored on the stack + syscall + retq