python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / security / afl / qemu.nix
blobe33c4c2fb03a84697fbaecfa50e54b3381fca171
1 { lib, stdenv, fetchurl, afl, python2, zlib, pkg-config, glib, perl
2 , texinfo, libuuid, flex, bison, pixman, autoconf
3 }:
5 with lib;
7 let
8   cpuTarget = if stdenv.hostPlatform.system == "x86_64-linux" then "x86_64-linux-user"
9     else if stdenv.hostPlatform.system == "i686-linux" then "i386-linux-user"
10     else throw "afl: no support for ${stdenv.hostPlatform.system}!";
12 stdenv.mkDerivation rec {
13   pname = "afl-qemu";
14   version = "2.10.0";
16   srcs = [
17     (fetchurl {
18       url = "http://wiki.qemu.org/download/qemu-${version}.tar.bz2";
19       sha256 = "0j3dfxzrzdp1w21k21fjvmakzc6lcha1rsclaicwqvbf63hkk7vy";
20     })
21     afl.src
22   ];
24   sourceRoot = "qemu-${version}";
26   postUnpack = ''
27     cp ${afl.src.name}/types.h $sourceRoot/afl-types.h
28     substitute ${afl.src.name}/config.h $sourceRoot/afl-config.h \
29       --replace "types.h" "afl-types.h"
30     substitute ${afl.src.name}/qemu_mode/patches/afl-qemu-cpu-inl.h $sourceRoot/afl-qemu-cpu-inl.h \
31       --replace "../../config.h" "afl-config.h"
32     substituteInPlace ${afl.src.name}/qemu_mode/patches/cpu-exec.diff \
33       --replace "../patches/afl-qemu-cpu-inl.h" "afl-qemu-cpu-inl.h"
34   '';
36   nativeBuildInputs = [
37     python2 perl pkg-config flex bison autoconf texinfo
38   ];
40   buildInputs = [
41     zlib glib pixman libuuid
42   ];
44   enableParallelBuilding = true;
46   patches = [
47     # patches extracted from afl source
48     "../${afl.src.name}/qemu_mode/patches/cpu-exec.diff"
49     "../${afl.src.name}/qemu_mode/patches/elfload.diff"
50     "../${afl.src.name}/qemu_mode/patches/syscall.diff"
51     "../${afl.src.name}/qemu_mode/patches/configure.diff"
52     "../${afl.src.name}/qemu_mode/patches/memfd.diff"
53     # nix-specific patches to make installation more well-behaved
54     ./qemu-patches/no-etc-install.patch
55     # patch for fixing qemu build on glibc >= 2.30
56     ./qemu-patches/syscall-glibc2_30.diff
57   ];
59   configureFlags =
60     [ "--disable-system"
61       "--enable-linux-user"
62       "--disable-gtk"
63       "--disable-sdl"
64       "--disable-vnc"
65       "--disable-kvm"
66       "--target-list=${cpuTarget}"
67       "--enable-pie"
68       "--sysconfdir=/etc"
69       "--localstatedir=/var"
70     ];
72   meta = with lib; {
73     homepage = "http://www.qemu.org/";
74     description = "Fork of QEMU with AFL instrumentation support";
75     license = licenses.gpl2Plus;
76     maintainers = with maintainers; [ thoughtpolice ];
77     platforms = platforms.linux;
78   };