diff options
author | Huanyao Rong <r3tr0spect2019@qq.com> | 2024-06-21 21:03:37 -0700 |
---|---|---|
committer | Nguyễn Gia Phong <cnx@loang.net> | 2024-12-03 11:17:44 +0900 |
commit | d04bdf2e841fa6706c16bbba1cb6f6c73d647767 (patch) | |
tree | 23393adc733e6e9e61d7eb226c90258870bb0624 /src/aflrun-cc.c | |
parent | cee3c86d7d5f0a05ad6cbb1434dc13162a16e336 (diff) | |
download | afl++-d04bdf2e841fa6706c16bbba1cb6f6c73d647767.tar.gz |
Implement AFLRun
References: https://github.com/Mem2019/AFLRun/commit/f5bb87f78ef1 References: https://github.com/Mem2019/AFLRun/commit/3af5f11b5644
Diffstat (limited to 'src/aflrun-cc.c')
-rw-r--r-- | src/aflrun-cc.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/aflrun-cc.c b/src/aflrun-cc.c new file mode 100644 index 00000000..2b12c413 --- /dev/null +++ b/src/aflrun-cc.c @@ -0,0 +1,30 @@ +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <unistd.h> + +#include "debug.h" +#include "alloc-inl.h" + +/* This compiler is used to handle cases where we cannot designate compiler +via $CC and $CXX, but instead we can only replace their compiler with the AFL one. +For example, when compiling chroimium/v8. */ + +int main(int argc, char const *argv[]) +{ + char const** new_argv = (char const**)malloc((argc + 1) * sizeof(char*)); + + char* afl_path = getenv("AFL_PATH"); + if (afl_path == NULL) + FATAL("Please specify AFL_PATH"); + + new_argv[0] = alloc_printf("%s/%s", afl_path, + strstr(argv[0], "++") == NULL ? "afl-clang-lto" : "afl-clang-lto++"); + for (int i = 1; i < argc; ++i) + new_argv[i] = argv[i]; + new_argv[argc] = NULL; + + execvp(new_argv[0], (char**)new_argv); + + return 0; +} |