android: Fix runtime for mutator
MODIFY
Android.bp
Android.bp
@@ -135,6 +135,8 @@ cc_binary_host {
"-DCLANGPP_BIN=\"prebuilts/clang/host/linux-x86/clang-r383902b/bin/clang++\"",
"-DAFL_REAL_LD=\"prebuilts/clang/host/linux-x86/clang-r383902b/bin/ld.lld\"",
"-DLLVM_LTO=1",
+ "-DLLVM_MAJOR=11",
+ "-DLLVM_MINOR=2",
],
srcs: [
@@ -145,8 +147,6 @@ cc_binary_host {
symlinks: [
"afl-clang-fast",
"afl-clang-fast++",
- "afl-clang-lto",
- "afl-clang-lto++",
],
}

MODIFY
src/afl-cc.c
src/afl-cc.c
@@ -586,6 +586,9 @@ static void edit_params(u32 argc, char **argv, char **envp) {
if (instrument_mode == INSTRUMENT_PCGUARD) {
#if LLVM_MAJOR > 10 || (LLVM_MAJOR == 10 && LLVM_MINOR > 0)
+#ifdef __ANDROID__
+ cc_params[cc_par_cnt++] = "-fsanitize-coverage=trace-pc-guard";
+#else
if (have_instr_list) {
if (!be_quiet)
@@ -605,6 +608,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
}
+#endif
#else
#if LLVM_MAJOR >= 4
if (!be_quiet)
@@ -1034,6 +1038,10 @@ int main(int argc, char **argv, char **envp) {
#endif
+#ifdef __ANDROID__
+ have_llvm = 1;
+#endif
+
if ((ptr = find_object("afl-gcc-pass.so", argv[0])) != NULL) {
have_gcc_plugin = 1;
@@ -1807,11 +1815,8 @@ int main(int argc, char **argv, char **envp) {
if (!be_quiet && cmplog_mode)
printf("CmpLog mode by <andreafioraldi@gmail.com>\n");
-#ifdef __ANDROID__
- ptr = find_object("afl-compiler-rt.so", argv[0]);
-#else
+#ifndef __ANDROID__
ptr = find_object("afl-compiler-rt.o", argv[0]);
-#endif
if (!ptr) {
@@ -1824,6 +1829,7 @@ int main(int argc, char **argv, char **envp) {
if (debug) { DEBUGF("rt=%s obj_path=%s\n", ptr, obj_path); }
ck_free(ptr);
+#endif
edit_params(argc, argv, envp);

MODIFY
src/afl-fuzz-mutators.c
src/afl-fuzz-mutators.c
@@ -141,7 +141,10 @@ struct custom_mutator *load_custom_mutator(afl_state_t *afl, const char *fn) {
struct custom_mutator *mutator = ck_alloc(sizeof(struct custom_mutator));
mutator->name = fn;
+ if (memchr(fn, '/', strlen(fn)))
mutator->name_short = strrchr(fn, '/') + 1;
+ else
+ mutator->name_short = strdup(fn);
ACTF("Loading custom mutator library from '%s'...", fn);
dh = dlopen(fn, RTLD_NOW);

android: Fix runtime for mutator