[compiler-rt] 529b570 - Revert "[compiler-rt] simplifying ::ReExec for freebsd. (#79711)" (#82933)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 25 13:10:04 PST 2024
Author: David CARLIER
Date: 2024-02-25T21:10:01Z
New Revision: 529b5705db2ccefeee2c9b8cb5144e1f5a6420de
URL: https://github.com/llvm/llvm-project/commit/529b5705db2ccefeee2c9b8cb5144e1f5a6420de
DIFF: https://github.com/llvm/llvm-project/commit/529b5705db2ccefeee2c9b8cb5144e1f5a6420de.diff
LOG: Revert "[compiler-rt] simplifying ::ReExec for freebsd. (#79711)" (#82933)
This reverts commit 691b12a2dcc12fa43517d23f2a9b6039616eebc8.
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h
compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
Removed:
################################################################################
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