about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSonic <50692172+SonicStark@users.noreply.github.com>2024-01-11 18:44:40 +0800
committerGitHub <noreply@github.com>2024-01-11 10:44:40 +0000
commit4e9c6050d038c852db4f1a22fad2e8c678c9f053 (patch)
treed450bdd899b8013ec334952eb997aef717637a68
parentf75778adfb0fbea570a94b43eff801eb6d996f79 (diff)
downloadafl++-4e9c6050d038c852db4f1a22fad2e8c678c9f053.tar.gz
Fix broken LTO mode and response file support (#1948)
-rw-r--r--src/afl-cc.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/afl-cc.c b/src/afl-cc.c
index 08348d2c..5ee19e42 100644
--- a/src/afl-cc.c
+++ b/src/afl-cc.c
@@ -2059,7 +2059,6 @@ void add_lto_passes(aflcc_state_t *aflcc) {
 #endif
 
   insert_param(aflcc, "-Wl,--allow-multiple-definition");
-  insert_param(aflcc, aflcc->lto_flag);
 
 }
 
@@ -2295,10 +2294,6 @@ param_st parse_misc_params(aflcc_state_t *aflcc, u8 *cur_argv, u8 scan) {
 
     SCAN_KEEP(aflcc->have_pic, 1);
 
-  } else if (cur_argv[0] != '-') {
-
-    SCAN_KEEP(aflcc->non_dash, 1);
-
   } else if (!strcmp(cur_argv, "-m32") ||
 
              !strcmp(cur_argv, "armv7a-linux-androideabi")) {
@@ -2374,6 +2369,14 @@ param_st parse_misc_params(aflcc_state_t *aflcc, u8 *cur_argv, u8 scan) {
 
     }
 
+  } else if (cur_argv[0] != '-') {
+
+    /* It's a weak, loose pattern, with very different purpose
+     than others. We handle it at last, cautiously and robustly. */
+
+    if (scan && cur_argv[0] != '@')  // response file support
+      aflcc->non_dash = 1;
+
   }
 
 #undef SCAN_KEEP
@@ -2912,10 +2915,16 @@ static void edit_params(aflcc_state_t *aflcc, u32 argc, char **argv,
     //     use. insert_param(aflcc, "-flegacy-pass-manager");
     // #endif
 
-    if (aflcc->lto_mode && !aflcc->have_c) {
+    if (aflcc->lto_mode) {
+
+      insert_param(aflcc, aflcc->lto_flag);
+
+      if (!aflcc->have_c) {
 
-      add_lto_linker(aflcc);
-      add_lto_passes(aflcc);
+        add_lto_linker(aflcc);
+        add_lto_passes(aflcc);
+
+      }
 
     } else {