aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2020-05-17 21:29:45 +0000
committerEd Maste <emaste@FreeBSD.org>2020-05-17 21:29:45 +0000
commitc056b412992d519104c7da1c83a59e552cbc31ca (patch)
tree9cae2db0c24326b4447857d8ccd6163ee03e0daf
parenta92cf87af45db925f892048b1de17721199a7ac6 (diff)
downloadsrc-c056b412992d519104c7da1c83a59e552cbc31ca.tar.gz
src-c056b412992d519104c7da1c83a59e552cbc31ca.zip
MF11 r360876: Merge commit 21e5e1724b75 from llvm git:
getMainExecutable: Fix hand-rolled AT_EXECPATH for older FreeBSD 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. Patch By: kevans Reviewed By: arichardson Approved by: re (kib)
Notes
Notes: svn path=/releng/11.4/; revision=361142
-rw-r--r--contrib/llvm-project/llvm/lib/Support/Unix/Path.inc9
1 files changed, 2 insertions, 7 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/Unix/Path.inc b/contrib/llvm-project/llvm/lib/Support/Unix/Path.inc
index 2a03dc682bce..9b902f15fc09 100644
--- a/contrib/llvm-project/llvm/lib/Support/Unix/Path.inc
+++ b/contrib/llvm-project/llvm/lib/Support/Unix/Path.inc
@@ -208,14 +208,9 @@ std::string getMainExecutable(const char *argv0, void *MainAddr) {
while (*p++ != 0)
;
// Iterate through auxiliary vectors for AT_EXECPATH.
- for (;;) {
- switch (*(uintptr_t *)p++) {
- case AT_EXECPATH:
+ for (; *(uintptr_t *)p != AT_NULL; p++) {
+ if (*(uintptr_t *)p++ == AT_EXECPATH)
return *p;
- case AT_NULL:
- break;
- }
- p++;
}
#endif
// Fall back to argv[0] if auxiliary vectors are not available.