From 9db916bba13d080968c97478e9565e7e2ab0d857 Mon Sep 17 00:00:00 2001 From: Danny Milosavljevic Date: Tue, 25 Aug 2020 11:08:20 +0200 Subject: [PATCH] Revert syscall split (of commit 55d38162be9ebd5b90b2550d0331a030c446c001); just copy the two syscalls I need for __raise instead. * lib/linux/arm-mes-gcc/syscall-internal.c (__sys_call_internal): New procedure. (__sys_call2_internal): New procedure. (__raise): Use them. (__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to... * lib/linux/arm-mes-gcc/syscall.c: ...here. * lib/linux/arm-mes-mescc/syscall-internal.c (__sys_call_internal): New procedure. (__sys_call2_internal): New procedure. (__raise): Use them. (__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to... * lib/linux/arm-mes-mescc/syscall.c: ...here. * lib/linux/x86-mes-gcc/syscall-internal.c (__sys_call_internal): New procedure. (__sys_call2_internal): New procedure. (__raise): Use them. (__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to... * lib/linux/x86-mes-gcc/syscall.c: ...here. * lib/linux/x86-mes-mescc/syscall-internal.c (__sys_call_internal): New procedure. (__sys_call2_internal): New procedure. (__raise): Use them. (__sys_call, __sys_call2, __sys_call3, __sys_call4, __sys_call6): Move to... * lib/linux/x86-mes-mescc/syscall.c: ...here. --- lib/linux/arm-mes-gcc/syscall-internal.c | 91 ++------------- lib/linux/arm-mes-gcc/syscall.c | 129 ++++++++++++++++++--- lib/linux/arm-mes-mescc/syscall-internal.c | 56 ++------- lib/linux/arm-mes-mescc/syscall.c | 63 +++++++++- lib/linux/x86-mes-gcc/syscall-internal.c | 69 ++--------- lib/linux/x86-mes-gcc/syscall.c | 98 +++++++++++++++- lib/linux/x86-mes-mescc/syscall-internal.c | 45 ++----- lib/linux/x86-mes-mescc/syscall.c | 49 +++++++- 8 files changed, 341 insertions(+), 259 deletions(-) diff --git a/lib/linux/arm-mes-gcc/syscall-internal.c b/lib/linux/arm-mes-gcc/syscall-internal.c index 1f4fc16b..6aeed250 100644 --- a/lib/linux/arm-mes-gcc/syscall-internal.c +++ b/lib/linux/arm-mes-gcc/syscall-internal.c @@ -21,8 +21,8 @@ #include // *INDENT-OFF* -long -__sys_call (long sys_call) +static long +__sys_call_internal (long sys_call) { long r; asm ( @@ -36,24 +36,8 @@ __sys_call (long sys_call) return r; } -long -__sys_call1 (long sys_call, long one) -{ - long r; - asm ( - "mov r7, %1\n\t" - "mov r0, %2\n\t" - "swi $0\n\t" - "mov %0, r0\n\t" - : "=r" (r) - : "r" (sys_call), "r" (one) - : "r0", "r7" - ); - return r; -} - -long -__sys_call2 (long sys_call, long one, long two) +static long +__sys_call2_internal (long sys_call, long one, long two) { long r; asm ( @@ -68,74 +52,15 @@ __sys_call2 (long sys_call, long one, long two) ); return r; } - -long -__sys_call3 (long sys_call, long one, long two, long three) -{ - long r; - asm ( - "mov r7, %1\n\t" - "mov r0, %2\n\t" - "mov r1, %3\n\t" - "mov r2, %4\n\t" - "swi $0\n\t" - "mov %0, r0\n\t" - : "=r" (r) - : "r" (sys_call), "r" (one), "r" (two), "r" (three) - : "r0", "r1", "r2", "r7" - ); - return r; -} - -long -__sys_call4 (long sys_call, long one, long two, long three, long four) -{ - long r; - asm ( - "mov r7, %1\n\t" - "mov r0, %2\n\t" - "mov r1, %3\n\t" - "mov r2, %4\n\t" - "mov r3, %5\n\t" - "swi $0\n\t" - "mov %0, r0\n\t" - : "=r" (r) - : "r" (sys_call), "r" (one), "r" (two), "r" (three), "r" (four) - : "r0", "r1", "r2", "r3", "r7" - ); - return r; -} - -#if 0 -long -__sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six) -{ - long r; - asm ( - "mov r7, %1\n\t" - "mov r0, %2\n\t" - "mov r1, %3\n\t" - "mov r2, %4\n\t" - "mov r3, %5\n\t" - "mov r4, %6\n\t" - "mov r5, %7\n\t" - "swi $0\n\t" - "mov %0, r0\n\t" - : "=r" (r) - : "r" (sys_call), "r" (one), "r" (two), "r" (three), "r" (four), "r" (five), "r" (six) - : "r0", "r1", "r2", "r3", "r4", "r5" //, "r7" FIXME - ); - return r; -} -#endif +// *INDENT-ON* /* Returns < 0 on error (errno-like value from kernel), or 0 on success */ int -__raise(int signum) +__raise (int signum) { - long pid = __sys_call (SYS_getpid); + long pid = __sys_call_internal (SYS_getpid); if (pid < 0) return pid; else - return __sys_call2 (SYS_kill, pid, signum); + return __sys_call2_internal (SYS_kill, pid, signum); } diff --git a/lib/linux/arm-mes-gcc/syscall.c b/lib/linux/arm-mes-gcc/syscall.c index 9f0251c7..37d13b7d 100644 --- a/lib/linux/arm-mes-gcc/syscall.c +++ b/lib/linux/arm-mes-gcc/syscall.c @@ -21,18 +21,121 @@ #include #include -long __sys_call (long sys_call); -long __sys_call1 (long sys_call, long one); -long __sys_call2 (long sys_call, long one, long two); -long __sys_call3 (long sys_call, long one, long two, long three); -long __sys_call4 (long sys_call, long one, long two, long three, long four); -long __sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six); - // *INDENT-OFF* +long +__sys_call (long sys_call) +{ + long r; + asm ( + "mov r7, %1\n\t" + "swi $0\n\t" + "mov %0, r0\n\t" + : "=r" (r) + : "r" (sys_call) + : "r0", "r7" + ); + return r; +} + +long +__sys_call1 (long sys_call, long one) +{ + long r; + asm ( + "mov r7, %1\n\t" + "mov r0, %2\n\t" + "swi $0\n\t" + "mov %0, r0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one) + : "r0", "r7" + ); + return r; +} + +long +__sys_call2 (long sys_call, long one, long two) +{ + long r; + asm ( + "mov r7, %1\n\t" + "mov r0, %2\n\t" + "mov r1, %3\n\t" + "swi $0\n\t" + "mov %0, r0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one), "r" (two) + : "r0", "r1", "r7" + ); + return r; +} + +long +__sys_call3 (long sys_call, long one, long two, long three) +{ + long r; + asm ( + "mov r7, %1\n\t" + "mov r0, %2\n\t" + "mov r1, %3\n\t" + "mov r2, %4\n\t" + "swi $0\n\t" + "mov %0, r0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one), "r" (two), "r" (three) + : "r0", "r1", "r2", "r7" + ); + return r; +} + +long +__sys_call4 (long sys_call, long one, long two, long three, long four) +{ + long r; + asm ( + "mov r7, %1\n\t" + "mov r0, %2\n\t" + "mov r1, %3\n\t" + "mov r2, %4\n\t" + "mov r3, %5\n\t" + "swi $0\n\t" + "mov %0, r0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one), "r" (two), "r" (three), "r" (four) + : "r0", "r1", "r2", "r3", "r7" + ); + return r; +} + +#if 0 +long +__sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six) +{ + long r; + asm ( + "mov r7, %1\n\t" + "mov r0, %2\n\t" + "mov r1, %3\n\t" + "mov r2, %4\n\t" + "mov r3, %5\n\t" + "mov r4, %6\n\t" + "mov r5, %7\n\t" + "swi $0\n\t" + "mov %0, r0\n\t" + : "=r" (r) + : "r" (sys_call), "r" (one), "r" (two), "r" (three), "r" (four), "r" (five), "r" (six) + : "r0", "r1", "r2", "r3", "r4", "r5" //, "r7" FIXME + ); + return r; +} +#endif + +// *INDENT-ON* + long _sys_call (long sys_call) { - long r = __sys_call(sys_call); + long r = __sys_call (sys_call); if (r < 0) { errno = -r; @@ -46,7 +149,7 @@ _sys_call (long sys_call) long _sys_call1 (long sys_call, long one) { - long r = __sys_call1(sys_call, one); + long r = __sys_call1 (sys_call, one); if (r < 0) { errno = -r; @@ -60,7 +163,7 @@ _sys_call1 (long sys_call, long one) long _sys_call2 (long sys_call, long one, long two) { - long r = __sys_call2(sys_call, one, two); + long r = __sys_call2 (sys_call, one, two); if (r < 0) { errno = -r; @@ -74,7 +177,7 @@ _sys_call2 (long sys_call, long one, long two) long _sys_call3 (long sys_call, long one, long two, long three) { - long r = __sys_call3(sys_call, one, two, three); + long r = __sys_call3 (sys_call, one, two, three); if (r < 0) { errno = -r; @@ -88,7 +191,7 @@ _sys_call3 (long sys_call, long one, long two, long three) long _sys_call4 (long sys_call, long one, long two, long three, long four) { - long r = __sys_call4(sys_call, one, two, three, four); + long r = __sys_call4 (sys_call, one, two, three, four); if (r < 0) { errno = -r; @@ -103,7 +206,7 @@ _sys_call4 (long sys_call, long one, long two, long three, long four) long _sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six) { - long r = __sys_call6(sys_call, one, two, three, four, five, six); + long r = __sys_call6 (sys_call, one, two, three, four, five, six); if (r < 0) { errno = -r; diff --git a/lib/linux/arm-mes-mescc/syscall-internal.c b/lib/linux/arm-mes-mescc/syscall-internal.c index e74fb440..f1246158 100644 --- a/lib/linux/arm-mes-mescc/syscall-internal.c +++ b/lib/linux/arm-mes-mescc/syscall-internal.c @@ -20,23 +20,15 @@ #include -int -__sys_call (int sys_call) +static int +__sys_call_internal (int sys_call) { asm ("!8 ldr____%r7,(%fp,+#$i8)"); asm ("swi____$0"); } -int -__sys_call1 (int sys_call, int one) -{ - asm ("!8 ldr____%r7,(%fp,+#$i8)"); - asm ("!12 ldr____%r0,(%fp,+#$i8)"); - asm ("swi____$0"); -} - -int -__sys_call2 (int sys_call, int one, int two) +static int +__sys_call2_internal (int sys_call, int one, int two) { asm ("!8 ldr____%r7,(%fp,+#$i8)"); asm ("!12 ldr____%r0,(%fp,+#$i8)"); @@ -44,47 +36,13 @@ __sys_call2 (int sys_call, int one, int two) asm ("swi____$0"); } -int -__sys_call3 (int sys_call, int one, int two, int three) -{ - asm ("!8 ldr____%r7,(%fp,+#$i8)"); - asm ("!12 ldr____%r0,(%fp,+#$i8)"); - asm ("!16 ldr____%r1,(%fp,+#$i8)"); - asm ("!20 ldr____%r2,(%fp,+#$i8)"); - asm ("swi____$0"); -} - -int -__sys_call4 (int sys_call, int one, int two, int three, int four) -{ - asm ("!8 ldr____%r7,(%fp,+#$i8)"); - asm ("!12 ldr____%r0,(%fp,+#$i8)"); - asm ("!16 ldr____%r1,(%fp,+#$i8)"); - asm ("!20 ldr____%r2,(%fp,+#$i8)"); - asm ("!24 ldr____%r3,(%fp,+#$i8)"); - asm ("swi____$0"); -} - -int -__sys_call6 (int sys_call, int one, int two, int three, int four, int five, int six) -{ - asm ("!8 ldr____%r7,(%fp,+#$i8)"); - asm ("!12 ldr____%r0,(%fp,+#$i8)"); - asm ("!16 ldr____%r1,(%fp,+#$i8)"); - asm ("!20 ldr____%r2,(%fp,+#$i8)"); - asm ("!24 ldr____%r3,(%fp,+#$i8)"); - asm ("!28 ldr____%r4,(%fp,+#$i8)"); - asm ("!32 ldr____%r5,(%fp,+#$i8)"); - asm ("swi____$0"); -} - /* Returns < 0 on error (errno-like value from kernel), or 0 on success */ int -__raise(int signum) +__raise (int signum) { - int pid = __sys_call (SYS_getpid); + int pid = __sys_call_internal (SYS_getpid); if (pid < 0) return pid; else - return __sys_call2 (SYS_kill, pid, signum); + return __sys_call2_internal (SYS_kill, pid, signum); } diff --git a/lib/linux/arm-mes-mescc/syscall.c b/lib/linux/arm-mes-mescc/syscall.c index a8535917..6ead98f6 100644 --- a/lib/linux/arm-mes-mescc/syscall.c +++ b/lib/linux/arm-mes-mescc/syscall.c @@ -21,12 +21,63 @@ #include #include -int __sys_call (int sys_call); -int __sys_call1 (int sys_call, int one); -int __sys_call2 (int sys_call, int one, int two); -int __sys_call3 (int sys_call, int one, int two, int three); -int __sys_call4 (int sys_call, int one, int two, int three, int four); -int __sys_call6 (int sys_call, int one, int two, int three, int four, int five, int six); +int +__sys_call (int sys_call) +{ + asm ("!8 ldr____%r7,(%fp,+#$i8)"); + asm ("swi____$0"); +} + +int +__sys_call1 (int sys_call, int one) +{ + asm ("!8 ldr____%r7,(%fp,+#$i8)"); + asm ("!12 ldr____%r0,(%fp,+#$i8)"); + asm ("swi____$0"); +} + +int +__sys_call2 (int sys_call, int one, int two) +{ + asm ("!8 ldr____%r7,(%fp,+#$i8)"); + asm ("!12 ldr____%r0,(%fp,+#$i8)"); + asm ("!16 ldr____%r1,(%fp,+#$i8)"); + asm ("swi____$0"); +} + +int +__sys_call3 (int sys_call, int one, int two, int three) +{ + asm ("!8 ldr____%r7,(%fp,+#$i8)"); + asm ("!12 ldr____%r0,(%fp,+#$i8)"); + asm ("!16 ldr____%r1,(%fp,+#$i8)"); + asm ("!20 ldr____%r2,(%fp,+#$i8)"); + asm ("swi____$0"); +} + +int +__sys_call4 (int sys_call, int one, int two, int three, int four) +{ + asm ("!8 ldr____%r7,(%fp,+#$i8)"); + asm ("!12 ldr____%r0,(%fp,+#$i8)"); + asm ("!16 ldr____%r1,(%fp,+#$i8)"); + asm ("!20 ldr____%r2,(%fp,+#$i8)"); + asm ("!24 ldr____%r3,(%fp,+#$i8)"); + asm ("swi____$0"); +} + +int +__sys_call6 (int sys_call, int one, int two, int three, int four, int five, int six) +{ + asm ("!8 ldr____%r7,(%fp,+#$i8)"); + asm ("!12 ldr____%r0,(%fp,+#$i8)"); + asm ("!16 ldr____%r1,(%fp,+#$i8)"); + asm ("!20 ldr____%r2,(%fp,+#$i8)"); + asm ("!24 ldr____%r3,(%fp,+#$i8)"); + asm ("!28 ldr____%r4,(%fp,+#$i8)"); + asm ("!32 ldr____%r5,(%fp,+#$i8)"); + asm ("swi____$0"); +} int _sys_call (int sys_call) diff --git a/lib/linux/x86-mes-gcc/syscall-internal.c b/lib/linux/x86-mes-gcc/syscall-internal.c index fe2117bb..ea8fdd0e 100644 --- a/lib/linux/x86-mes-gcc/syscall-internal.c +++ b/lib/linux/x86-mes-gcc/syscall-internal.c @@ -21,8 +21,8 @@ #include // *INDENT-OFF* -long -__sys_call (long sys_call) +static long +__sys_call_internal (long sys_call) { long r; asm ( @@ -36,24 +36,9 @@ __sys_call (long sys_call) return r; } -long -__sys_call1 (long sys_call, long one) -{ - long r; - asm ( - "mov %1,%%eax\n\t" - "mov %2,%%ebx\n\t" - "int $0x80\n\t" - "mov %%eax,%0\n\t" - : "=r" (r) - : "rm" (sys_call), "rm" (one) - : "eax", "ebx" - ); - return r; -} -long -__sys_call2 (long sys_call, long one, long two) +static long +__sys_call2_internal (long sys_call, long one, long two) { long r; asm ( @@ -68,51 +53,15 @@ __sys_call2 (long sys_call, long one, long two) ); return r; } +// *INDENT-ON* -long -__sys_call3 (long sys_call, long one, long two, long three) -{ - long r; - asm ( - "mov %2,%%ebx\n\t" - "mov %3,%%ecx\n\t" - "mov %4,%%edx\n\t" - "mov %1,%%eax\n\t" - "int $0x80\n\t" - "mov %%eax,%0\n\t" - : "=r" (r) - : "rm" (sys_call), "rm" (one), "rm" (two), "rm" (three) - : "eax", "ebx", "ecx", "edx" - ); - return r; -} - -long -__sys_call4 (long sys_call, long one, long two, long three, long four) -{ - long r; - asm ( - "mov %2,%%ebx\n\t" - "mov %3,%%ecx\n\t" - "mov %4,%%edx\n\t" - "mov %5,%%esi\n\t" - "mov %1,%%eax\n\t" - "int $0x80\n\t" - "mov %%eax,%0\n\t" - : "=r" (r) - : "rm" (sys_call), "rm" (one), "rm" (two), "rm" (three), "rm" (four) - : "eax", "ebx", "ecx", "edx", "esi" - ); - return r; -} - -/* Returns < 0 on error (errno-like value from kernel), or 0 on success */ +/* Return < 0 on error (errno-like value from kernel), or 0 on success */ int -__raise(int signum) +__raise (int signum) { - long pid = __sys_call (SYS_getpid); + long pid = __sys_call_internal (SYS_getpid); if (pid < 0) return pid; else - return __sys_call2 (SYS_kill, pid, signum); + return __sys_call2_internal (SYS_kill, pid, signum); } diff --git a/lib/linux/x86-mes-gcc/syscall.c b/lib/linux/x86-mes-gcc/syscall.c index 0b5c2a70..28d2b662 100644 --- a/lib/linux/x86-mes-gcc/syscall.c +++ b/lib/linux/x86-mes-gcc/syscall.c @@ -21,17 +21,103 @@ #include #include +// *INDENT-OFF* +long +__sys_call (long sys_call) +{ + long r; + asm ( + "mov %1,%%eax\n\t" + "int $0x80\n\t" + "mov %%eax,%0\n\t" + : "=r" (r) + : "rm" (sys_call) + : "eax" + ); + return r; +} + +long +__sys_call1 (long sys_call, long one) +{ + long r; + asm ( + "mov %1,%%eax\n\t" + "mov %2,%%ebx\n\t" + "int $0x80\n\t" + "mov %%eax,%0\n\t" + : "=r" (r) + : "rm" (sys_call), "rm" (one) + : "eax", "ebx" + ); + return r; +} + +long +__sys_call2 (long sys_call, long one, long two) +{ + long r; + asm ( + "mov %1,%%eax\n\t" + "mov %2,%%ebx\n\t" + "mov %3,%%ecx\n\t" + "int $0x80\n\t" + "mov %%eax,%0\n\t" + : "=r" (r) + : "rm" (sys_call), "rm" (one), "rm" (two) + : "eax", "ebx", "ecx" + ); + return r; +} + +long +__sys_call3 (long sys_call, long one, long two, long three) +{ + long r; + asm ( + "mov %2,%%ebx\n\t" + "mov %3,%%ecx\n\t" + "mov %4,%%edx\n\t" + "mov %1,%%eax\n\t" + "int $0x80\n\t" + "mov %%eax,%0\n\t" + : "=r" (r) + : "rm" (sys_call), "rm" (one), "rm" (two), "rm" (three) + : "eax", "ebx", "ecx", "edx" + ); + return r; +} + +long +__sys_call4 (long sys_call, long one, long two, long three, long four) +{ + long r; + asm ( + "mov %2,%%ebx\n\t" + "mov %3,%%ecx\n\t" + "mov %4,%%edx\n\t" + "mov %5,%%esi\n\t" + "mov %1,%%eax\n\t" + "int $0x80\n\t" + "mov %%eax,%0\n\t" + : "=r" (r) + : "rm" (sys_call), "rm" (one), "rm" (two), "rm" (three), "rm" (four) + : "eax", "ebx", "ecx", "edx", "esi" + ); + return r; +} +// *INDENT-ON* + long __sys_call (long sys_call); long __sys_call1 (long sys_call, long one); long __sys_call2 (long sys_call, long one, long two); long __sys_call3 (long sys_call, long one, long two, long three); long __sys_call4 (long sys_call, long one, long two, long three, long four); -// *INDENT-OFF* long _sys_call (long sys_call) { - long r = __sys_call(sys_call); + long r = __sys_call (sys_call); if (r < 0) { errno = -r; @@ -45,7 +131,7 @@ _sys_call (long sys_call) long _sys_call1 (long sys_call, long one) { - long r = __sys_call1(sys_call, one); + long r = __sys_call1 (sys_call, one); if (r < 0) { errno = -r; @@ -59,7 +145,7 @@ _sys_call1 (long sys_call, long one) long _sys_call2 (long sys_call, long one, long two) { - long r = __sys_call2(sys_call, one, two); + long r = __sys_call2 (sys_call, one, two); if (r < 0) { errno = -r; @@ -73,7 +159,7 @@ _sys_call2 (long sys_call, long one, long two) long _sys_call3 (long sys_call, long one, long two, long three) { - long r = __sys_call3(sys_call, one, two, three); + long r = __sys_call3 (sys_call, one, two, three); if (r < 0) { errno = -r; @@ -87,7 +173,7 @@ _sys_call3 (long sys_call, long one, long two, long three) long _sys_call4 (long sys_call, long one, long two, long three, long four) { - long r = __sys_call4(sys_call, one, two, three, four); + long r = __sys_call4 (sys_call, one, two, three, four); if (r < 0) { errno = -r; diff --git a/lib/linux/x86-mes-mescc/syscall-internal.c b/lib/linux/x86-mes-mescc/syscall-internal.c index cf115810..451c5ed7 100644 --- a/lib/linux/x86-mes-mescc/syscall-internal.c +++ b/lib/linux/x86-mes-mescc/syscall-internal.c @@ -20,23 +20,15 @@ #include -int -__sys_call (int sys_call) +static int +__sys_call_internal (int sys_call) { asm ("mov____0x8(%ebp),%eax !8"); asm ("int____$0x80"); } -int -__sys_call1 (int sys_call, int one) -{ - asm ("mov____0x8(%ebp),%eax !8"); - asm ("mov____0x8(%ebp),%ebx !12"); - asm ("int____$0x80"); -} - -int -__sys_call2 (int sys_call, int one, int two) +static int +__sys_call2_internal (int sys_call, int one, int two) { asm ("mov____0x8(%ebp),%eax !8"); asm ("mov____0x8(%ebp),%ebx !12"); @@ -44,34 +36,13 @@ __sys_call2 (int sys_call, int one, int two) asm ("int____$0x80"); } +/* Return < 0 on error (errno-like value from kernel), or 0 on success */ int -__sys_call3 (int sys_call, int one, int two, int three) +__raise (int signum) { - asm ("mov____0x8(%ebp),%eax !8"); - asm ("mov____0x8(%ebp),%ebx !12"); - asm ("mov____0x8(%ebp),%ecx !16"); - asm ("mov____0x8(%ebp),%edx !20"); - asm ("int____$0x80"); -} - -int -__sys_call4 (int sys_call, int one, int two, int three, int four) -{ - asm ("mov____0x8(%ebp),%eax !8"); - asm ("mov____0x8(%ebp),%ebx !12"); - asm ("mov____0x8(%ebp),%ecx !16"); - asm ("mov____0x8(%ebp),%edx !20"); - asm ("mov____0x8(%ebp),%esi !24"); - asm ("int____$0x80"); -} - -/* Returns < 0 on error (errno-like value from kernel), or 0 on success */ -int -__raise(int signum) -{ - int pid = __sys_call (SYS_getpid); + int pid = __sys_call_internal (SYS_getpid); if (pid < 0) return pid; else - return __sys_call2 (SYS_kill, pid, signum); + return __sys_call2_internal (SYS_kill, pid, signum); } diff --git a/lib/linux/x86-mes-mescc/syscall.c b/lib/linux/x86-mes-mescc/syscall.c index 2488e860..5d88cca5 100644 --- a/lib/linux/x86-mes-mescc/syscall.c +++ b/lib/linux/x86-mes-mescc/syscall.c @@ -21,11 +21,50 @@ #include #include -int __sys_call (int sys_call); -int __sys_call1 (int sys_call, int one); -int __sys_call2 (int sys_call, int one, int two); -int __sys_call3 (int sys_call, int one, int two, int three); -int __sys_call4 (int sys_call, int one, int two, int three, int four); +int +__sys_call (int sys_call) +{ + asm ("mov____0x8(%ebp),%eax !8"); + asm ("int____$0x80"); +} + +int +__sys_call1 (int sys_call, int one) +{ + asm ("mov____0x8(%ebp),%eax !8"); + asm ("mov____0x8(%ebp),%ebx !12"); + asm ("int____$0x80"); +} + +int +__sys_call2 (int sys_call, int one, int two) +{ + asm ("mov____0x8(%ebp),%eax !8"); + asm ("mov____0x8(%ebp),%ebx !12"); + asm ("mov____0x8(%ebp),%ecx !16"); + asm ("int____$0x80"); +} + +int +__sys_call3 (int sys_call, int one, int two, int three) +{ + asm ("mov____0x8(%ebp),%eax !8"); + asm ("mov____0x8(%ebp),%ebx !12"); + asm ("mov____0x8(%ebp),%ecx !16"); + asm ("mov____0x8(%ebp),%edx !20"); + asm ("int____$0x80"); +} + +int +__sys_call4 (int sys_call, int one, int two, int three, int four) +{ + asm ("mov____0x8(%ebp),%eax !8"); + asm ("mov____0x8(%ebp),%ebx !12"); + asm ("mov____0x8(%ebp),%ecx !16"); + asm ("mov____0x8(%ebp),%edx !20"); + asm ("mov____0x8(%ebp),%esi !24"); + asm ("int____$0x80"); +} int _sys_call (int sys_call)