about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2025-04-22 17:20:33 +0900
committerNguyễn Gia Phong <cnx@loang.net>2025-04-22 17:20:33 +0900
commitff736052958e432f945db82441177c04a6a7e1d8 (patch)
tree543b9c13bc25616b49ed555cac09a9f8f7440f86
parent956de57022dadb23722e5d0d010bd8e98897e464 (diff)
downloadloftix-ff736052958e432f945db82441177c04a6a7e1d8.tar.gz
Add build modifier for Evocatio targets
-rw-r--r--loftix/fuzzing.scm28
1 files changed, 26 insertions, 2 deletions
diff --git a/loftix/fuzzing.scm b/loftix/fuzzing.scm
index 6ec3a35..ad8d587 100644
--- a/loftix/fuzzing.scm
+++ b/loftix/fuzzing.scm
@@ -1,6 +1,6 @@
 ;;; Packages for software fuzzing
 ;;;
-;;; SPDX-FileCopyrightText: 2024 Nguyễn Gia Phong
+;;; SPDX-FileCopyrightText: 2024-2025 Nguyễn Gia Phong
 ;;; SPDX-License-Identifier: GPL-3.0-or-later
 
 (define-module (loftix fuzzing)
@@ -16,7 +16,8 @@
   #:use-module (guix git-download)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
-  #:use-module (guix utils))
+  #:use-module (guix utils)
+  #:export (for-evocatio))
 
 (define-public afl-dyninst
   (package
@@ -123,3 +124,26 @@ of how an attacker can exploit a bug.
 Evocatio leverages a capability-guided fuzzer to efficiently uncover
 new bug capabilities (rather than only generating a single crashing test case
 for a given bug, as a traditional greybox fuzzer does)."))))
+
+(define (for-evocatio base)
+  (package
+    (inherit base)
+    (name (string-append (package-name base) "-for-evocatio"))
+    (arguments
+     (substitute-keyword-arguments (package-arguments base)
+       ((#:configure-flags flags #~'())
+        #~(cons (string-append "CC=" #$evocatio "/bin/afl-cc")
+                #$flags))
+       ((#:phases phases #~%standard-phases)
+        #~(modify-phases #$phases
+            (add-before 'configure 'set-env
+              (lambda _
+                (setenv "CC" #$(file-append evocatio "/bin/afl-cc"))
+                (setenv "AFL_USE_ASAN" "1")
+                (setenv "AFL_USE_UBSAN" "1")
+                (setenv "ASAN_OPTIONS" "detect_leaks=0")))))
+       ((#:tests? _ #f)
+        #f)))
+    (native-inputs
+      (modify-inputs (package-native-inputs base)
+        (append evocatio)))))