From 0d0fbbe73f5b02bfeac0aedd0b6b9e8417ab0b0f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 26 Aug 2016 07:09:25 +0200 Subject: overhaul syscall description generation process This splits generation process into two phases: 1. Extract values of constants from linux kernel sources. 2. Generate Go code. Constant values are checked in. The advantage is that the second phase is now completely independent from linux source files, kernel version, presence of headers for particular drivers, etc. This allows to change what Go code we generate any time without access to all kernel headers (which in future won't be limited to only upstream headers). Constant extraction process does require proper kernel sources, but this can be done only once by the person who added the driver and has access to the required sources. Then the constant values are checked in for others to use. Consant extraction process is per-file/per-arch. That is, if I am adding a driver that is not present upstream and that works only on a single arch, I will check in constants only for that driver and for that arch. --- extract.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 extract.sh (limited to 'extract.sh') diff --git a/extract.sh b/extract.sh new file mode 100755 index 000000000..405711016 --- /dev/null +++ b/extract.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Copyright 2015 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. + +if [ "$LINUX" == "" ]; then + echo "usage: make extract LINUX=/linux/checkout]" + exit 1 +fi + +FILES="sys/sys.txt sys/socket.txt sys/tty.txt sys/perf.txt sys/kvm.txt \ + sys/key.txt sys/bpf.txt sys/fuse.txt sys/dri.txt sys/kdbus.txt sys/sctp.txt \ + sys/sndseq.txt sys/sndtimer.txt sys/sndcontrol.txt sys/input.txt \ + sys/netlink.txt sys/tun.txt sys/random.txt sys/kcm.txt sys/netrom.txt" + +generate_arch() { + echo generating arch $1... + echo "cd $LINUX; make defconfig" + OUT=`(cd $LINUX; make ARCH=$2 CROSS_COMPILE=/usr/bin/$3-linux-gnu- defconfig 2>&1)` + if [ $? -ne 0 ]; then + echo "$OUT" + exit 1 + fi + echo "cd $LINUX; make" + OUT=`(cd $LINUX; make ARCH=$2 CROSS_COMPILE=/usr/bin/$3-linux-gnu- init/main.o 2>&1)` + if [ $? -ne 0 ]; then + echo "$OUT" + exit 1 + fi + for F in $FILES; do + echo "extracting from $F" + bin/syz-extract -arch $1 -linux "$LINUX" -linuxbld "$LINUXBLD" $F + if [ $? -ne 0 ]; then + exit 1 + fi + done + echo +} + +generate_arch amd64 x86_64 x86_64 +generate_arch arm64 arm64 aarch64 +generate_arch ppc64le powerpc powerpc64le -- cgit mrf-deployment