From e2f1c7ed36b35111ae7f2c6d6dbe43d50ffddd90 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 25 Sep 2017 15:40:58 +0200 Subject: Makefile: add fuchsia support --- Makefile | 54 ++++++++++++++++++++++++++++---------------- docs/fuchsia.md | 19 ++++++++++++++++ docs/windows.md | 4 ++-- executor/executor_fuchsia.cc | 1 + 4 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 docs/fuchsia.md diff --git a/Makefile b/Makefile index d6a498cd0..da5b5eefe 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ HOSTARCH ?= $(BUILDARCH) TARGETOS ?= $(HOSTOS) TARGETARCH ?= $(HOSTARCH) TARGETVMARCH ?= $(TARGETARCH) +GO := go ifeq ("$(TARGETARCH)", "amd64") CC = "x86_64-linux-gnu-gcc" @@ -76,6 +77,19 @@ ifeq ("$(TARGETOS)", "android") CFLAGS = -I $(NDK)/sources/cxx-stl/llvm-libc++/include --sysroot=$(NDK)/platforms/android-$(ANDROID_API)/arch-$(ANDROIDARCH) -O1 -g -Wall -static endif +ifeq ("$(TARGETOS)", "fuchsia") + # SOURCEDIR should point to fuchsia checkout. + GO = $(SOURCEDIR)/buildtools/go + CC = $(SOURCEDIR)/buildtools/linux-x64/clang/bin/clang++ + export CGO_ENABLED=1 + NOSTATIC = 1 + ifeq ("$(TARGETARCH)", "amd64") + ADDCFLAGS = --target=x86_64-fuchsia -lfdio -lzircon --sysroot $(SOURCEDIR)/out/build-zircon/build-zircon-pc-x86-64/sysroot + else ifeq ("$(TARGETARCH)", "arm64") + ADDCFLAGS = --target=aarch64-fuchsia -lfdio -lzircon --sysroot $(SOURCEDIR)/out/build-zircon/build-zircon-pc-x86-64/sysroot + endif +endif + GITREV=$(shell git rev-parse HEAD) ifeq ($(`git diff --shortstat`), "") REV=$(GITREV) @@ -108,11 +122,11 @@ endif all: host target host: - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) go install ./syz-manager + GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO) install ./syz-manager $(MAKE) manager repro mutate prog2c db upgrade target: - GOOS=$(TARGETOS) GOARCH=$(TARGETVMARCH) go install ./syz-fuzzer + GOOS=$(TARGETOS) GOARCH=$(TARGETVMARCH) $(GO) install ./syz-fuzzer $(MAKE) fuzzer execprog stress executor # executor uses stacks of limited size, so no jumbo frames. @@ -123,57 +137,57 @@ executor: $(ADDCFLAGS) $(CFLAGS) -DGIT_REVISION=\"$(REV)\" manager: - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) go build $(GOFLAGS) -o ./bin/syz-manager github.com/google/syzkaller/syz-manager + GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO) build $(GOFLAGS) -o ./bin/syz-manager github.com/google/syzkaller/syz-manager fuzzer: - GOOS=$(TARGETOS) GOARCH=$(TARGETVMARCH) go build $(GOFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-fuzzer github.com/google/syzkaller/syz-fuzzer + GOOS=$(TARGETOS) GOARCH=$(TARGETVMARCH) $(GO) build $(GOFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-fuzzer github.com/google/syzkaller/syz-fuzzer execprog: - GOOS=$(TARGETOS) GOARCH=$(TARGETVMARCH) go build $(GOFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-execprog github.com/google/syzkaller/tools/syz-execprog + GOOS=$(TARGETOS) GOARCH=$(TARGETVMARCH) $(GO) build $(GOFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-execprog github.com/google/syzkaller/tools/syz-execprog ci: - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) go build $(GOFLAGS) -o ./bin/syz-ci github.com/google/syzkaller/syz-ci + GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO) build $(GOFLAGS) -o ./bin/syz-ci github.com/google/syzkaller/syz-ci hub: - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) go build $(GOFLAGS) -o ./bin/syz-hub github.com/google/syzkaller/syz-hub + GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO) build $(GOFLAGS) -o ./bin/syz-hub github.com/google/syzkaller/syz-hub repro: - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) go build $(GOFLAGS) -o ./bin/syz-repro github.com/google/syzkaller/tools/syz-repro + GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO) build $(GOFLAGS) -o ./bin/syz-repro github.com/google/syzkaller/tools/syz-repro mutate: - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) go build $(GOFLAGS) -o ./bin/syz-mutate github.com/google/syzkaller/tools/syz-mutate + GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO) build $(GOFLAGS) -o ./bin/syz-mutate github.com/google/syzkaller/tools/syz-mutate prog2c: - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) go build $(GOFLAGS) -o ./bin/syz-prog2c github.com/google/syzkaller/tools/syz-prog2c + GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO) build $(GOFLAGS) -o ./bin/syz-prog2c github.com/google/syzkaller/tools/syz-prog2c stress: - GOOS=$(TARGETOS) GOARCH=$(TARGETVMARCH) go build $(GOFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-stress github.com/google/syzkaller/tools/syz-stress + GOOS=$(TARGETOS) GOARCH=$(TARGETVMARCH) $(GO) build $(GOFLAGS) -o ./bin/$(TARGETOS)_$(TARGETVMARCH)/syz-stress github.com/google/syzkaller/tools/syz-stress db: - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) go build $(GOFLAGS) -o ./bin/syz-db github.com/google/syzkaller/tools/syz-db + GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO) build $(GOFLAGS) -o ./bin/syz-db github.com/google/syzkaller/tools/syz-db upgrade: - GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) go build $(GOFLAGS) -o ./bin/syz-upgrade github.com/google/syzkaller/tools/syz-upgrade + GOOS=$(HOSTOS) GOARCH=$(HOSTARCH) $(GO) build $(GOFLAGS) -o ./bin/syz-upgrade github.com/google/syzkaller/tools/syz-upgrade extract: bin/syz-extract bin/syz-extract -build -os=$(TARGETOS) -sourcedir=$(SOURCEDIR) bin/syz-extract: - go build $(GOFLAGS) -o $@ ./sys/syz-extract + $(GO) build $(GOFLAGS) -o $@ ./sys/syz-extract generate: bin/syz-sysgen bin/syz-sysgen - go generate ./pkg/csource ./executor ./pkg/ifuzz ./pkg/kernel + $(GO) generate ./pkg/csource ./executor ./pkg/ifuzz ./pkg/kernel $(MAKE) format bin/syz-sysgen: - go build $(GOFLAGS) -o $@ ./sys/syz-sysgen + $(GO) build $(GOFLAGS) -o $@ ./sys/syz-sysgen format: bin/syz-fmt - go fmt ./... + $(GO) fmt ./... clang-format --style=file -i executor/*.cc executor/*.h tools/kcovtrace/*.c bin/syz-fmt sys/linux bin/syz-fmt sys/fuchsia bin/syz-fmt: - go build $(GOFLAGS) -o $@ ./tools/syz-fmt + $(GO) build $(GOFLAGS) -o $@ ./tools/syz-fmt tidy: # A single check is enabled for now. But it's always fixable and proved to be useful. @@ -182,8 +196,8 @@ tidy: $(CC) executor/test_executor.cc -c -o /dev/null -Wparentheses -Wno-unused -Wall test: - go test -short ./... - go test -short -race ./... + $(GO) test -short ./... + $(GO) test -short -race ./... arch: env HOSTOS=darwin HOSTARCH=amd64 $(MAKE) host diff --git a/docs/fuchsia.md b/docs/fuchsia.md new file mode 100644 index 000000000..71932708c --- /dev/null +++ b/docs/fuchsia.md @@ -0,0 +1,19 @@ +# Fuchsia support + +To update descriptions run: +``` +make extract TARGETOS=fuchsia SOURCEDIR=/path/to/fuchsia/checkout +make generate +``` + +To build binaries: +``` +make TARGETOS=fuchsia TARGETARCH=amd64 SOURCEDIR=/path/to/fuchsia/checkout +``` + +To run: +``` +$SOURCEDIR/out/build-zircon/tools/netcp bin/fuchsia_amd64/syz-executor :/syz-executor +$SOURCEDIR/out/build-zircon/tools/netcp bin/fuchsia_amd64/syz-stress :/syz-stress +$SOURCEDIR/out/build-zircon/tools/netruncmd : "/syz-stress -executor /syz-executor -cover=0" +``` diff --git a/docs/windows.md b/docs/windows.md index b89caf55c..12691a521 100644 --- a/docs/windows.md +++ b/docs/windows.md @@ -1,4 +1,4 @@ -# Windows +# Windows support To update descriptions run (assumes `cl` cross-compiler is in PATH): ``` @@ -15,4 +15,4 @@ cl executor\executor_windows.cc /EHsc -o bin\windows_amd64\syz-executor.exe To run: ``` bin\windows_amd64\syz-stress.exe -executor c:\full\path\to\bin\windows_amd64\syz-executor.exe -cover=0 -``` \ No newline at end of file +``` diff --git a/executor/executor_fuchsia.cc b/executor/executor_fuchsia.cc index 7bb7146e1..a5aa19470 100644 --- a/executor/executor_fuchsia.cc +++ b/executor/executor_fuchsia.cc @@ -22,6 +22,7 @@ int main(int argc, char** argv) return 0; } + install_segv_handler(); int pos = 0; for (;;) { int rv = read(0, input_data + pos, sizeof(input_data) - pos); -- cgit mrf-deployment