From b9e5d234d9551dfb85f1c2c6f400b6ae93ddb559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Sun, 5 Oct 2025 23:55:37 +0900 Subject: [PATCH] gnu: Add qemu-for-aflplusplus. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * gnu/packages/debug.scm (qemu-for-aflplusplus): New variable. Change-Id: Iecb693c5f4544ac511387a59819ecab422c62949 Signed-off-by: 宋文武 --- gnu/packages/debug.scm | 77 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/gnu/packages/debug.scm b/gnu/packages/debug.scm index f36fb9d2eb07dfc535daeac9b6575d6c66d32a77..6869436deb3baf3b901ea22c438e09f422ac59d5 100644 --- a/gnu/packages/debug.scm +++ b/gnu/packages/debug.scm @@ -529,6 +529,83 @@ server and embedded PowerPC, and S390 guests.") ;; Several tests fail on MIPS. (supported-systems (delete "mips64el-linux" %supported-systems)))))) +(define-public qemu-for-aflplusplus + (let ((base qemu-minimal) + (commit "790d2124fd054621d3c0d3ec31bea114b60601f9") + (revision "0")) + (hidden-package + (package + (inherit base) + (name "qemu") + (version (git-version "5.2.50" revision commit)) + (source + (origin + (method git-fetch) + (uri (git-reference (url "https://github.com/AFLplusplus/qemuafl") + (commit commit) + (recursive? #t))) + (file-name (git-file-name name version)) + (sha256 + (base32 "1l2kl8768l4mbkiaj63zn6gsdn3qpl3rg7s6h62rmd7599ar3xn3")))) + (arguments + (substitute-keyword-arguments (package-arguments base) + ((#:configure-flags _ #~'()) + #~(list (string-append + "--target-list=" + ;; AFL++ only supports using a single afl-qemu-trace, + ;; so we only build qemu for the native target. + (match #$(let-system system system) + ("aarch64-linux" "aarch64-linux-user") + ("armhf-linux" "arm-linux-user") + ("i686-linux" "i386-linux-user") + ("mips64el-linux" "mips64el-linux-user") + ("powerpc-linux" "ppc-linux-user") + ("riscv64-linux" "riscv64-linux-user") + ("x86_64-linux" "x86_64-linux-user"))))) + ((#:phases phases) + #~(modify-phases #$phases + (delete 'replace-firmwares) + (delete 'patch-embedded-shebangs) + (delete 'fix-optionrom-makefile) + (delete 'disable-unusable-tests) + (replace 'configure + (lambda* (#:key configure-flags #:allow-other-keys) + ;; The `configure' script doesn't understand some of the + ;; GNU options. Thus, add a new phase that's compatible. + (setenv "SHELL" (which "bash")) + ;; The binaries need to be linked against -lrt. + (setenv "LDFLAGS" "-lrt") + (apply invoke + "./configure" + (string-append "--cc=" #$(cc-for-target)) + ;; Some architectures insist on using HOST_CC + (string-append "--host-cc=" #$(cc-for-target)) + "--disable-debug-info" ; save build space + (string-append "--prefix=" #$output) + (string-append "--sysconfdir=/etc") + configure-flags))) + (add-after 'install 'install-qasan-header + (lambda _ + (install-file "qemuafl/qasan.h" + (string-append #$output "/include")))) + (delete 'delete-firmwares) + #$@(if (target-riscv64?) + '((replace 'disable-some-tests + (lambda _ + ;; qemu.qmp.QMPConnectError: + ;; Unexpected empty reply from server + (delete-file "tests/qemu-iotests/040") + (delete-file "tests/qemu-iotests/041") + (delete-file "tests/qemu-iotests/256") + ;; No 'PCI' bus found for device 'virtio-scsi-pci' + (delete-file "tests/qemu-iotests/127") + (delete-file "tests/qemu-iotests/267")))) + '()))))) + (inputs (modify-inputs (package-inputs base) + (delete "dtc"))) + (home-page "https://github.com/AFLplusplus/qemuafl") + (synopsis "QEMU for AFL++"))))) + (define-public aflplusplus (package (inherit american-fuzzy-lop)