about summary refs log tree commit diff
path: root/src/afl-cc.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2023-10-24 09:19:26 +0200
committerGitHub <noreply@github.com>2023-10-24 09:19:26 +0200
commitd52013832a82fa637450cad826af9fd8d64fefa1 (patch)
treebfa47476716ba9d5760c86b3221c93307da0bd8c /src/afl-cc.c
parenteaa6a1754a2efa54903959a5b3ce3d433dcdea37 (diff)
parentcf458a7d25dc3448b94ffe08d3d89531fc8d4818 (diff)
downloadafl++-d52013832a82fa637450cad826af9fd8d64fefa1.tar.gz
Merge pull request #1893 from jschwartzentruber/add-no-rpath-flag
Add an env to afl-clang-fast to disable setting rpath if LLVM path isn't recognized
Diffstat (limited to 'src/afl-cc.c')
-rw-r--r--src/afl-cc.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/afl-cc.c b/src/afl-cc.c
index 037a5c30..5f8f278f 100644
--- a/src/afl-cc.c
+++ b/src/afl-cc.c
@@ -1144,19 +1144,22 @@ static void edit_params(u32 argc, char **argv, char **envp) {
 
   if (!have_pic) { cc_params[cc_par_cnt++] = "-fPIC"; }
 
-  // in case LLVM is installed not via a package manager or "make install"
-  // e.g. compiled download or compiled from github then its ./lib directory
-  // might not be in the search path. Add it if so.
-  u8 *libdir = strdup(LLVM_LIBDIR);
-  if (plusplus_mode && strlen(libdir) && strncmp(libdir, "/usr", 4) &&
-      strncmp(libdir, "/lib", 4)) {
+  if (!getenv("AFL_LLVM_NO_RPATH")) {
+    // in case LLVM is installed not via a package manager or "make install"
+    // e.g. compiled download or compiled from github then its ./lib directory
+    // might not be in the search path. Add it if so.
+    u8 *libdir = strdup(LLVM_LIBDIR);
+    if (plusplus_mode && strlen(libdir) && strncmp(libdir, "/usr", 4) &&
+        strncmp(libdir, "/lib", 4)) {
 
-    cc_params[cc_par_cnt++] = "-Wl,-rpath";
-    cc_params[cc_par_cnt++] = libdir;
+      cc_params[cc_par_cnt++] = "-Wl,-rpath";
+      cc_params[cc_par_cnt++] = libdir;
 
-  } else {
+    } else {
 
-    free(libdir);
+      free(libdir);
+
+    }
 
   }
 
@@ -2289,7 +2292,9 @@ int main(int argc, char **argv, char **envp) {
             "  AFL_LLVM_CTX: use full context sensitive coverage (for "
             "CLASSIC)\n"
             "  AFL_LLVM_NGRAM_SIZE: use ngram prev_loc count coverage (for "
-            "CLASSIC)\n");
+            "CLASSIC)\n"
+            "  AFL_LLVM_NO_RPATH: disable rpath setting for custom LLVM "
+            "locations\n");
 
 #ifdef AFL_CLANG_FLTO
       if (have_lto)