Skip to content

Commit 529b570

Browse files
authored
Revert "[compiler-rt] simplifying ::ReExec for freebsd. (llvm#79711)" (llvm#82933)
This reverts commit 691b12a.
1 parent 641d160 commit 529b570

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_getauxval.h

-14
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,6 @@ static inline decltype(AuxInfo::a_v) getauxval(decltype(AuxInfo::a_type) type) {
5555
return 0;
5656
}
5757

58-
#elif SANITIZER_FREEBSD
59-
# include <sys/auxv.h>
60-
61-
# define SANITIZER_USE_GETAUXVAL 1
62-
# define AT_EXECFN AT_EXECPATH
63-
64-
static inline unsigned long getauxval(unsigned long type) {
65-
unsigned long buf = 0ul;
66-
67-
if (elf_aux_info(static_cast<int>(type), &buf, sizeof(buf)))
68-
return 0ul;
69-
return buf;
70-
}
71-
7258
#endif
7359

7460
#endif // SANITIZER_GETAUXVAL_H

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,14 @@ u64 MonotonicNanoTime() {
934934
void ReExec() {
935935
const char *pathname = "/proc/self/exe";
936936

937-
# if SANITIZER_NETBSD
937+
# if SANITIZER_FREEBSD
938+
for (const auto *aux = __elf_aux_vector; aux->a_type != AT_NULL; aux++) {
939+
if (aux->a_type == AT_EXECPATH) {
940+
pathname = static_cast<const char *>(aux->a_un.a_ptr);
941+
break;
942+
}
943+
}
944+
# elif SANITIZER_NETBSD
938945
static const int name[] = {
939946
CTL_KERN,
940947
KERN_PROC_ARGS,

0 commit comments

Comments
 (0)