]> git.corax.cc Git - corax/commitdiff
kernel: Add execeve syscall for execution of ELF files
authorMatthias Kruk <m@m10k.eu>
Sun, 3 May 2020 17:22:24 +0000 (02:22 +0900)
committerMatthias Kruk <m@m10k.eu>
Sun, 3 May 2020 17:22:24 +0000 (02:22 +0900)
include/corax/syscall.h
kernel/core/posixcall.c
kernel/klibc/posixcall.S
libc/posixcall.S

index c8bccb81bd19d690b2020e50d30908ac4a062864..58c7c54b3031d21677c6d6edd660f8605b83ebb5 100644 (file)
@@ -36,6 +36,7 @@
 
 /* Corax-specific variations of POSIX syscalls */
 #define SYS_EXECFVE    128
+#define SYS_EXECEVE    129
 
 #define IPC_SEND       0
 #define IPC_RECV       1
index faea3aa5c196d12a4891f7c230c0a15828c3180d..1bdec663eba33f029823c6f2b86f061c65d5a249 100644 (file)
@@ -293,6 +293,22 @@ int sys_execfve(stack_frame_t *stk)
        return(ret_val);
 }
 
+int sys_execeve(stack_frame_t *stk)
+{
+/*
+       void *elfdata;
+       size_t elfsize;
+       char **argv;
+       char **envp;
+
+       elfdata = stk->ebx;
+       elfsize = stk->ecx;
+       argv = (char**)stk->edx;
+       envp = (char**)stk->esi;
+*/
+       return(-ENOSYS);
+}
+
 int sys_vfork(void)
 {
        return(process_fork(1));
@@ -480,6 +496,10 @@ int sys_posixcall(stack_frame_t *stk)
                ret_val = sys_execfve(stk);
                break;
 
+       case SYS_EXECEVE:
+               ret_val = sys_execeve(stk);
+               break;
+
        case SYS_MMAP:
                ret_val = sys_mmap(stk);
                break;
index 379621597ae3b65c91120fca00782cc874e6b340..3180f8b7a90f91b084872e16a5ea9fab90d8369d 100644 (file)
@@ -10,6 +10,7 @@
        .global _exit
        .global fork
        .global execfve
+       .global execeve
        .global brk
        .global sbrk
        .global mmap
@@ -51,6 +52,19 @@ execfve:
        popl    %ebx
        ret
 
+execeve:
+       pushl   %ebx
+
+       movl    $SYS_EXECEVE, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       movl    20(%esp), %esi
+       int     $SYSCALL_POSIX
+
+       popl    %ebx
+       ret
+
 brk:
        pushl   $0
        call    sbrk
index 6aecef1db5ba034cd36ba392f4ba625351434d47..696d2ee8bb75d53e4573fc612f621f5353b1ed5d 100644 (file)
@@ -36,6 +36,20 @@ exit:
        popl    %ebx
        ret
 
+.global execeve
+execeve:
+       pushl   %ebx
+
+       movl    $SYS_EXECEVE, %eax
+       movl    8(%esp), %ebx
+       movl    12(%esp), %ecx
+       movl    16(%esp), %edx
+       movl    20(%esp), %esi
+       int     $SYSCALL_POSIX
+
+       popl    %ebx
+       ret
+
 .global wait
 wait:
        pushl   %ebx