Skip to content

Commit 120d009

Browse files
committed
wasm support
1 parent e12acaa commit 120d009

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

Diff for: GNUmakefile

+1
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ help:
388388
@echo NO_NYX - disable building nyx mode dependencies
389389
@echo "NO_CORESIGHT - disable building coresight (arm64 only)"
390390
@echo NO_UNICORN_ARM64 - disable building unicorn on arm64
391+
@echo "WAFL_MODE - enable for WASM fuzzing with https://github.com/fgsect/WAFL"
391392
@echo AFL_NO_X86 - if compiling on non-intel/amd platforms
392393
@echo "LLVM_CONFIG - if your distro doesn't use the standard name for llvm-config (e.g., Debian)"
393394
@echo "=========================================="

Diff for: GNUmakefile.llvm

+5
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,11 @@ endif
294294
CLANG_CPPFL = `$(LLVM_CONFIG) --cxxflags` -fno-rtti -fPIC $(CXXFLAGS) -Wno-deprecated-declarations
295295
CLANG_LFL = `$(LLVM_CONFIG) --ldflags` $(LDFLAGS)
296296

297+
# wasm fuzzing: disable thread-local storage and unset LLVM debug flag
298+
ifdef WAFL_MODE
299+
$(info Compiling libraries for use with WAVM)
300+
CLANG_CPPFL += -DNDEBUG -DNO_TLS
301+
endif
297302

298303
# User teor2345 reports that this is required to make things work on MacOS X.
299304
ifeq "$(SYS)" "Darwin"

Diff for: instrumentation/afl-compiler-rt.o.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ int __afl_selective_coverage __attribute__((weak));
113113
int __afl_selective_coverage_start_off __attribute__((weak));
114114
static int __afl_selective_coverage_temp = 1;
115115

116-
#if defined(__ANDROID__) || defined(__HAIKU__)
116+
#if defined(__ANDROID__) || defined(__HAIKU__) || defined(NO_TLS)
117117
PREV_LOC_T __afl_prev_loc[NGRAM_SIZE_MAX];
118118
PREV_LOC_T __afl_prev_caller[CTX_MAX_K];
119119
u32 __afl_prev_ctx;

Diff for: instrumentation/afl-llvm-pass.so.cc

+5-5
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ bool AFLCoverage::runOnModule(Module &M) {
413413
GlobalVariable *AFLContext = NULL;
414414

415415
if (ctx_str || caller_str)
416-
#if defined(__ANDROID__) || defined(__HAIKU__)
416+
#if defined(__ANDROID__) || defined(__HAIKU__) || defined(NO_TLS)
417417
AFLContext = new GlobalVariable(
418418
M, Int32Ty, false, GlobalValue::ExternalLinkage, 0, "__afl_prev_ctx");
419419
#else
@@ -424,7 +424,7 @@ bool AFLCoverage::runOnModule(Module &M) {
424424

425425
#ifdef AFL_HAVE_VECTOR_INTRINSICS
426426
if (ngram_size)
427-
#if defined(__ANDROID__) || defined(__HAIKU__)
427+
#if defined(__ANDROID__) || defined(__HAIKU__) || defined(NO_TLS)
428428
AFLPrevLoc = new GlobalVariable(
429429
M, PrevLocTy, /* isConstant */ false, GlobalValue::ExternalLinkage,
430430
/* Initializer */ nullptr, "__afl_prev_loc");
@@ -437,7 +437,7 @@ bool AFLCoverage::runOnModule(Module &M) {
437437
#endif
438438
else
439439
#endif
440-
#if defined(__ANDROID__) || defined(__HAIKU__)
440+
#if defined(__ANDROID__) || defined(__HAIKU__) || defined(NO_TLS)
441441
AFLPrevLoc = new GlobalVariable(
442442
M, Int32Ty, false, GlobalValue::ExternalLinkage, 0, "__afl_prev_loc");
443443
#else
@@ -448,7 +448,7 @@ bool AFLCoverage::runOnModule(Module &M) {
448448

449449
#ifdef AFL_HAVE_VECTOR_INTRINSICS
450450
if (ctx_k)
451-
#if defined(__ANDROID__) || defined(__HAIKU__)
451+
#if defined(__ANDROID__) || defined(__HAIKU__) || defined(NO_TLS)
452452
AFLPrevCaller = new GlobalVariable(
453453
M, PrevCallerTy, /* isConstant */ false, GlobalValue::ExternalLinkage,
454454
/* Initializer */ nullptr, "__afl_prev_caller");
@@ -461,7 +461,7 @@ bool AFLCoverage::runOnModule(Module &M) {
461461
#endif
462462
else
463463
#endif
464-
#if defined(__ANDROID__) || defined(__HAIKU__)
464+
#if defined(__ANDROID__) || defined(__HAIKU__) || defined(NO_TLS)
465465
AFLPrevCaller =
466466
new GlobalVariable(M, Int32Ty, false, GlobalValue::ExternalLinkage, 0,
467467
"__afl_prev_caller");

0 commit comments

Comments
 (0)