Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-forensics/aflplusplus/files/, app-forensics/aflplusplus/
Date: Wed, 31 Mar 2021 23:39:03
Message-Id: 1617233923.06382b00ebd78da1c4968fd78a9bafb82aabff3e.sam@gentoo
1 commit: 06382b00ebd78da1c4968fd78a9bafb82aabff3e
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Wed Mar 31 18:32:12 2021 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Mar 31 23:38:43 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=06382b00
7
8 app-forensics/aflplusplus: initial import
9
10 Signed-off-by: Sam James <sam <AT> gentoo.org>
11
12 app-forensics/aflplusplus/Manifest | 1 +
13 app-forensics/aflplusplus/aflplusplus-3.12c.ebuild | 75 ++++++++++++++
14 .../files/aflplusplus-3.0c-CFLAGS.patch | 110 +++++++++++++++++++++
15 .../files/aflplusplus-3.0c-LDFLAGS.patch | 11 +++
16 app-forensics/aflplusplus/metadata.xml | 11 +++
17 5 files changed, 208 insertions(+)
18
19 diff --git a/app-forensics/aflplusplus/Manifest b/app-forensics/aflplusplus/Manifest
20 new file mode 100644
21 index 00000000000..81c2a1618a1
22 --- /dev/null
23 +++ b/app-forensics/aflplusplus/Manifest
24 @@ -0,0 +1 @@
25 +DIST aflplusplus-3.12c.tar.gz 2065569 BLAKE2B ff7a87eb02f7731b5ce8e1a3016239c6fd1cd1bfeb0b9c0fb69f72bdbf079e7700cdb32abe64f64853e5ff82f1c0ecd86d2cadb892e7c40be6bb2a7b089f7387 SHA512 a814d61298b60d99388289e742dbedf2ed1ab454a5e1ea20d48bb2f18b36c01553ab1f097a06f733439d67e804d48cb823a82ff249c404fb0b83a281564f3040
26
27 diff --git a/app-forensics/aflplusplus/aflplusplus-3.12c.ebuild b/app-forensics/aflplusplus/aflplusplus-3.12c.ebuild
28 new file mode 100644
29 index 00000000000..8f54edd03d1
30 --- /dev/null
31 +++ b/app-forensics/aflplusplus/aflplusplus-3.12c.ebuild
32 @@ -0,0 +1,75 @@
33 +# Copyright 1999-2021 Gentoo Authors
34 +# Distributed under the terms of the GNU General Public License v2
35 +
36 +EAPI=7
37 +
38 +PYTHON_COMPAT=( python3_{7,8,9} )
39 +LLVM_MAX_SLOT=11
40 +inherit toolchain-funcs llvm python-single-r1
41 +
42 +DESCRIPTION="A fork of AFL, the popular compile-time instrumentation fuzzer"
43 +HOMEPAGE="https://github.com/AFLplusplus/AFLplusplus"
44 +SRC_URI="https://github.com/AFLplusplus/AFLplusplus/archive/${PV}.tar.gz -> ${P}.tar.gz"
45 +S="${WORKDIR}/AFLplusplus-${PV}"
46 +
47 +LICENSE="Apache-2.0"
48 +SLOT="0"
49 +KEYWORDS="~amd64"
50 +IUSE="test"
51 +
52 +REQUIRED_USE="${PYTHON_REQUIRED_USE}"
53 +
54 +# Tests involve heavy use of LD_PRELOAD in some cases
55 +# This isn't compatible with sandbox
56 +RESTRICT="test"
57 +
58 +RDEPEND="
59 + ${PYTHON_DEPS}
60 + || (
61 + sys-devel/llvm:10
62 + sys-devel/llvm:11
63 + sys-devel/llvm:12
64 + )
65 +"
66 +DEPEND="
67 + ${RDEPEND}
68 + test? ( dev-util/cmocka )
69 +"
70 +
71 +QA_PREBUILT="/usr/share/afl/testcases/others/elf/small_exec.elf"
72 +
73 +PATCHES=(
74 + "${FILESDIR}/${PN}-3.0c-LDFLAGS.patch"
75 + "${FILESDIR}/${PN}-3.0c-CFLAGS.patch"
76 +)
77 +
78 +pkg_setup() {
79 + llvm_pkg_setup
80 + python-single-r1_pkg_setup
81 +}
82 +
83 +src_prepare() {
84 + default
85 +
86 + sed -i -e 's/-O3 -fno-unroll-loops//' GNUmakefile || die
87 +}
88 +
89 +src_compile() {
90 + emake \
91 + CC="$(tc-getCC)" \
92 + CFLAGS_FLTO="" \
93 + PREFIX="${EPREFIX}/usr" \
94 + HELPER_PATH="${EPREFIX}/usr/$(get_libdir)/afl" \
95 + DOC_PATH="${EPREFIX}/usr/share/doc/${PF}" \
96 + MAN_PATH="${EPREFIX}/usr/share/man/man8"
97 +}
98 +
99 +src_install() {
100 + emake \
101 + DESTDIR="${D}"
102 + PREFIX="${EPREFIX}/usr" \
103 + HELPER_PATH="${EPREFIX}/usr/$(get_libdir)/afl" \
104 + DOC_PATH="${EPREFIX}/usr/share/doc/${PF}" \
105 + MAN_PATH="${EPREFIX}/usr/share/man/man8" \
106 + install
107 +}
108
109 diff --git a/app-forensics/aflplusplus/files/aflplusplus-3.0c-CFLAGS.patch b/app-forensics/aflplusplus/files/aflplusplus-3.0c-CFLAGS.patch
110 new file mode 100644
111 index 00000000000..a3477fd7559
112 --- /dev/null
113 +++ b/app-forensics/aflplusplus/files/aflplusplus-3.0c-CFLAGS.patch
114 @@ -0,0 +1,110 @@
115 +--- a/GNUmakefile.gcc_plugin
116 ++++ b/GNUmakefile.gcc_plugin
117 +@@ -28,14 +28,14 @@ MAN_PATH ?= $(PREFIX)/share/man/man8
118 +
119 + VERSION = $(shell grep '^$(HASH)define VERSION ' ./config.h | cut -d '"' -f2)
120 +
121 +-CFLAGS ?= -O3 -g -funroll-loops -D_FORTIFY_SOURCE=2
122 ++CFLAGS ?= -D_FORTIFY_SOURCE=2
123 + CFLAGS_SAFE := -Wall -Iinclude -Wno-pointer-sign \
124 + -DAFL_PATH=\"$(HELPER_PATH)\" -DBIN_PATH=\"$(BIN_PATH)\" \
125 + -DGCC_VERSION=\"$(GCCVER)\" -DGCC_BINDIR=\"$(GCCBINDIR)\" \
126 + -Wno-unused-function
127 + override CFLAGS += $(CFLAGS_SAFE)
128 +
129 +-CXXFLAGS ?= -O3 -g -funroll-loops -D_FORTIFY_SOURCE=2
130 ++CXXFLAGS ?= -D_FORTIFY_SOURCE=2
131 + CXXEFLAGS := $(CXXFLAGS) -Wall -std=c++11
132 +
133 + CC ?= gcc
134 +--- a/GNUmakefile.llvm
135 ++++ b/GNUmakefile.llvm
136 +@@ -237,7 +237,7 @@ else
137 + AFL_CLANG_DEBUG_PREFIX =
138 + endif
139 +
140 +-CFLAGS ?= -O3 -funroll-loops -fPIC -D_FORTIFY_SOURCE=2
141 ++CFLAGS ?= -fPIC -D_FORTIFY_SOURCE=2
142 + CFLAGS_SAFE := -Wall -g -Wno-cast-qual -Wno-variadic-macros -Wno-pointer-sign -I ./include/ -I ./instrumentation/ \
143 + -DAFL_PATH=\"$(HELPER_PATH)\" -DBIN_PATH=\"$(BIN_PATH)\" \
144 + -DLLVM_BINDIR=\"$(LLVM_BINDIR)\" -DVERSION=\"$(VERSION)\" \
145 +@@ -254,7 +254,7 @@ ifdef AFL_TRACE_PC
146 + $(info Compile option AFL_TRACE_PC is deprecated, just set AFL_LLVM_INSTRUMENT=PCGUARD to activate when compiling targets )
147 + endif
148 +
149 +-CXXFLAGS ?= -O3 -funroll-loops -fPIC -D_FORTIFY_SOURCE=2
150 ++CXXFLAGS ?= -fPIC -D_FORTIFY_SOURCE=2
151 + override CXXFLAGS += -Wall -g -I ./include/ \
152 + -DVERSION=\"$(VERSION)\" -Wno-variadic-macros \
153 + -DLLVM_MINOR=$(LLVM_MINOR) -DLLVM_MAJOR=$(LLVM_MAJOR)
154 +@@ -434,20 +434,20 @@ afl-llvm-dict2file.so: instrumentation/afl-llvm-dict2file.so.cc instrumentation/
155 +
156 + .PHONY: document
157 + document:
158 +- $(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -O3 -Wno-unused-result -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt.o
159 +- @$(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -O3 -Wno-unused-result -m32 -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt-32.o 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
160 +- @$(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -O3 -Wno-unused-result -m64 -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt-64.o 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
161 ++ $(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -Wno-unused-result -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt.o
162 ++ @$(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -Wno-unused-result -m32 -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt-32.o 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
163 ++ @$(CLANG_BIN) -D_AFL_DOCUMENT_MUTATIONS $(CFLAGS_SAFE) $(CPPFLAGS) $(CLANG_CFL) -Wno-unused-result -m64 -fPIC -c instrumentation/afl-compiler-rt.o.c -o ./afl-compiler-rt-64.o 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; else echo "failed (that's fine)"; fi
164 +
165 + ./afl-compiler-rt.o: instrumentation/afl-compiler-rt.o.c
166 +- $(CC) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -O3 -Wno-unused-result -fPIC -c $< -o $@
167 ++ $(CC) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -Wno-unused-result -fPIC -c $< -o $@
168 +
169 + ./afl-compiler-rt-32.o: instrumentation/afl-compiler-rt.o.c
170 + @printf "[*] Building 32-bit variant of the runtime (-m32)... "
171 +- @$(CC) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -O3 -Wno-unused-result -m32 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; ln -sf afl-compiler-rt-32.o afl-llvm-rt-32.o; else echo "failed (that's fine)"; fi
172 ++ @$(CC) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -Wno-unused-result -m32 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; ln -sf afl-compiler-rt-32.o afl-llvm-rt-32.o; else echo "failed (that's fine)"; fi
173 +
174 + ./afl-compiler-rt-64.o: instrumentation/afl-compiler-rt.o.c
175 + @printf "[*] Building 64-bit variant of the runtime (-m64)... "
176 +- @$(CC) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -O3 -Wno-unused-result -m64 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; ln -sf afl-compiler-rt-64.o afl-llvm-rt-64.o; else echo "failed (that's fine)"; fi
177 ++ @$(CC) $(CLANG_CFL) $(CFLAGS_SAFE) $(CPPFLAGS) -Wno-unused-result -m64 -fPIC -c $< -o $@ 2>/dev/null; if [ "$$?" = "0" ]; then echo "success!"; ln -sf afl-compiler-rt-64.o afl-llvm-rt-64.o; else echo "failed (that's fine)"; fi
178 +
179 + .PHONY: test_build
180 + test_build: $(PROGS)
181 +--- a/unicorn_mode/samples/c/Makefile
182 ++++ b/unicorn_mode/samples/c/Makefile
183 +@@ -35,7 +35,7 @@ clean:
184 + rm -rf *.o harness harness-debug
185 +
186 + harness.o: harness.c ../../unicornafl/include/unicorn/*.h
187 +- ${MYCC} ${CFLAGS} -O3 -c harness.c
188 ++ ${MYCC} ${CFLAGS} -c harness.c
189 +
190 + harness-debug.o: harness.c ../../unicornafl/include/unicorn/*.h
191 + ${MYCC} ${CFLAGS} -g -c harness.c -o $@
192 +--- a/unicorn_mode/samples/persistent/Makefile
193 ++++ b/unicorn_mode/samples/persistent/Makefile
194 +@@ -35,7 +35,7 @@ clean:
195 + rm -rf *.o harness harness-debug
196 +
197 + harness.o: harness.c ../../unicornafl/include/unicorn/*.h
198 +- ${MYCC} ${CFLAGS} -O3 -c harness.c
199 ++ ${MYCC} ${CFLAGS} -c harness.c
200 +
201 + harness-debug.o: harness.c ../../unicornafl/include/unicorn/*.h
202 + ${MYCC} ${CFLAGS} -DAFL_DEBUG=1 -g -c harness.c -o $@
203 +--- a/utils/afl_untracer/Makefile
204 ++++ b/utils/afl_untracer/Makefile
205 +@@ -1,7 +1,7 @@
206 + ifdef DEBUG
207 + OPT=-O0
208 + else
209 +- OPT=-O3
210 ++ OPT?=-O2
211 + endif
212 +
213 + all: afl-untracer libtestinstr.so
214 +--- a/utils/custom_mutators/Makefile
215 ++++ b/utils/custom_mutators/Makefile
216 +@@ -1,7 +1,7 @@
217 + all: libexamplemutator.so
218 +
219 + libexamplemutator.so:
220 +- $(CC) $(CFLAGS) -D_FORTIFY_SOURCE=2 -O3 -fPIC -shared -g -I ../../include example.c -o libexamplemutator.so
221 ++ $(CC) $(CFLAGS) -D_FORTIFY_SOURCE=2 -fPIC -shared -g -I ../../include example.c -o libexamplemutator.so
222 +
223 + clean:
224 + rm -rf libexamplemutator.so
225
226 diff --git a/app-forensics/aflplusplus/files/aflplusplus-3.0c-LDFLAGS.patch b/app-forensics/aflplusplus/files/aflplusplus-3.0c-LDFLAGS.patch
227 new file mode 100644
228 index 00000000000..3e8f4dd92d1
229 --- /dev/null
230 +++ b/app-forensics/aflplusplus/files/aflplusplus-3.0c-LDFLAGS.patch
231 @@ -0,0 +1,11 @@
232 +--- a/GNUmakefile.gcc_plugin
233 ++++ b/GNUmakefile.gcc_plugin
234 +@@ -129,7 +129,7 @@ afl-common.o: ./src/afl-common.c
235 + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ $(LDFLAGS)
236 +
237 + ./afl-gcc-pass.so: instrumentation/afl-gcc-pass.so.cc | test_deps
238 +- $(CXX) $(CXXEFLAGS) $(PLUGIN_FLAGS) -shared $< -o $@
239 ++ $(CXX) $(CXXEFLAGS) $(PLUGIN_FLAGS) -shared $< -o $@ $(LDFLAGS)
240 + ln -sf afl-cc afl-gcc-fast
241 + ln -sf afl-cc afl-g++-fast
242 + ln -sf afl-cc.8 afl-gcc-fast.8
243
244 diff --git a/app-forensics/aflplusplus/metadata.xml b/app-forensics/aflplusplus/metadata.xml
245 new file mode 100644
246 index 00000000000..2c9221b04d2
247 --- /dev/null
248 +++ b/app-forensics/aflplusplus/metadata.xml
249 @@ -0,0 +1,11 @@
250 +<?xml version="1.0" encoding="UTF-8"?>
251 +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
252 +<pkgmetadata>
253 + <maintainer type="person">
254 + <email>sam@g.o</email>
255 + <name>Sam James</name>
256 + </maintainer>
257 + <upstream>
258 + <remote-id type="github">AFLplusplus/AFLplusplus</remote-id>
259 + </upstream>
260 +</pkgmetadata>