2016-11-19 09:16:16 +00:00
|
|
|
{ stdenv, fetchurl, python2, zlib, pkgconfig, glib, ncurses, perl
|
2018-07-21 00:44:44 +00:00
|
|
|
, attr, libcap, vde2, texinfo, libuuid, flex, bison, lzo, snappy
|
2015-03-23 02:57:55 +00:00
|
|
|
, libaio, libcap_ng, gnutls, pixman, autoconf
|
|
|
|
, writeText
|
|
|
|
}:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
2015-05-13 11:52:56 +00:00
|
|
|
n = "qemu-2.3.0";
|
2015-03-23 02:57:55 +00:00
|
|
|
|
|
|
|
aflHeaderFile = writeText "afl-qemu-cpu-inl.h"
|
|
|
|
(builtins.readFile ./qemu-patches/afl-qemu-cpu-inl.h);
|
|
|
|
aflConfigFile = writeText "afl-config.h"
|
|
|
|
(builtins.readFile ./qemu-patches/afl-config.h);
|
|
|
|
aflTypesFile = writeText "afl-types.h"
|
|
|
|
(builtins.readFile ./qemu-patches/afl-types.h);
|
|
|
|
|
2018-08-20 19:11:29 +00:00
|
|
|
cpuTarget = if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64-linux-user"
|
|
|
|
else if stdenv.hostPlatform.system == "i686-linux" then "i386-linux-user"
|
|
|
|
else throw "afl: no support for ${stdenv.hostPlatform.system}!";
|
2015-03-23 02:57:55 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "afl-${n}";
|
|
|
|
|
|
|
|
src = fetchurl {
|
|
|
|
url = "http://wiki.qemu.org/download/${n}.tar.bz2";
|
2015-05-13 11:52:56 +00:00
|
|
|
sha256 = "120m53c3p28qxmfzllicjzr8syjv6v4d9rsyrgkp7gnmcgvvgfmn";
|
2015-03-23 02:57:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs =
|
2016-11-19 09:16:16 +00:00
|
|
|
[ python2 zlib pkgconfig glib pixman ncurses perl attr libcap
|
2015-03-23 02:57:55 +00:00
|
|
|
vde2 texinfo libuuid flex bison lzo snappy autoconf
|
|
|
|
libcap_ng gnutls
|
|
|
|
]
|
2018-08-20 19:11:29 +00:00
|
|
|
++ optionals (hasSuffix "linux" stdenv.hostPlatform.system) [ libaio ];
|
2015-03-23 02:57:55 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
patches =
|
|
|
|
[ ./qemu-patches/elfload.patch
|
|
|
|
./qemu-patches/cpu-exec.patch
|
|
|
|
./qemu-patches/no-etc-install.patch
|
|
|
|
./qemu-patches/translate-all.patch
|
2015-03-28 06:51:00 +00:00
|
|
|
./qemu-patches/syscall.patch
|
2017-11-16 17:11:10 +00:00
|
|
|
./qemu-patches/qemu-2.3.0-glibc-2.26.patch
|
2015-03-23 02:57:55 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
cp ${aflTypesFile} afl-types.h
|
|
|
|
cp ${aflConfigFile} afl-config.h
|
|
|
|
cp ${aflHeaderFile} afl-qemu-cpu-inl.h
|
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags =
|
|
|
|
[ "--disable-system"
|
|
|
|
"--enable-linux-user"
|
|
|
|
"--enable-guest-base"
|
|
|
|
"--disable-gtk"
|
|
|
|
"--disable-sdl"
|
|
|
|
"--disable-vnc"
|
|
|
|
"--target-list=${cpuTarget}"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--localstatedir=/var"
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
homepage = http://www.qemu.org/;
|
2015-04-11 11:43:25 +00:00
|
|
|
description = "Fork of QEMU with AFL instrumentation support";
|
2015-03-23 02:57:55 +00:00
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|