aboutsummaryrefslogtreecommitdiff
path: root/llvm_mode
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-03-09 10:56:53 +0100
committervan Hauser <vh@thc.org>2020-03-09 10:56:53 +0100
commitdcf7d85cba9a8ee5a33cff578fe48bdbccda1a3d (patch)
tree07e5d1337b58053645ae470e00aae12cd3b61a5e /llvm_mode
parent8e953d99314203f5c996b4a327403563b1c4ec00 (diff)
downloadafl++-dcf7d85cba9a8ee5a33cff578fe48bdbccda1a3d.tar.gz
honor no_quiet for missing llvm_mode output, also print to stderr with afl-*-rt.o.c instead of stdout for errors plus two potential bad free() fixes
Diffstat (limited to 'llvm_mode')
-rw-r--r--llvm_mode/LLVMInsTrim.so.cc22
-rw-r--r--llvm_mode/afl-ld.c2
-rw-r--r--llvm_mode/afl-llvm-lto-instrumentation.so.cc2
-rw-r--r--llvm_mode/afl-llvm-lto-whitelist.so.cc1
-rw-r--r--llvm_mode/afl-llvm-rt.o.c8
5 files changed, 20 insertions, 15 deletions
diff --git a/llvm_mode/LLVMInsTrim.so.cc b/llvm_mode/LLVMInsTrim.so.cc
index 390e0697..8127c893 100644
--- a/llvm_mode/LLVMInsTrim.so.cc
+++ b/llvm_mode/LLVMInsTrim.so.cc
@@ -142,7 +142,7 @@ struct InsTrim : public ModulePass {
#if LLVM_VERSION_MAJOR < 9
char *neverZero_counters_str;
if ((neverZero_counters_str = getenv("AFL_LLVM_NOT_ZERO")) != NULL)
- OKF("LLVM neverZero activated (by hexcoder)\n");
+ if (!be_quiet) OKF("LLVM neverZero activated (by hexcoder)\n");
#endif
if (getenv("AFL_LLVM_INSTRIM_LOOPHEAD") != NULL ||
@@ -523,15 +523,19 @@ struct InsTrim : public ModulePass {
}
- char modeline[100];
- snprintf(modeline, sizeof(modeline), "%s%s%s%s",
- getenv("AFL_HARDEN") ? "hardened" : "non-hardened",
- getenv("AFL_USE_ASAN") ? ", ASAN" : "",
- getenv("AFL_USE_MSAN") ? ", MSAN" : "",
- getenv("AFL_USE_UBSAN") ? ", UBSAN" : "");
+ if (!be_quiet) {
- OKF("Instrumented %u locations (%llu, %llu) (%s mode)\n", total_instr,
- total_rs, total_hs, modeline);
+ char modeline[100];
+ snprintf(modeline, sizeof(modeline), "%s%s%s%s",
+ getenv("AFL_HARDEN") ? "hardened" : "non-hardened",
+ getenv("AFL_USE_ASAN") ? ", ASAN" : "",
+ getenv("AFL_USE_MSAN") ? ", MSAN" : "",
+ getenv("AFL_USE_UBSAN") ? ", UBSAN" : "");
+
+ OKF("Instrumented %u locations (%llu, %llu) (%s mode)\n", total_instr,
+ total_rs, total_hs, modeline);
+
+ }
return false;
diff --git a/llvm_mode/afl-ld.c b/llvm_mode/afl-ld.c
index 0e85795a..bd451ca5 100644
--- a/llvm_mode/afl-ld.c
+++ b/llvm_mode/afl-ld.c
@@ -424,7 +424,7 @@ static void edit_params(int argc, char** argv) {
} else
- if (dir_ent->d_name[0] != '.')
+ if (dir_ent->d_name[0] != '.' && !be_quiet)
WARNF("Unusual file found in ar archive %s: %s", argv[i], ar_file);
}
diff --git a/llvm_mode/afl-llvm-lto-instrumentation.so.cc b/llvm_mode/afl-llvm-lto-instrumentation.so.cc
index d3224700..febb8950 100644
--- a/llvm_mode/afl-llvm-lto-instrumentation.so.cc
+++ b/llvm_mode/afl-llvm-lto-instrumentation.so.cc
@@ -282,7 +282,7 @@ bool AFLLTOPass::runOnModule(Module &M) {
if (!newBB) {
- WARNF("Split failed!");
+ if (!be_quiet) WARNF("Split failed!");
continue;
}
diff --git a/llvm_mode/afl-llvm-lto-whitelist.so.cc b/llvm_mode/afl-llvm-lto-whitelist.so.cc
index 617f9ca1..48df76c3 100644
--- a/llvm_mode/afl-llvm-lto-whitelist.so.cc
+++ b/llvm_mode/afl-llvm-lto-whitelist.so.cc
@@ -217,6 +217,7 @@ bool AFLwhitelist::runOnModule(Module &M) {
F.getName().compare("init") == 0 ||
F.getName().compare("_init") == 0) {
+ // We do not honor be_quiet for this one
WARNF("Cannot ignore functions main/init/start");
} else {
diff --git a/llvm_mode/afl-llvm-rt.o.c b/llvm_mode/afl-llvm-rt.o.c
index 64c2ff2b..58b64670 100644
--- a/llvm_mode/afl-llvm-rt.o.c
+++ b/llvm_mode/afl-llvm-rt.o.c
@@ -97,7 +97,7 @@ static void __afl_map_shm(void) {
shm_fd = shm_open(shm_file_path, O_RDWR, 0600);
if (shm_fd == -1) {
- printf("shm_open() failed\n");
+ fprintf(stderr, "shm_open() failed\n");
exit(1);
}
@@ -109,7 +109,7 @@ static void __afl_map_shm(void) {
close(shm_fd);
shm_fd = -1;
- printf("mmap() failed\n");
+ fprintf(stderr, "mmap() failed\n");
exit(2);
}
@@ -145,7 +145,7 @@ static void __afl_map_shm(void) {
shm_fd = shm_open(shm_file_path, O_RDWR, 0600);
if (shm_fd == -1) {
- printf("shm_open() failed\n");
+ fprintf(stderr, "shm_open() failed\n");
exit(1);
}
@@ -158,7 +158,7 @@ static void __afl_map_shm(void) {
close(shm_fd);
shm_fd = -1;
- printf("mmap() failed\n");
+ fprintf(stderr, "mmap() failed\n");
exit(2);
}