about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-12-11 11:19:26 +0100
committervan Hauser <vh@thc.org>2020-12-11 11:19:26 +0100
commit2bf68a0bf45fb2bb3bc0f574f20959a62c9f8239 (patch)
tree9452e9bc752dccbec05ac87928e2cf32a1bafd5a
parent8a1acac559edb66e8e246e73508cec541a9fc530 (diff)
downloadafl++-2bf68a0bf45fb2bb3bc0f574f20959a62c9f8239.tar.gz
fix MMAP
-rw-r--r--GNUmakefile.llvm4
-rw-r--r--instrumentation/afl-compiler-rt.o.c2
-rw-r--r--src/afl-cc.c27
-rw-r--r--src/afl-fuzz.c8
4 files changed, 21 insertions, 20 deletions
diff --git a/GNUmakefile.llvm b/GNUmakefile.llvm
index 6e80de81..414cd487 100644
--- a/GNUmakefile.llvm
+++ b/GNUmakefile.llvm
@@ -288,13 +288,13 @@ ifeq "$(shell echo '$(HASH)include <sys/ipc.h>@$(HASH)include <sys/shm.h>@int ma
         SHMAT_OK=1
 else
         SHMAT_OK=0
-        #CFLAGS+=-DUSEMMAP=1
+        CFLAGS_SAFE += -DUSEMMAP=1
         LDFLAGS += -Wno-deprecated-declarations
 endif
 
 ifeq "$(TEST_MMAP)" "1"
         SHMAT_OK=0
-        CFLAGS+=-DUSEMMAP=1
+        CFLAGS_SAFE += -DUSEMMAP=1
         LDFLAGS += -Wno-deprecated-declarations
 endif
 
diff --git a/instrumentation/afl-compiler-rt.o.c b/instrumentation/afl-compiler-rt.o.c
index 99dcbb67..afe0839e 100644
--- a/instrumentation/afl-compiler-rt.o.c
+++ b/instrumentation/afl-compiler-rt.o.c
@@ -1107,7 +1107,7 @@ void __sanitizer_cov_trace_pc_guard_init(uint32_t *start, uint32_t *stop) {
      to avoid duplicate calls (which can happen as an artifact of the underlying
      implementation in LLVM). */
 
-  *(start++) = R(MAP_SIZE - 1) + 1;
+  *(start++) = ++__afl_final_loc;
 
   while (start < stop) {
 
diff --git a/src/afl-cc.c b/src/afl-cc.c
index 14d8e070..37cfc7c8 100644
--- a/src/afl-cc.c
+++ b/src/afl-cc.c
@@ -130,21 +130,6 @@ static u8 *find_object(u8 *obj, u8 *argv0) {
   u8 *afl_path = getenv("AFL_PATH");
   u8 *slash = NULL, *tmp;
 
-  /*
-    if (obj_path) {
-
-      tmp = alloc_printf("%s/%s", obj_path, obj);
-
-      if (debug) DEBUGF("Trying %s\n", tmp);
-
-      if (!access(tmp, R_OK)) { return tmp; }
-
-      ck_free(tmp);
-
-    }
-
-  */
-
   if (afl_path) {
 
     tmp = alloc_printf("%s/%s", afl_path, obj);
@@ -906,6 +891,10 @@ static void edit_params(u32 argc, char **argv, char **envp) {
           alloc_printf("-Wl,--dynamic-list=%s/dynamic_list.txt", obj_path);
   #endif
 
+#ifdef USEMMAP
+    cc_params[cc_par_cnt++] = "-lrt";
+#endif
+
   }
 
 #endif
@@ -1475,9 +1464,15 @@ int main(int argc, char **argv, char **envp) {
     if (have_llvm)
       SAYF("afl-cc LLVM version %d with the the binary path \"%s\".\n",
            LLVM_MAJOR, LLVM_BINDIR);
-    if (have_lto || have_llvm) SAYF("\n");
 #endif
 
+#ifdef USEMMAP
+  SAYF("Compiled with shm_open support (adds -lrt when linking).\n");
+#else
+  SAYF("Compiled with shmat support.\n");
+#endif
+    SAYF("\n");
+
     SAYF(
         "Do not be overwhelmed :) afl-cc uses good defaults if no options are "
         "selected.\n"
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index bbe6aec6..391d4c4f 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -230,6 +230,12 @@ static void usage(u8 *argv0, int more_help) {
   SAYF("Compiled without python module support\n");
 #endif
 
+#ifdef USEMMAP
+  SAYF("Compiled with shm_open support.\n");
+#else
+  SAYF("Compiled with shmat support.\n");
+#endif
+
 #ifdef ASAN_BUILD
   SAYF("Compiled with ASAN_BUILD\n\n");
 #endif
@@ -254,7 +260,7 @@ static void usage(u8 *argv0, int more_help) {
   SAYF("Compiled with _AFL_DOCUMENT_MUTATIONS\n\n");
 #endif
 
-  SAYF("For additional help please consult %s/README.md\n\n", doc_path);
+  SAYF("For additional help please consult %s/README.md :)\n\n", doc_path);
 
   exit(1);
 #undef PHYTON_SUPPORT