Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 1 | DESCRIPTION = "syzkaller is an unsupervised coverage-guided kernel fuzzer" |
| 2 | LICENSE = "Apache-2.0" |
| 3 | LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=5335066555b14d832335aa4660d6c376" |
| 4 | |
| 5 | inherit go-mod |
| 6 | |
| 7 | GO_IMPORT = "github.com/google/syzkaller" |
| 8 | |
| 9 | SRC_URI = "git://${GO_IMPORT};protocol=https;destsuffix=${BPN}-${PV}/src/${GO_IMPORT};branch=master \ |
| 10 | file://0001-sys-targets-targets.go-allow-users-to-override-hardc.patch;patchdir=src/${GO_IMPORT} \ |
| 11 | " |
| 12 | SRCREV = "67cb024cd1a3c95e311263a5c95e957f9abfd8ca" |
| 13 | |
| 14 | COMPATIBLE_HOST = "(x86_64|i.86|arm|aarch64).*-linux" |
| 15 | |
| 16 | B = "${S}/src/${GO_IMPORT}/bin" |
| 17 | |
| 18 | GO_EXTRA_LDFLAGS += ' -X ${GO_IMPORT}/prog.GitRevision=${SRCREV}' |
| 19 | |
| 20 | export GOHOSTFLAGS="${GO_LINKSHARED} ${GOBUILDFLAGS}" |
| 21 | export GOTARGETFLAGS="${GO_LINKSHARED} ${GOBUILDFLAGS}" |
| 22 | export TARGETOS = '${GOOS}' |
| 23 | export TARGETARCH = '${GOARCH}' |
| 24 | export TARGETVMARCH = '${GOARCH}' |
| 25 | |
| 26 | CGO_ENABLED = "0" |
| 27 | |
| 28 | DEPENDS:class-native += "qemu-system-native" |
| 29 | |
| 30 | do_compile:class-native() { |
| 31 | export HOSTOS="${GOHOSTOS}" |
| 32 | export HOSTARCH="${GOHOSTARCH}" |
| 33 | |
| 34 | oe_runmake HOSTGO="${GO}" host |
| 35 | } |
| 36 | |
| 37 | do_compile:class-target() { |
| 38 | export HOSTOS="${GOOS}" |
| 39 | export HOSTARCH="${GOARCH}" |
| 40 | export SYZ_CC_${TARGETOS}_${TARGETARCH}="${CC}" |
| 41 | |
| 42 | # Unset GOOS and GOARCH so that the correct syz-sysgen binary can be |
| 43 | # generated. Fixes: |
| 44 | # go install: cannot install cross-compiled binaries when GOBIN is set |
| 45 | unset GOOS |
| 46 | unset GOARCH |
| 47 | |
| 48 | oe_runmake GO="${GO}" CC="${CXX}" CFLAGS="${CXXFLAGS} ${LDFLAGS}" REV=${SRCREV} target |
| 49 | } |
| 50 | |
| 51 | do_install:class-native() { |
| 52 | SYZ_BINS_NATIVE="syz-manager syz-runtest syz-repro syz-mutate syz-prog2c \ |
| 53 | syz-db syz-upgrade" |
| 54 | |
| 55 | install -d ${D}${bindir} |
| 56 | |
| 57 | for i in ${SYZ_BINS_NATIVE}; do |
| 58 | install -m 0755 ${B}/${i} ${D}${bindir} |
| 59 | done |
| 60 | } |
| 61 | |
| 62 | do_install:class-target() { |
| 63 | SYZ_TARGET_DIR="${TARGETOS}_${TARGETARCH}" |
| 64 | SYZ_BINS_TARGET="syz-fuzzer syz-execprog syz-stress syz-executor" |
| 65 | |
| 66 | install -d ${D}${bindir}/${SYZ_TARGET_DIR} |
| 67 | |
| 68 | for i in ${SYZ_BINS_TARGET}; do |
| 69 | install -m 0755 ${B}/${SYZ_TARGET_DIR}/${i} ${D}${bindir}/${SYZ_TARGET_DIR} |
| 70 | done |
| 71 | } |
| 72 | |
| 73 | BBCLASSEXTEND += "native" |