diff --git a/src/kernel/emulation/linux/CMakeLists.txt b/src/kernel/emulation/linux/CMakeLists.txt index 93f2f554a..056e4f676 100644 --- a/src/kernel/emulation/linux/CMakeLists.txt +++ b/src/kernel/emulation/linux/CMakeLists.txt @@ -67,10 +67,10 @@ set(emulation_sources unistd/setgroups.c unistd/getgroups.c unistd/pipe.c - unistd/chmod_extended.c - unistd/fchmod_extended.c - unistd/fchflags.c - unistd/chflags.c + unistd/chmod_extended.c + unistd/fchmod_extended.c + unistd/fchflags.c + unistd/chflags.c select/select.c select/poll.c process/vfork.c @@ -91,7 +91,7 @@ set(emulation_sources misc/proc_info.c misc/sysctl.c misc/getrlimit.c - misc/setrlimit.c + misc/setrlimit.c misc/gethostuuid.c misc/getrusage.c misc/getlogin.c @@ -169,9 +169,10 @@ set(emulation_sources psynch/psynch_cvwait.c psynch/psynch_cvbroad.c psynch/psynch_cvsignal.c - conf/pathconf.c - conf/fpathconf.c + conf/pathconf.c + conf/fpathconf.c syscalls-table.S + linux-syscall.S ) set_source_files_properties(mman/mman.c PROPERTIES COMPILE_FLAGS diff --git a/src/kernel/emulation/linux/base.c b/src/kernel/emulation/linux/base.c index 89cf5dbf9..b7f37f7da 100644 --- a/src/kernel/emulation/linux/base.c +++ b/src/kernel/emulation/linux/base.c @@ -5,53 +5,6 @@ #include "duct_errno.h" #include "syscalls.h" -#ifdef __x86_64__ -__attribute__((naked)) -long linux_syscall(long a1, long a2, long a3, long a4, long a5, long a6, int nr) -{ - __asm__ ("movl 8(%rsp), %eax\n" - "movq %rcx, %r10\n" - "syscall\n" - "ret"); -} -#elif defined(__i386__) -__attribute__((naked)) -long linux_syscall(long a1, long a2, long a3, long a4, long a5, long a6, int nr) -{ - __asm__("push %ebp\n" - "push %ebx\n" - "push %esi\n" - "push %edi\n" - "call 1f\n" - "1:\n" - "pop %ebp\n" - "addl $(2f-1b), %ebp\n" - "push %ebp\n" - "push %ecx\n" - "push %edx\n" - "movl 28+28(%esp), %eax\n" - "movl 4+28(%esp), %ebx\n" - "movl 8+28(%esp), %ecx\n" - "movl 12+28(%esp), %edx\n" - "movl 16+28(%esp), %esi\n" - "movl 20+28(%esp), %edi\n" - "push %ebp\n" - "movl 24+28(%esp), %ebp\n" - "movl %ebp, -4(%esp)\n" - "movl %esp, %ebp\n" - "sysenter\n" - "2:\n" - "pop %edi\n" - "pop %esi\n" - "pop %ebx\n" - "pop %ebp\n" - "ret" - ); -} -#else -# error Unsupported platform! -#endif - long __unknown_syscall(int nr, ...) { __simple_printf("Unimplemented syscall (%d)\n", nr); diff --git a/src/kernel/emulation/linux/linux-syscall.S b/src/kernel/emulation/linux/linux-syscall.S new file mode 100644 index 000000000..67d5301db --- /dev/null +++ b/src/kernel/emulation/linux/linux-syscall.S @@ -0,0 +1,49 @@ +.text +.globl linux_syscall + +linux_syscall: + +#if defined(__x86_64__) + + movl 8(%rsp), %eax + movq %rcx, %r10 + syscall + ret + +#elif defined(__i386__) + + push %ebp + push %ebx + push %esi + push %edi + call 1f +1: + pop %ebp + addl $(2f-1b), %ebp + push %ebp + push %ecx + push %edx + movl 28+28(%esp), %eax + movl 4+28(%esp), %ebx + movl 8+28(%esp), %ecx + movl 12+28(%esp), %edx + movl 16+28(%esp), %esi + movl 20+28(%esp), %edi + push %ebp + movl 24+28(%esp), %ebp + movl %ebp, -4(%esp) + movl %esp, %ebp + sysenter +2: + pop %edi + pop %esi + pop %ebx + pop %ebp + ret + +#else + +# error Missing assembly! + +#endif + diff --git a/src/kernel/emulation/linux/syscalls-table.S b/src/kernel/emulation/linux/syscalls-table.S index 590b68663..be3ffc87d 100644 --- a/src/kernel/emulation/linux/syscalls-table.S +++ b/src/kernel/emulation/linux/syscalls-table.S @@ -1,3 +1,4 @@ +.text .globl __darling_bsd_syscall #if defined(__x86_64__)