// Copyright 2017 syzkaller project authors. All rights reserved. // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. // +build #define SYZ_EXECUTOR #include "common_fuchsia.h" #include "executor_fuchsia.h" #include "syscalls_fuchsia.h" #include "executor.h" uint32 output; int main(int argc, char** argv) { if (argc == 2 && strcmp(argv[1], "version") == 0) { puts(GOOS " " GOARCH " " SYZ_REVISION " " GIT_REVISION); return 0; } if (syz_mmap(SYZ_DATA_OFFSET, SYZ_NUM_PAGES * SYZ_PAGE_SIZE) != ZX_OK) fail("mmap of data segment failed"); install_segv_handler(); main_init(); execute_one(); (void)error; // prevent unused function warning return 0; } long execute_syscall(const call_t* c, long a0, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8) { long res = ZX_ERR_INVALID_ARGS; NONFAILING(res = c->call(a0, a1, a2, a3, a4, a5, a6, a7, a8)); if (strncmp(c->name, "zx_", 3) == 0) { // Convert zircon error convention to the libc convention that executor expects. if (res == ZX_OK) return 0; errno = res; return -1; } // We cast libc functions to signature returning long, // as the result int -1 is returned as 0x00000000ffffffff rather than full -1. if (res == 0xffffffff) res = (long)-1; return res; } void cover_open() { } void cover_enable(thread_t* th) { } void cover_reset(thread_t* th) { } uint32 cover_read_size(thread_t* th) { return 0; } bool cover_check(uint32 pc) { return true; } bool cover_check(uint64 pc) { return true; } uint32* write_output(uint32 v) { return &output; } void write_completed(uint32 completed) { } bool kcov_comparison_t::ignore() const { return false; }