security/afl++: Add option to build GCC plugin and afl-gcc-fast

Unfortunately not enabled by default since lang/gcc* does not enable
plugins support by default yet.

Suggested by:	David Carlier
This commit is contained in:
Tobias Kortkamp 2019-12-01 08:28:53 +00:00
parent e08eaf2990
commit 968290922e
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=518758
2 changed files with 44 additions and 4 deletions

View File

@ -27,14 +27,18 @@ TEST_TARGET= test_build
CONFLICTS_INSTALL= afl CONFLICTS_INSTALL= afl
OPTIONS_DEFINE= DEBUG DOCS LLVM OPTIONS_DEFINE= DEBUG DOCS GCC LLVM
OPTIONS_DEFAULT= LLVM OPTIONS_DEFAULT= LLVM
# On non-x86 architectures LLVM is mandatory # On non-x86 architectures LLVM is mandatory
OPTIONS_SLAVE= ${ARCH:Namd64:Ni386:S/${ARCH}/LLVM/} OPTIONS_SLAVE= ${ARCH:Namd64:Ni386:S/${ARCH}/LLVM/}
OPTIONS_SUB= yes OPTIONS_SUB= yes
GCC_DESC= Build GCC plugin and afl-gcc-fast
LLVM_DESC= LLVM-based instrumentation LLVM_DESC= LLVM-based instrumentation
GCC_BUILD_DEPENDS= gcc${GCC_DEFAULT}:lang/gcc${GCC_DEFAULT}
GCC_RUN_DEPENDS= gcc${GCC_DEFAULT}:lang/gcc${GCC_DEFAULT}
LLVM_BUILD_DEPENDS= clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT} LLVM_BUILD_DEPENDS= clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
LLVM_RUN_DEPENDS= clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT} LLVM_RUN_DEPENDS= clang${LLVM_DEFAULT}:devel/llvm${LLVM_DEFAULT}
LLVM_MAKE_ARGS= LLVM_CONFIG=llvm-config${LLVM_DEFAULT} LLVM_MAKE_ARGS= LLVM_CONFIG=llvm-config${LLVM_DEFAULT}
@ -71,12 +75,22 @@ post-patch:
.endif .endif
@${CAT} ${FILESDIR}/Makefile.extra >> ${WRKSRC}/Makefile @${CAT} ${FILESDIR}/Makefile.extra >> ${WRKSRC}/Makefile
post-patch-GCC-on:
@${REINPLACE_CMD} \
-e 's|"gcc"|"gcc${GCC_DEFAULT}"|g' \
-e 's|"g\+\+"|"g\+\+${GCC_DEFAULT}"|g' \
${WRKSRC}/gcc_plugin/afl-gcc-fast.c
post-patch-LLVM-on: post-patch-LLVM-on:
@${REINPLACE_CMD} \ @${REINPLACE_CMD} \
-e 's|"clang"|"clang${LLVM_DEFAULT}"|g' \ -e 's|"clang"|"clang${LLVM_DEFAULT}"|g' \
-e 's|"clang\+\+"|"clang\+\+${LLVM_DEFAULT}"|g' \ -e 's|"clang\+\+"|"clang\+\+${LLVM_DEFAULT}"|g' \
${WRKSRC}/llvm_mode/afl-clang-fast.c ${WRKSRC}/llvm_mode/afl-clang-fast.c
post-build-GCC-on:
@${DO_MAKE_BUILD} -C ${WRKSRC}/gcc_plugin CC=gcc${GCC_DEFAULT} \
CXX=g++${GCC_DEFAULT}
post-install: post-install:
.for script in afl-cmin afl-plot afl-whatsup .for script in afl-cmin afl-plot afl-whatsup
${INSTALL_SCRIPT} ${WRKSRC}/${script} ${STAGEDIR}${PREFIX}/bin ${INSTALL_SCRIPT} ${WRKSRC}/${script} ${STAGEDIR}${PREFIX}/bin
@ -85,12 +99,26 @@ post-install:
.for prog in afl-analyze afl-fuzz afl-gcc afl-gotcpu afl-showmap afl-tmin .for prog in afl-analyze afl-fuzz afl-gcc afl-gotcpu afl-showmap afl-tmin
@${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/${prog} @${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/${prog}
.endfor .endfor
${INSTALL_LIB} ${WRKSRC}/libdislocator.so \ @${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/afl/*.so
${STAGEDIR}${PREFIX}/lib/afl @${MKDIR} ${STAGEDIR}${DOCSDIR}/libdislocator
${MKDIR} ${STAGEDIR}${DOCSDIR}/libdislocator
${INSTALL_MAN} ${WRKSRC}/libdislocator/README.md \ ${INSTALL_MAN} ${WRKSRC}/libdislocator/README.md \
${STAGEDIR}${DOCSDIR}/libdislocator ${STAGEDIR}${DOCSDIR}/libdislocator
post-install-GCC-on:
${INSTALL_PROGRAM} ${WRKSRC}/afl-g++-fast \
${WRKSRC}/afl-gcc-fast \
${STAGEDIR}${PREFIX}/bin
${INSTALL_MAN} ${WRKSRC}/afl-g++-fast.8 \
${WRKSRC}/afl-gcc-fast.8 \
${STAGEDIR}${PREFIX}/man/man8
${INSTALL_LIB} ${WRKSRC}/afl-gcc-pass.so \
${STAGEDIR}${PREFIX}/lib/afl
${INSTALL_DATA} ${WRKSRC}/afl-gcc-rt.o \
${STAGEDIR}${PREFIX}/lib/afl
@${MKDIR} ${STAGEDIR}${DOCSDIR}/gcc_plugin
${INSTALL_MAN} ${WRKSRC}/gcc_plugin/README.* \
${STAGEDIR}${DOCSDIR}/gcc_plugin
post-install-LLVM-on: post-install-LLVM-on:
@${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/afl/*.so \ @${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/afl/*.so \
${STAGEDIR}${PREFIX}/bin/afl-clang-fast ${STAGEDIR}${PREFIX}/bin/afl-clang-fast
@ -98,4 +126,8 @@ post-install-LLVM-on:
${INSTALL_MAN} ${WRKSRC}/llvm_mode/README.* \ ${INSTALL_MAN} ${WRKSRC}/llvm_mode/README.* \
${STAGEDIR}${DOCSDIR}/llvm_mode ${STAGEDIR}${DOCSDIR}/llvm_mode
post-test-GCC-on:
@${DO_MAKE_BUILD} -C ${WRKSRC}/gcc_plugin CC=gcc${GCC_DEFAULT} \
CXX=g++${GCC_DEFAULT} test_build
.include <bsd.port.mk> .include <bsd.port.mk>

View File

@ -3,6 +3,8 @@ bin/afl-analyze
%%X86%%bin/afl-clang++ %%X86%%bin/afl-clang++
%%LLVM%%bin/afl-clang-fast %%LLVM%%bin/afl-clang-fast
%%LLVM%%bin/afl-clang-fast++ %%LLVM%%bin/afl-clang-fast++
%%GCC%%bin/afl-g++-fast
%%GCC%%bin/afl-gcc-fast
bin/afl-cmin bin/afl-cmin
bin/afl-fuzz bin/afl-fuzz
%%X86%%bin/afl-g++ %%X86%%bin/afl-g++
@ -14,6 +16,8 @@ bin/afl-system-config
bin/afl-tmin bin/afl-tmin
bin/afl-whatsup bin/afl-whatsup
%%X86%%lib/afl/afl-as %%X86%%lib/afl/afl-as
%%GCC%%lib/afl/afl-gcc-pass.so
%%GCC%%lib/afl/afl-gcc-rt.o
%%LLVM%%lib/afl/afl-llvm-pass.so %%LLVM%%lib/afl/afl-llvm-pass.so
%%X86%%%%LLVM%%lib/afl/afl-llvm-rt-32.o %%X86%%%%LLVM%%lib/afl/afl-llvm-rt-32.o
%%LLVM%%lib/afl/afl-llvm-rt-64.o %%LLVM%%lib/afl/afl-llvm-rt-64.o
@ -28,6 +32,8 @@ lib/afl/libdislocator.so
%%LLVM%%man/man8/afl-clang-fast++.8.gz %%LLVM%%man/man8/afl-clang-fast++.8.gz
man/man8/afl-cmin.8.gz man/man8/afl-cmin.8.gz
man/man8/afl-fuzz.8.gz man/man8/afl-fuzz.8.gz
%%GCC%%man/man8/afl-g++-fast.8.gz
%%GCC%%man/man8/afl-gcc-fast.8.gz
man/man8/afl-gcc.8.gz man/man8/afl-gcc.8.gz
man/man8/afl-gotcpu.8.gz man/man8/afl-gotcpu.8.gz
man/man8/afl-plot.8.gz man/man8/afl-plot.8.gz
@ -93,6 +99,8 @@ man/man8/afl-whatsup.8.gz
%%PORTDOCS%%%%DOCSDIR%%/binaryonly_fuzzing.txt %%PORTDOCS%%%%DOCSDIR%%/binaryonly_fuzzing.txt
%%PORTDOCS%%%%DOCSDIR%%/custom_mutator.txt %%PORTDOCS%%%%DOCSDIR%%/custom_mutator.txt
%%PORTDOCS%%%%DOCSDIR%%/env_variables.txt %%PORTDOCS%%%%DOCSDIR%%/env_variables.txt
%%GCC%%%%PORTDOCS%%%%DOCSDIR%%/gcc_plugin/README.gcc.md
%%GCC%%%%PORTDOCS%%%%DOCSDIR%%/gcc_plugin/README.whitelist.md
%%PORTDOCS%%%%DOCSDIR%%/historical_notes.txt %%PORTDOCS%%%%DOCSDIR%%/historical_notes.txt
%%PORTDOCS%%%%DOCSDIR%%/libdislocator/README.md %%PORTDOCS%%%%DOCSDIR%%/libdislocator/README.md
%%PORTDOCS%%%%DOCSDIR%%/life_pro_tips.txt %%PORTDOCS%%%%DOCSDIR%%/life_pro_tips.txt