зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1765546 - Add AFL++ instrumentation toolchain r=decoder,firefox-build-system-reviewers,glandium
Differential Revision: https://phabricator.services.mozilla.com/D144208
This commit is contained in:
Родитель
d4e257a039
Коммит
1d70bb1160
|
@ -654,3 +654,10 @@ pkgconf:
|
|||
artifact-name: pkgconf.tar.zst
|
||||
strip-components: 1
|
||||
add-prefix: pkgconf/
|
||||
|
||||
aflplusplus-4.0:
|
||||
description: AFL++ 4.00 source
|
||||
fetch:
|
||||
type: git
|
||||
repo: https://github.com/AFLplusplus/AFLplusplus
|
||||
revision: ac80678592ea4a790ab2eedccfec4e3bc9f96447
|
||||
|
|
|
@ -365,3 +365,19 @@ win64-vs2019:
|
|||
- build/vs/pack_vs.py
|
||||
- build/vs/vs2019.yaml
|
||||
toolchain-artifact: project/gecko/vs/vs.tar.zst
|
||||
|
||||
linux64-afl-instrumentation-4.0:
|
||||
description: "AFL++ instrumentation toolchain build"
|
||||
treeherder:
|
||||
symbol: TL(afl++)
|
||||
worker:
|
||||
max-run-time: 3600
|
||||
run:
|
||||
script: build-afl.sh
|
||||
toolchain-artifact: public/build/afl-instrumentation.tar.zst
|
||||
toolchain-alias: linux64-afl-instrumentation
|
||||
fetches:
|
||||
fetch:
|
||||
- aflplusplus-4.0
|
||||
toolchain:
|
||||
- linux64-clang
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
diff --git a/src/afl-cc.c b/src/afl-cc.c
|
||||
index ffdda386..6ee0e2d4 100644
|
||||
--- a/src/afl-cc.c
|
||||
+++ b/src/afl-cc.c
|
||||
@@ -58,6 +58,7 @@ static u8 debug;
|
||||
static u8 cwd[4096];
|
||||
static u8 cmplog_mode;
|
||||
u8 use_stdin; /* dummy */
|
||||
+static int passthrough;
|
||||
// static u8 *march_opt = CFLAGS_OPT;
|
||||
|
||||
enum {
|
||||
@@ -315,7 +316,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
|
||||
u8 fortify_set = 0, asan_set = 0, x_set = 0, bit_mode = 0, shared_linking = 0,
|
||||
preprocessor_only = 0, have_unroll = 0, have_o = 0, have_pic = 0,
|
||||
- have_c = 0, partial_linking = 0, wasm_linking = 0;
|
||||
+ have_c = 0, partial_linking = 0;
|
||||
|
||||
cc_params = ck_alloc((argc + 128) * sizeof(u8 *));
|
||||
|
||||
@@ -825,8 +826,14 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
if (!strcmp(cur, "-x")) x_set = 1;
|
||||
if (!strcmp(cur, "-E")) preprocessor_only = 1;
|
||||
if (!strcmp(cur, "-shared")) shared_linking = 1;
|
||||
+ if (!strcmp(cur, "--target=wasm32-wasi")) {
|
||||
+
|
||||
+ if (!be_quiet) { WARNF("Found '%s'!", cur); }
|
||||
+ passthrough = 1;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
if (!strcmp(cur, "-dynamiclib")) shared_linking = 1;
|
||||
- if (!strcmp(cur, "--target=wasm32-wasi")) wasm_linking = 1;
|
||||
if (!strcmp(cur, "-Wl,-r")) partial_linking = 1;
|
||||
if (!strcmp(cur, "-Wl,-i")) partial_linking = 1;
|
||||
if (!strcmp(cur, "-Wl,--relocatable")) partial_linking = 1;
|
||||
@@ -845,7 +852,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
// e.g. compiled download or compiled from github then its ./lib directory
|
||||
// might not be in the search path. Add it if so.
|
||||
u8 *libdir = strdup(LLVM_LIBDIR);
|
||||
- if (plusplus_mode && !wasm_linking && strlen(libdir) &&
|
||||
+ if (plusplus_mode && strlen(libdir) &&
|
||||
strncmp(libdir, "/usr", 4) && strncmp(libdir, "/lib", 4)) {
|
||||
|
||||
cc_params[cc_par_cnt++] = "-rpath";
|
||||
@@ -1034,7 +1041,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
|
||||
cc_params[cc_par_cnt++] =
|
||||
"-D__AFL_LOOP(_A)="
|
||||
- "({ static volatile char *_B __attribute__((used)); "
|
||||
+ "({ static volatile char *_B __attribute__((used,unused)); "
|
||||
" _B = (char*)\"" PERSIST_SIG
|
||||
"\"; "
|
||||
#ifdef __APPLE__
|
||||
@@ -1048,7 +1055,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
|
||||
cc_params[cc_par_cnt++] =
|
||||
"-D__AFL_INIT()="
|
||||
- "do { static volatile char *_A __attribute__((used)); "
|
||||
+ "do { static volatile char *_A __attribute__((used,unused)); "
|
||||
" _A = (char*)\"" DEFER_SIG
|
||||
"\"; "
|
||||
#ifdef __APPLE__
|
||||
@@ -1093,7 +1100,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
switch (bit_mode) {
|
||||
|
||||
case 0:
|
||||
- if (!shared_linking && !partial_linking && !wasm_linking)
|
||||
+ if (!shared_linking && !partial_linking)
|
||||
cc_params[cc_par_cnt++] =
|
||||
alloc_printf("%s/afl-compiler-rt.o", obj_path);
|
||||
if (lto_mode)
|
||||
@@ -1102,7 +1109,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
break;
|
||||
|
||||
case 32:
|
||||
- if (!shared_linking && !partial_linking && !wasm_linking) {
|
||||
+ if (!shared_linking && !partial_linking) {
|
||||
|
||||
cc_params[cc_par_cnt++] =
|
||||
alloc_printf("%s/afl-compiler-rt-32.o", obj_path);
|
||||
@@ -1123,7 +1130,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
break;
|
||||
|
||||
case 64:
|
||||
- if (!shared_linking && !partial_linking && !wasm_linking) {
|
||||
+ if (!shared_linking && !partial_linking) {
|
||||
|
||||
cc_params[cc_par_cnt++] =
|
||||
alloc_printf("%s/afl-compiler-rt-64.o", obj_path);
|
||||
@@ -1146,7 +1153,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
}
|
||||
|
||||
#if !defined(__APPLE__) && !defined(__sun)
|
||||
- if (!shared_linking && !partial_linking && !wasm_linking)
|
||||
+ if (!shared_linking && !partial_linking)
|
||||
cc_params[cc_par_cnt++] =
|
||||
alloc_printf("-Wl,--dynamic-list=%s/dynamic_list.txt", obj_path);
|
||||
#endif
|
||||
@@ -1179,7 +1186,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
|
||||
|
||||
int main(int argc, char **argv, char **envp) {
|
||||
|
||||
- int i, passthrough = 0;
|
||||
+ int i;
|
||||
char *callname = argv[0], *ptr = NULL;
|
||||
|
||||
if (getenv("AFL_DEBUG")) {
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e -x
|
||||
|
||||
artifact=$(basename "$TOOLCHAIN_ARTIFACT")
|
||||
dir=${artifact%.tar.*}
|
||||
scripts="$(realpath "${0%/*}")"
|
||||
|
||||
cd "$MOZ_FETCHES_DIR/AFLplusplus"
|
||||
patch -p1 -i "$scripts/afl-wasm.patch"
|
||||
make -f GNUmakefile afl-showmap \
|
||||
CC="$MOZ_FETCHES_DIR/clang/bin/clang"
|
||||
make -f GNUmakefile.llvm install \
|
||||
DESTDIR="$dir" \
|
||||
PREFIX=/ \
|
||||
LLVM_CONFIG="$MOZ_FETCHES_DIR/clang/bin/llvm-config"
|
||||
rm -rf "$dir/share"
|
||||
|
||||
tar caf "$artifact" "$dir"
|
||||
|
||||
mkdir -p "$UPLOAD_DIR"
|
||||
mv "$artifact" "$UPLOAD_DIR"
|
Загрузка…
Ссылка в новой задаче