[compiler-rt] Revert "[compiler-rt] simplifying ::ReExec for freebsd. (#79711)" (PR #82933)
David CARLIER via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 25 12:58:18 PST 2024
https://github.com/devnexen created https://github.com/llvm/llvm-project/pull/82933
This reverts commit 691b12a2dcc12fa43517d23f2a9b6039616eebc8.
>From 4f096251c6443fcaee4d1a542b6f481a0acce794 Mon Sep 17 00:00:00 2001
From: David Carlier <devnexen at gmail.com>
Date: Sun, 25 Feb 2024 20:57:42 +0000
Subject: [PATCH] Revert "[compiler-rt] simplifying ::ReExec for freebsd.
(#79711)"
This reverts commit 691b12a2dcc12fa43517d23f2a9b6039616eebc8.
---
.../lib/sanitizer_common/sanitizer_getauxval.h | 14 --------------
.../sanitizer_common/sanitizer_linux_libcdep.cpp | 9 ++++++++-
2 files changed, 8 insertions(+), 15 deletions(-)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h b/compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h
index a22248d5007153..38439e44f611e6 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h
@@ -55,20 +55,6 @@ static inline decltype(AuxInfo::a_v) getauxval(decltype(AuxInfo::a_type) type) {
return 0;
}
-#elif SANITIZER_FREEBSD
-# include <sys/auxv.h>
-
-# define SANITIZER_USE_GETAUXVAL 1
-# define AT_EXECFN AT_EXECPATH
-
-static inline unsigned long getauxval(unsigned long type) {
- unsigned long buf = 0ul;
-
- if (elf_aux_info(static_cast<int>(type), &buf, sizeof(buf)))
- return 0ul;
- return buf;
-}
-
#endif
#endif // SANITIZER_GETAUXVAL_H
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
index b3f1fe91f16c58..cccbb4d256df2f 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -934,7 +934,14 @@ u64 MonotonicNanoTime() {
void ReExec() {
const char *pathname = "/proc/self/exe";
-# if SANITIZER_NETBSD
+# if SANITIZER_FREEBSD
+ for (const auto *aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) {
+ if (aux->a_type == AT_EXECPATH) {
+ pathname = static_cast<const char *>(aux->a_un.a_ptr);
+ break;
+ }
+ }
+# elif SANITIZER_NETBSD
static const int name[] = {
CTL_KERN,
KERN_PROC_ARGS,
More information about the llvm-commits
mailing list