2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchurl, afl, python2, zlib, pkg-config, glib, perl
|
2020-04-24 23:36:52 +00:00
|
|
|
, texinfo, libuuid, flex, bison, pixman, autoconf
|
|
|
|
}:
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
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}!";
|
|
|
|
in
|
2021-12-06 16:07:01 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "afl-qemu";
|
|
|
|
version = "2.10.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
srcs = [
|
|
|
|
(fetchurl {
|
2021-12-06 16:07:01 +00:00
|
|
|
url = "http://wiki.qemu.org/download/qemu-${version}.tar.bz2";
|
2020-04-24 23:36:52 +00:00
|
|
|
sha256 = "0j3dfxzrzdp1w21k21fjvmakzc6lcha1rsclaicwqvbf63hkk7vy";
|
|
|
|
})
|
|
|
|
afl.src
|
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
sourceRoot = "qemu-${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postUnpack = ''
|
|
|
|
cp ${afl.src.name}/types.h $sourceRoot/afl-types.h
|
|
|
|
substitute ${afl.src.name}/config.h $sourceRoot/afl-config.h \
|
|
|
|
--replace "types.h" "afl-types.h"
|
|
|
|
substitute ${afl.src.name}/qemu_mode/patches/afl-qemu-cpu-inl.h $sourceRoot/afl-qemu-cpu-inl.h \
|
|
|
|
--replace "../../config.h" "afl-config.h"
|
|
|
|
substituteInPlace ${afl.src.name}/qemu_mode/patches/cpu-exec.diff \
|
|
|
|
--replace "../patches/afl-qemu-cpu-inl.h" "afl-qemu-cpu-inl.h"
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2021-02-05 17:12:51 +00:00
|
|
|
python2 perl pkg-config flex bison autoconf texinfo
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
zlib glib pixman libuuid
|
|
|
|
];
|
|
|
|
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# patches extracted from afl source
|
|
|
|
"../${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"
|
|
|
|
# nix-specific patches to make installation more well-behaved
|
|
|
|
./qemu-patches/no-etc-install.patch
|
|
|
|
# patch for fixing qemu build on glibc >= 2.30
|
|
|
|
./qemu-patches/syscall-glibc2_30.diff
|
|
|
|
];
|
|
|
|
|
|
|
|
configureFlags =
|
|
|
|
[ "--disable-system"
|
|
|
|
"--enable-linux-user"
|
|
|
|
"--disable-gtk"
|
|
|
|
"--disable-sdl"
|
|
|
|
"--disable-vnc"
|
|
|
|
"--disable-kvm"
|
|
|
|
"--target-list=${cpuTarget}"
|
|
|
|
"--enable-pie"
|
|
|
|
"--sysconfdir=/etc"
|
|
|
|
"--localstatedir=/var"
|
|
|
|
];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://www.qemu.org/";
|
|
|
|
description = "Fork of QEMU with AFL instrumentation support";
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
|
|
|
platforms = platforms.linux;
|
|
|
|
};
|
|
|
|
}
|