aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2021-03-09 16:53:56 +0100
committervanhauser-thc <vh@thc.org>2021-03-09 16:53:56 +0100
commit47f2650a32470172a32c4ebd446003cb8a4b80e8 (patch)
tree69deb46ab5a81758b9b0d5699dc346e6685c90bc
parent74a6044b3fba496c1255f9aedbf5b7253ae29f0e (diff)
downloadafl++-47f2650a32470172a32c4ebd446003cb8a4b80e8.tar.gz
add AFL_NOOPT
-rw-r--r--README.md17
-rw-r--r--docs/env_variables.md11
-rw-r--r--include/envs.h4
-rw-r--r--src/afl-cc.c21
-rw-r--r--src/afl-common.c1
5 files changed, 47 insertions, 7 deletions
diff --git a/README.md b/README.md
index 6b11fee4..d4e39566 100644
--- a/README.md
+++ b/README.md
@@ -399,10 +399,19 @@ How to do this is described below.
Then build the target. (Usually with `make`)
-**NOTE**: sometimes configure and build systems are fickle and do not like
-stderr output (and think this means a test failure) - which is something
-afl++ like to do to show statistics. It is recommended to disable them via
-`export AFL_QUIET=1`.
+**NOTES**
+
+1. sometimes configure and build systems are fickle and do not like
+ stderr output (and think this means a test failure) - which is something
+ afl++ like to do to show statistics. It is recommended to disable them via
+ `export AFL_QUIET=1`.
+
+2. sometimes configure and build systems error on warnings - these should be
+ disabled (e.g. `--disable-werror` for some configure scripts`
+
+3. in case the configure/build system complains about afl++'s compiler and
+ aborts then set `export AFL_NOOPT=1` which will then just behave like the
+ real compiler. This option has to be unset again before building the target!
##### configure
diff --git a/docs/env_variables.md b/docs/env_variables.md
index f6ed12d0..a20f1e42 100644
--- a/docs/env_variables.md
+++ b/docs/env_variables.md
@@ -26,6 +26,17 @@ Because (with the exception of the --afl-MODE command line option) the
compile-time tools do not accept afl specific command-line options, they
make fairly broad use of environmental variables instead:
+ - Some build/configure scripts break with afl++ compilers. To be able to
+ pass them, do:
+```
+ export CC=afl-cc
+ export CXX=afl-c++
+ export AFL_NOOPT=1
+ ./configure --disable-shared --disabler-werror
+ unset AFL_NOOPT
+ make
+```
+
- Most afl tools do not print any output if stdout/stderr are redirected.
If you want to get the output into a file then set the `AFL_DEBUG`
environment variable.
diff --git a/include/envs.h b/include/envs.h
index e8595ef7..37748a56 100644
--- a/include/envs.h
+++ b/include/envs.h
@@ -119,10 +119,12 @@ static char *afl_environment_variables[] = {
"AFL_NO_PYTHON",
"AFL_UNTRACER_FILE",
"AFL_LLVM_USE_TRACE_PC",
- "AFL_NO_X86", // not really an env but we dont want to warn on it
"AFL_MAP_SIZE",
"AFL_MAPSIZE",
"AFL_MAX_DET_EXTRAS",
+ "AFL_NO_X86", // not really an env but we dont want to warn on it
+ "AFL_NOOPT",
+ "AFL_PASSTHROUGH",
"AFL_PATH",
"AFL_PERFORMANCE_FILE",
"AFL_PRELOAD",
diff --git a/src/afl-cc.c b/src/afl-cc.c
index bb136fb9..8f9bb397 100644
--- a/src/afl-cc.c
+++ b/src/afl-cc.c
@@ -1025,7 +1025,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
int main(int argc, char **argv, char **envp) {
- int i;
+ int i, passthrough = 0;
char *callname = argv[0], *ptr = NULL;
if (getenv("AFL_DEBUG")) {
@@ -1045,6 +1045,13 @@ int main(int argc, char **argv, char **envp) {
}
+ if (getenv("AFL_PASSTHROUGH") || getenv("AFL_NOOPT")) {
+
+ passthrough = 1;
+ if (!debug) { be_quiet = 1; }
+
+ }
+
if ((ptr = strrchr(callname, '/')) != NULL) callname = ptr + 1;
argvnull = (u8 *)argv[0];
check_environment_vars(envp);
@@ -1665,6 +1672,7 @@ int main(int argc, char **argv, char **envp) {
" AFL_DONT_OPTIMIZE: disable optimization instead of -O3\n"
" AFL_NO_BUILTIN: no builtins for string compare functions (for "
"libtokencap.so)\n"
+ " AFL_NOOP: behave lik a normal compiler (to pass configure tests)\n"
" AFL_PATH: path to instrumenting pass and runtime "
"(afl-compiler-rt.*o)\n"
" AFL_IGNORE_UNKNOWN_ENVS: don't warn on unknown env vars\n"
@@ -1977,7 +1985,16 @@ int main(int argc, char **argv, char **envp) {
}
- execvp(cc_params[0], (char **)cc_params);
+ if (passthrough) {
+
+ argv[0] = cc_params[0];
+ execvp(cc_params[0], (char **)argv);
+
+ } else {
+
+ execvp(cc_params[0], (char **)cc_params);
+
+ }
FATAL("Oops, failed to execute '%s' - check your PATH", cc_params[0]);
diff --git a/src/afl-common.c b/src/afl-common.c
index a306fe5e..68f82a5e 100644
--- a/src/afl-common.c
+++ b/src/afl-common.c
@@ -682,6 +682,7 @@ void check_environment_vars(char **envp) {
env[strlen(afl_environment_variables[i])] == '=') {
match = 1;
+
if ((val = getenv(afl_environment_variables[i])) && !*val) {
WARNF(