1 // Copyright 2017 syzkaller project authors. All rights reserved.
2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
3
4 #include <stdio.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <sys/mman.h>
8 #include <unistd.h>
9
10 #include "nocover.h"
11
os_init(int argc,char ** argv,void * data,size_t data_size)12 static void os_init(int argc, char** argv, void* data, size_t data_size)
13 {
14 program_name = argv[0];
15 if (argc == 2 && strcmp(argv[1], "child") == 0) {
16 if (mmap(data, data_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0) != data)
17 fail("mmap of data segment failed");
18 child();
19 }
20 }
21
execute_syscall(const call_t * c,long a[kMaxArgs])22 static long execute_syscall(const call_t* c, long a[kMaxArgs])
23 {
24 return syscall(c->sys_nr, a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);
25 }
26