android: Fix runtime for mutator

This commit is contained in:
Joey Jiao
2021-01-19 09:44:59 +08:00
parent 7ad8f6c717
commit ac1117ffae
3 changed files with 16 additions and 7 deletions

View File

@ -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++",
],
}

View File

@ -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);

View File

@ -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);