2019-01-12 14:10:39 +00:00
|
|
|
{ stdenv, fetchurl, afl, python2, zlib, pkgconfig, glib, perl
|
|
|
|
, texinfo, libuuid, flex, bison, pixman, autoconf
|
2015-03-23 02:57:55 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let
|
2018-12-02 16:26:31 +00:00
|
|
|
qemuName = "qemu-2.10.0";
|
2018-08-20 20:11:29 +01: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
|
2019-08-13 22:52:01 +01:00
|
|
|
stdenv.mkDerivation {
|
2018-12-02 16:26:31 +00:00
|
|
|
name = "afl-${qemuName}";
|
2015-03-23 02:57:55 +00:00
|
|
|
|
2018-12-02 16:26:31 +00:00
|
|
|
srcs = [
|
|
|
|
(fetchurl {
|
|
|
|
url = "http://wiki.qemu.org/download/${qemuName}.tar.bz2";
|
|
|
|
sha256 = "0j3dfxzrzdp1w21k21fjvmakzc6lcha1rsclaicwqvbf63hkk7vy";
|
|
|
|
})
|
|
|
|
afl.src
|
|
|
|
];
|
|
|
|
|
|
|
|
sourceRoot = qemuName;
|
|
|
|
|
|
|
|
postUnpack = ''
|
2019-12-21 13:50:23 +00:00
|
|
|
cp ${afl.src.name}/types.h $sourceRoot/afl-types.h
|
|
|
|
substitute ${afl.src.name}/config.h $sourceRoot/afl-config.h \
|
2018-12-02 16:26:31 +00:00
|
|
|
--replace "types.h" "afl-types.h"
|
2019-12-21 13:50:23 +00:00
|
|
|
substitute ${afl.src.name}/qemu_mode/patches/afl-qemu-cpu-inl.h $sourceRoot/afl-qemu-cpu-inl.h \
|
2018-12-02 16:26:31 +00:00
|
|
|
--replace "../../config.h" "afl-config.h"
|
2019-12-21 13:50:23 +00:00
|
|
|
substituteInPlace ${afl.src.name}/qemu_mode/patches/cpu-exec.diff \
|
2018-12-02 16:26:31 +00:00
|
|
|
--replace "../patches/afl-qemu-cpu-inl.h" "afl-qemu-cpu-inl.h"
|
|
|
|
'';
|
2015-03-23 02:57:55 +00:00
|
|
|
|
2019-01-05 16:01:50 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
python2 perl pkgconfig flex bison autoconf texinfo
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
2019-01-12 14:10:39 +00:00
|
|
|
zlib glib pixman libuuid
|
|
|
|
];
|
2015-03-23 02:57:55 +00:00
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
2018-12-02 16:26:31 +00:00
|
|
|
patches = [
|
|
|
|
# patches extracted from afl source
|
2019-12-21 13:50:23 +00:00
|
|
|
"../${afl.src.name}/qemu_mode/patches/cpu-exec.diff"
|
|
|
|
"../${afl.src.name}/qemu_mode/patches/elfload.diff"
|
|
|
|
"../${afl.src.name}/qemu_mode/patches/syscall.diff"
|
|
|
|
"../${afl.src.name}/qemu_mode/patches/configure.diff"
|
|
|
|
"../${afl.src.name}/qemu_mode/patches/memfd.diff"
|
2018-12-02 16:26:31 +00:00
|
|
|
# nix-specific patches to make installation more well-behaved
|
|
|
|
./qemu-patches/no-etc-install.patch
|
2020-03-13 08:23:01 +00:00
|
|
|
# patch for fixing qemu build on glibc >= 2.30
|
|
|
|
./qemu-patches/syscall-glibc2_30.diff
|
2018-12-02 16:26:31 +00:00
|
|
|
];
|
2015-03-23 02:57:55 +00:00
|
|
|
|
|
|
|
configureFlags =
|
|
|
|
[ "--disable-system"
|
|
|
|
"--enable-linux-user"
|
|
|
|
"--disable-gtk"
|
|
|
|
"--disable-sdl"
|
|
|
|
"--disable-vnc"
|
2019-01-12 14:10:39 +00:00
|
|
|
"--disable-kvm"
|
2015-03-23 02:57:55 +00:00
|
|
|
"--target-list=${cpuTarget}"
|
2018-12-02 16:26:31 +00:00
|
|
|
"--enable-pie"
|
2015-03-23 02:57:55 +00:00
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--localstatedir=/var"
|
|
|
|
];
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "http://www.qemu.org/";
|
2015-04-11 12:43:25 +01: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;
|
|
|
|
};
|
|
|
|
}
|