[compiler-rt] 691b12a - [compiler-rt] simplifying ::ReExec for freebsd. (#79711)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 16 15:59:40 PST 2024
Author: David CARLIER
Date: 2024-02-16T23:59:38Z
New Revision: 691b12a2dcc12fa43517d23f2a9b6039616eebc8
URL: https://github.com/llvm/llvm-project/commit/691b12a2dcc12fa43517d23f2a9b6039616eebc8
DIFF: https://github.com/llvm/llvm-project/commit/691b12a2dcc12fa43517d23f2a9b6039616eebc8.diff
LOG: [compiler-rt] simplifying ::ReExec for freebsd. (#79711)
taking the getauxval route since elf_aux_info is available since FBSD
12.
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 38439e44f611e6..a22248d5007153 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h
@@ -55,6 +55,20 @@ 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 cccbb4d256df2f..b3f1fe91f16c58 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp
@@ -934,14 +934,7 @@ u64 MonotonicNanoTime() {
void ReExec() {
const char *pathname = "/proc/self/exe";
-# 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
+# if SANITIZER_NETBSD
static const int name[] = {
CTL_KERN,
KERN_PROC_ARGS,
More information about the llvm-commits
mailing list