.PHONY: x86-insn-fuzz-all
ifeq ($(CONFIG_X86_64),y)
-x86-insn-fuzz-all: x86-insn-fuzzer.a fuzz-emul.o afl
+x86-insn-fuzz-all: x86-insn-fuzzer.a fuzz-emul.o afl libfuzzer
else
x86-insn-fuzz-all:
endif
afl-harness-cov: afl-harness-cov.o $(patsubst %.o,%-cov.o,$(OBJS)) cpuid.o wrappers.o
$(CC) $(CFLAGS) $(GCOV_FLAGS) $(addprefix -Wl$(comma)--wrap=,$(WRAPPED)) $^ -o $@
+libfuzzer-harness: $(OBJS) cpuid.o wrappers.o
+ $(CC) $(CFLAGS) $(LIB_FUZZING_ENGINE) -fsanitize=fuzzer $(addprefix -Wl$(comma)--wrap=,$(WRAPPED)) $^ -o $@
+
# Common targets
.PHONY: all
all: x86-insn-fuzz-all
.PHONY: clean
clean:
- rm -f *.a *.o $(DEPS_RM) afl-harness afl-harness-cov *.gcda *.gcno *.gcov
+ rm -f *.a *.o $(DEPS_RM) *.gcda *.gcno *.gcov
+ rm -f afl-harness afl-harness-cov libfuzzer-harness
rm -rf x86_emulate x86-emulate.c x86-emulate.h wrappers.c cpuid.c
.PHONY: install
.PHONY: afl-cov
afl-cov: afl-harness-cov
+.PHONY: libfuzzer
+libfuzzer: libfuzzer-harness
+
-include $(DEPS_INCLUDE)
if ( size <= DATA_OFFSET )
{
- printf("Input too small\n");
- return 1;
+ return -1;
}
if ( size > FUZZ_CORPUS_SIZE )
{
- printf("Input too large\n");
- return 1;
+ return -1;
}
memcpy(&input, data_p, size);
return rc;
}
+int __wrap_vsnprintf(char *buf, size_t n, const char *fmt, va_list varg)
+{
+ int rc;
+
+ emul_save_fpu_state();
+ rc = __real_vsnprintf(buf, n, fmt, varg);
+ emul_restore_fpu_state();
+
+ return rc;
+}
+
char *__wrap_strstr(const char *s1, const char *s2)
{
char *s;