mirror of
https://github.com/reactos/syzkaller.git
synced 2025-01-23 20:34:21 +00:00
Makefile: fix Android builds
There are 2 known problems with current Android support: 1. It does not work with newer NDK (happens on every NDK update). 2. Dynamic Go binaries do not start on Android emulator. Drop special Android support and just build static linux binaries. For context see: https://groups.google.com/forum/#!msg/syzkaller/etg1ZJmTMzg/NYE-yjxxAQAJ https://groups.google.com/d/msg/syzkaller/8KjCYWslTFY/1oTXn5tTAgAJ Fixes #478
This commit is contained in:
parent
2d836b1d35
commit
90a46995a8
51
Makefile
51
Makefile
@ -17,9 +17,9 @@
|
||||
# To test x86 compat syscalls, run:
|
||||
# make TARGETVMARCH=amd64 TARGETARCH=386
|
||||
#
|
||||
# There is a special case for Android builds:
|
||||
# NDK=/path/to/android/ndk make TARGETOS=android TARGETARCH=arm64
|
||||
# But you still need to specify "target": "linux/arm64" in syz-manager config.
|
||||
# There is one special case for extracting constants for Android
|
||||
# (you don't need this unless you update system call descriptions):
|
||||
# make extract TARGETOS=android SOURCEDIR=/path/to/android/checkout
|
||||
|
||||
BUILDOS := $(shell go env GOOS)
|
||||
BUILDARCH := $(shell go env GOARCH)
|
||||
@ -28,7 +28,6 @@ HOSTARCH ?= $(BUILDARCH)
|
||||
TARGETOS ?= $(HOSTOS)
|
||||
TARGETARCH ?= $(HOSTARCH)
|
||||
TARGETVMARCH ?= $(TARGETARCH)
|
||||
EXTRACTOS := $(TARGETOS)
|
||||
GO := go
|
||||
EXE :=
|
||||
|
||||
@ -46,40 +45,6 @@ else ifeq ("$(TARGETARCH)", "ppc64le")
|
||||
CC = "powerpc64le-linux-gnu-gcc"
|
||||
endif
|
||||
|
||||
ifeq ("$(TARGETOS)", "android")
|
||||
EXTRACTOS = android
|
||||
override TARGETOS = linux
|
||||
ANDROID_API = 24
|
||||
BUILDGCCARCH = ""
|
||||
ANDROIDARCH = ""
|
||||
TOOLCHAIN = ""
|
||||
GCCBIN = ""
|
||||
ifeq ("$(TARGETARCH)", "amd64")
|
||||
ANDROIDARCH = "x86_64"
|
||||
TOOLCHAIN = "x86_64-4.9"
|
||||
GCCBIN = "x86_64-linux-android-g++"
|
||||
else ifeq ("$(TARGETARCH)", "386")
|
||||
ANDROIDARCH = "x86"
|
||||
TOOLCHAIN = "x86-4.9"
|
||||
GCCBIN = "i686-linux-android-g++"
|
||||
else ifeq ("$(TARGETARCH)", "arm64")
|
||||
ANDROIDARCH = "arm64"
|
||||
TOOLCHAIN = "aarch64-linux-android-4.9"
|
||||
GCCBIN = "aarch64-linux-android-g++"
|
||||
else ifeq ("$(TARGETARCH)", "arm")
|
||||
ANDROIDARCH = "arm"
|
||||
TOOLCHAIN = "arm-linux-androideabi-4.9"
|
||||
GCCBIN = "arm-linux-androideabi-g++"
|
||||
endif
|
||||
ifeq ("$(BUILDARCH)", "amd64")
|
||||
BUILDGCCARCH = "x86_64"
|
||||
else ifeq ("$(BUILDARCH)", "arm64")
|
||||
BUILDGCCARCH = "aarch64"
|
||||
endif
|
||||
CC = $(NDK)/toolchains/$(TOOLCHAIN)/prebuilt/$(BUILDOS)-$(BUILDGCCARCH)/bin/$(GCCBIN)
|
||||
CFLAGS = -I $(NDK)/sources/cxx-stl/llvm-libc++/include --sysroot=$(NDK)/platforms/android-$(ANDROID_API)/arch-$(ANDROIDARCH) -static
|
||||
endif
|
||||
|
||||
ifeq ("$(TARGETOS)", "fuchsia")
|
||||
# SOURCEDIR should point to fuchsia checkout.
|
||||
GO = $(SOURCEDIR)/buildtools/go
|
||||
@ -122,6 +87,9 @@ endif
|
||||
# That's only needed if you use gdb or nm.
|
||||
# If you need that, build manually without these flags.
|
||||
GOFLAGS := "-ldflags=-s -w -X github.com/google/syzkaller/sys.GitRevision=$(REV)"
|
||||
# Build all Go binaries as static. We don't need cgo and it is known to cause
|
||||
# problems at least on Android emulator.
|
||||
export CGO_ENABLED=0
|
||||
ifneq ("$(GOTAGS)", "")
|
||||
GOFLAGS += "-tags=$(GOTAGS)"
|
||||
endif
|
||||
@ -188,7 +156,7 @@ 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=$(EXTRACTOS) -sourcedir=$(SOURCEDIR)
|
||||
bin/syz-extract -build -os=$(TARGETOS) -sourcedir=$(SOURCEDIR)
|
||||
bin/syz-extract:
|
||||
$(GO) build $(GOFLAGS) -o $@ ./sys/syz-extract
|
||||
|
||||
@ -219,8 +187,9 @@ tidy:
|
||||
$(CC) executor/test_executor.cc -c -o /dev/null -Wparentheses -Wno-unused -Wall
|
||||
|
||||
test:
|
||||
$(GO) test -short ./...
|
||||
$(GO) test -short -race -bench=.* ./...
|
||||
# Executor tests use cgo.
|
||||
env CGO_ENABLED=1 $(GO) test -short ./...
|
||||
env CGO_ENABLED=1 $(GO) test -short -race -bench=.* ./...
|
||||
|
||||
arch:
|
||||
env GOOG=darwin GOARCH=amd64 go install github.com/google/syzkaller/syz-manager
|
||||
|
@ -2,14 +2,12 @@
|
||||
|
||||
Prerequisites:
|
||||
- go1.8+ toolchain (can be downloaded from [here](https://golang.org/dl/))
|
||||
- Android NDK (tested with r15 on API24) (can be downloaded from [here](https://developer.android.com/ndk/downloads/index.html))
|
||||
+ Set the `$NDK` environment variable to point at it
|
||||
- Android Serial Cable or [Suzy-Q](https://chromium.googlesource.com/chromiumos/platform/ec/+/master/docs/case_closed_debugging.md) device to capture console output is preferable but optional. syzkaller can work with normal USB cable as well, but that can be somewhat unreliable and turn lots of crashes into "lost connection to test machine" crashes with no additional info.
|
||||
|
||||
- Build syzkaller
|
||||
|
||||
```sh
|
||||
$ NDK=/path/to/android/ndk make TARGETOS=android TARGETARCH=arm64
|
||||
$ make TARGETOS=linux TARGETARCH=arm64
|
||||
```
|
||||
|
||||
- Create config with `"type": "adb"` and specify adb devices to use. For example:
|
||||
|
@ -21,7 +21,6 @@ Install Go as follows:
|
||||
``` bash
|
||||
wget https://storage.googleapis.com/golang/go1.9.2.linux-amd64.tar.gz
|
||||
tar -xf go1.9.2.linux-amd64.tar.gz
|
||||
mv go goroot
|
||||
export PATH=`pwd`/go/bin:$PATH
|
||||
mkdir gopath
|
||||
export GOPATH=`pwd`/gopath
|
||||
@ -31,7 +30,7 @@ export GOPATH=`pwd`/gopath
|
||||
|
||||
### Initialize a working directory and set up environment variables
|
||||
|
||||
Create a working directory. Also make sure GOROOT, GOPATH, and optionally NDKARM are defined and exported as instructed earlier.
|
||||
Create a working directory. Also make sure GOROOT, GOPATH are defined and exported as instructed earlier.
|
||||
|
||||
``` bash
|
||||
go get -u -d github.com/google/syzkaller/...
|
||||
@ -45,10 +44,6 @@ Run make.
|
||||
```
|
||||
make TARGETOS=linux TARGETARCH=arm
|
||||
```
|
||||
As an alternative, is possible to use the Android NDK toolchain to build syz-executor.
|
||||
To do that, one way is to create an Android.mk file and and Application.mk file
|
||||
and to use the Android NDK's ndk-build program to build syz-executor from executor/executor_linux.cc. The clang cross-compiler, which is
|
||||
part of the Android NDK, is going to be needed for a successful build.
|
||||
|
||||
### Create a manager configuration file
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user