about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorvanhauser-thc <vh@thc.org>2023-01-23 12:45:21 +0100
committervanhauser-thc <vh@thc.org>2023-01-23 12:45:21 +0100
commit8bc7b3cf26c2e94ee99fa854c9f7007092bc9949 (patch)
treedcd70774207b5c39ad79861b1943b1f9e008511b /src
parent5163a49350ed17149cb3c52bc79bd87e86402510 (diff)
downloadafl++-8bc7b3cf26c2e94ee99fa854c9f7007092bc9949.tar.gz
add CFI variant for gcc
Diffstat (limited to 'src')
-rw-r--r--src/afl-cc.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/afl-cc.c b/src/afl-cc.c
index 803e784e..cbf57047 100644
--- a/src/afl-cc.c
+++ b/src/afl-cc.c
@@ -1050,17 +1050,25 @@ static void edit_params(u32 argc, char **argv, char **envp) {
 
   if (getenv("AFL_USE_CFISAN")) {
 
-    if (!lto_mode) {
+    if (compiler_mode == GCC_PLUGIN || compiler_mode == GCC) {
 
-      uint32_t i = 0, found = 0;
-      while (envp[i] != NULL && !found)
-        if (strncmp("-flto", envp[i++], 5) == 0) found = 1;
-      if (!found) cc_params[cc_par_cnt++] = "-flto";
+      cc_params[cc_par_cnt++] = "-fcf-protection";
 
-    }
+    } else {
+
+      if (!lto_mode) {
+
+        uint32_t i = 0, found = 0;
+        while (envp[i] != NULL && !found)
+          if (strncmp("-flto", envp[i++], 5) == 0) found = 1;
+        if (!found) cc_params[cc_par_cnt++] = "-flto";
 
-    cc_params[cc_par_cnt++] = "-fsanitize=cfi";
-    cc_params[cc_par_cnt++] = "-fvisibility=hidden";
+      }
+
+      cc_params[cc_par_cnt++] = "-fsanitize=cfi";
+      cc_params[cc_par_cnt++] = "-fvisibility=hidden";
+
+    }
 
   }