Revert syscall split (of commit 55d38162be);

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.
This commit is contained in:
Danny Milosavljevic 2020-08-25 11:08:20 +02:00 committed by Jan (janneke) Nieuwenhuizen
parent 3ed3b51371
commit 9db916bba1
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
8 changed files with 341 additions and 259 deletions

View file

@ -21,8 +21,8 @@
#include <linux/x86/syscall.h>
// *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)
{
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);
}

View file

@ -21,14 +21,117 @@
#include <errno.h>
#include <linux/x86/syscall.h>
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)
{

View file

@ -20,23 +20,15 @@
#include <linux/x86/syscall.h>
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)
{
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);
}

View file

@ -21,12 +21,63 @@
#include <errno.h>
#include <linux/x86/syscall.h>
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)

View file

@ -21,8 +21,8 @@
#include <linux/x86/syscall.h>
// *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)
{
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);
}

View file

@ -21,13 +21,99 @@
#include <errno.h>
#include <linux/x86/syscall.h>
// *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)
{

View file

@ -20,23 +20,15 @@
#include <linux/x86/syscall.h>
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");
}
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");
}
/* 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)
{
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);
}

View file

@ -21,11 +21,50 @@
#include <errno.h>
#include <linux/x86/syscall.h>
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)