add AFL_NOOPT

This commit is contained in:
vanhauser-thc
2021-03-09 16:53:56 +01:00
parent 74a6044b3f
commit 47f2650a32
5 changed files with 47 additions and 7 deletions

View File

@ -399,10 +399,19 @@ How to do this is described below.
Then build the target. (Usually with `make`) Then build the target. (Usually with `make`)
**NOTE**: sometimes configure and build systems are fickle and do not like **NOTES**
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 1. sometimes configure and build systems are fickle and do not like
`export AFL_QUIET=1`. 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 ##### configure

View File

@ -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 compile-time tools do not accept afl specific command-line options, they
make fairly broad use of environmental variables instead: 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. - 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` If you want to get the output into a file then set the `AFL_DEBUG`
environment variable. environment variable.

View File

@ -119,10 +119,12 @@ static char *afl_environment_variables[] = {
"AFL_NO_PYTHON", "AFL_NO_PYTHON",
"AFL_UNTRACER_FILE", "AFL_UNTRACER_FILE",
"AFL_LLVM_USE_TRACE_PC", "AFL_LLVM_USE_TRACE_PC",
"AFL_NO_X86", // not really an env but we dont want to warn on it
"AFL_MAP_SIZE", "AFL_MAP_SIZE",
"AFL_MAPSIZE", "AFL_MAPSIZE",
"AFL_MAX_DET_EXTRAS", "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_PATH",
"AFL_PERFORMANCE_FILE", "AFL_PERFORMANCE_FILE",
"AFL_PRELOAD", "AFL_PRELOAD",

View File

@ -1025,7 +1025,7 @@ static void edit_params(u32 argc, char **argv, char **envp) {
int main(int 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; char *callname = argv[0], *ptr = NULL;
if (getenv("AFL_DEBUG")) { 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; if ((ptr = strrchr(callname, '/')) != NULL) callname = ptr + 1;
argvnull = (u8 *)argv[0]; argvnull = (u8 *)argv[0];
check_environment_vars(envp); 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_DONT_OPTIMIZE: disable optimization instead of -O3\n"
" AFL_NO_BUILTIN: no builtins for string compare functions (for " " AFL_NO_BUILTIN: no builtins for string compare functions (for "
"libtokencap.so)\n" "libtokencap.so)\n"
" AFL_NOOP: behave lik a normal compiler (to pass configure tests)\n"
" AFL_PATH: path to instrumenting pass and runtime " " AFL_PATH: path to instrumenting pass and runtime "
"(afl-compiler-rt.*o)\n" "(afl-compiler-rt.*o)\n"
" AFL_IGNORE_UNKNOWN_ENVS: don't warn on unknown env vars\n" " AFL_IGNORE_UNKNOWN_ENVS: don't warn on unknown env vars\n"
@ -1977,8 +1985,17 @@ int main(int argc, char **argv, char **envp) {
} }
if (passthrough) {
argv[0] = cc_params[0];
execvp(cc_params[0], (char **)argv);
} else {
execvp(cc_params[0], (char **)cc_params); execvp(cc_params[0], (char **)cc_params);
}
FATAL("Oops, failed to execute '%s' - check your PATH", cc_params[0]); FATAL("Oops, failed to execute '%s' - check your PATH", cc_params[0]);
return 0; return 0;

View File

@ -682,6 +682,7 @@ void check_environment_vars(char **envp) {
env[strlen(afl_environment_variables[i])] == '=') { env[strlen(afl_environment_variables[i])] == '=') {
match = 1; match = 1;
if ((val = getenv(afl_environment_variables[i])) && !*val) { if ((val = getenv(afl_environment_variables[i])) && !*val) {
WARNF( WARNF(