[compiler-rt] Revert "[compiler-rt] simplifying ::ReExec for freebsd. (#79711)" (PR #82933)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 25 12:58:48 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: David CARLIER (devnexen)
<details>
<summary>Changes</summary>
This reverts commit 691b12a2dcc12fa43517d23f2a9b6039616eebc8.
---
Full diff: https://github.com/llvm/llvm-project/pull/82933.diff
2 Files Affected:
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h (-14)
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp (+8-1)
``````````diff
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,
``````````
</details>
https://github.com/llvm/llvm-project/pull/82933
More information about the llvm-commits
mailing list