[PATCH] D79239: getMainExecutable: Fix hand-rolled AT_EXECPATH search for older branches

Kyle Evans via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 17:14:02 PDT 2020


kevans created this revision.
kevans added reviewers: dim, emaste.
Herald added subscribers: llvm-commits, hiraditya, krytarowski, arichardson.
Herald added a project: LLVM.

Once we hit AT_NULL, we need to bail out of the loop; not just the enclosing
switch. This fixes basic usage (e.g. `cc --version`) when AT_EXECPATH isn't
present on older branches (e.g. under qemu-user-static, at the moment),
where we would previously run off the end of ::environ.

Signed-off-by: Kyle Evans <kevans at FreeBSD.org>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79239

Files:
  llvm/lib/Support/Unix/Path.inc


Index: llvm/lib/Support/Unix/Path.inc
===================================================================
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -212,10 +212,11 @@
     case AT_EXECPATH:
       return *p;
     case AT_NULL:
-      break;
+      goto out;
     }
     p++;
   }
+out:
 #endif
   // Fall back to argv[0] if auxiliary vectors are not available.
   if (getprogpath(exe_path, argv0) != NULL)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79239.261469.patch
Type: text/x-patch
Size: 437 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200502/831f456d/attachment-0001.bin>


More information about the llvm-commits mailing list