New comment by Duncaen on void-packages repository https://github.com/void-linux/void-packages/pull/44998#issuecomment-1637113701 Comment: Here is the template I've had lying around, don't remember how finished it is, but I have x86_64-glibc version installed and used it a bit. ```diff From 14518faadde08701569ed29142420bb6758ceb58 Mon Sep 17 00:00:00 2001 From: Duncaen Date: Sun, 16 Jul 2023 16:55:27 +0200 Subject: [PATCH] New package: afl++-4.06c --- .../0001-fix-missing-max-path-define.patch | 20 +++++++ .../0003-fix-wrong-format-specifier.patch | 15 +++++ srcpkgs/afl++/template | 58 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 srcpkgs/afl++/patches/0001-fix-missing-max-path-define.patch create mode 100644 srcpkgs/afl++/patches/0003-fix-wrong-format-specifier.patch create mode 100644 srcpkgs/afl++/template diff --git a/srcpkgs/afl++/patches/0001-fix-missing-max-path-define.patch b/srcpkgs/afl++/patches/0001-fix-missing-max-path-define.patch new file mode 100644 index 0000000000..8711c06961 --- /dev/null +++ b/srcpkgs/afl++/patches/0001-fix-missing-max-path-define.patch @@ -0,0 +1,20 @@ +Source: https://git.alpinelinux.org/aports/tree/community/afl++/0001-fix-missing-max-path-define.patch +Fix for: + + src/afl-ld-lto.c:260:15: error: use of undeclared identifier 'PATH_MAX' + char thecwd[PATH_MAX]; + +--- AFLplusplus-4.00c/src/afl-ld-lto.c ++++ AFLplusplus-4.00c/src/afl-ld-lto.c +@@ -45,10 +45,7 @@ + + #include + +-#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || \ +- defined(__DragonFly__) +- #include +-#endif ++#include + + #ifdef __APPLE__ + #include diff --git a/srcpkgs/afl++/patches/0003-fix-wrong-format-specifier.patch b/srcpkgs/afl++/patches/0003-fix-wrong-format-specifier.patch new file mode 100644 index 0000000000..49622819a7 --- /dev/null +++ b/srcpkgs/afl++/patches/0003-fix-wrong-format-specifier.patch @@ -0,0 +1,15 @@ +Source: https://git.alpinelinux.org/aports/tree/community/afl++/0003-fix-wrong-format-specifier.patch +The format specifier for size_t is %zu and not %lu. Fixing this to +prevent issues on 32 bit machines. + +--- AFLplusplus-4.00c/instrumentation/SanitizerCoverageLTO.so.cc ++++ AFLplusplus-4.00c/instrumentation/SanitizerCoverageLTO.so.cc +@@ -1080,7 +1080,7 @@ + } + + if (!be_quiet) +- printf("AUTODICTIONARY: %lu string%s found\n", count, ++ printf("AUTODICTIONARY: %zu string%s found\n", count, + count == 1 ? "" : "s"); + + if (count) { diff --git a/srcpkgs/afl++/template b/srcpkgs/afl++/template new file mode 100644 index 0000000000..c16d74c6eb --- /dev/null +++ b/srcpkgs/afl++/template @@ -0,0 +1,58 @@ +# Template file for 'afl++' +pkgname=afl++ +version=4.06c +revision=1 +#wrksrc= +#create_wrksrc=yes +#only_for_archs="i686 x86_64" +build_style=gnu-makefile +#configure_args="" +#make_build_args="" +#make_install_args="" +#conf_files="" +#make_dirs="/var/log/dir 0755 root root" +hostmakedepends="clang llvm lld " +makedepends="gmp-devel " +depends="" +short_desc="AFL fork fuzzer relying on genetic algorithms instead of brute force" +maintainer="Duncaen " +license="Apache-2.0" +homepage="https://aflplus.plus/" +distfiles="https://github.com/AFLplusplus/AFLplusplus/archive/refs/tags/${version}.tar.gz" +checksum=98ef9d9a1eee10b1642067700a3ea2ff87ee7aa6ca4a15cb924053c41d119423 + +ignore_elf_dirs="/usr/share/afl/testcases/others/elf" +nostrip_files="small_archive.a small_exec.elf" +conflicts="afl>=0" + +post_patch() { + vsed -e 's/install: all/install:/' -i GNUmakefile + vsed -e '/-f GNUmakefile.llvm$/d' -i GNUmakefile +} + +do_build() { + case "${XBPS_TARGET_MACHINE}" in + x86_64*|i686*) ;; + *) export AFL_NO_X86=1 ;; + esac + if [[ -v CROSS_BUILD ]]; then + CLANG_TARGET="-target=${XBPS_CROSS_TRIPLET}" + fi + echo $LDFLAGS + export CFLAGS="${CFLAGS//-fstack-clash-protection}" + export CFLAGS="${CFLAGS//-D_FORTIFY_SOURCE=2}" + export CXXFLAGS="${CXXFLAGS//-fstack-clash-protection}" + export CXXFLAGS="${CXXFLAGS//-D_FORTIFY_SOURCE=2}" + make PREFIX=/usr CLANG_BIN="$CLANG_BIN" CLANGPP_BIN="$CLANGPP_BIN" all + make -f GNUmakefile.llvm PREFIX=/usr CFLAGS="${CLANG_TARGET} ${CFLAGS}" CXXFLAGS="${CLANG_TARGET} ${CXXFLAGS}" +} + +pre_install() { + export AFL_NO_X86=1 +} + +post_install() { + # Test cases contain binary .../testcases/others/elf/small_exec.elf + # so move them to /usr/lib/afl + mv ${DESTDIR}/usr/{share,lib}/afl/testcases +} -- 2.41.0 ```