diff options
author | Vitaly Buka <vitalybuka@google.com> | 2018-11-06 19:23:22 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2018-11-06 19:23:22 +0000 |
commit | bcee83da3ea5d80dffd3afd3843711b8043b9718 (patch) | |
tree | 0506e8d6b6e1ea1096b3cc3c7bdb27ec17fe1b0e /compiler-rt/lib/sanitizer_common | |
parent | ecb2eb46bcd9056a4e3f92c046c9b6a731deedee (diff) | |
download | bcm5719-llvm-bcee83da3ea5d80dffd3afd3843711b8043b9718.tar.gz bcm5719-llvm-bcee83da3ea5d80dffd3afd3843711b8043b9718.zip |
[sanitizer] Fix nolibc unittests broken by r346215
Subscribers: kubamracek, krytarowski, fedor.sergeev, llvm-commits
Differential Revision: https://reviews.llvm.org/D54163
llvm-svn: 346258
Diffstat (limited to 'compiler-rt/lib/sanitizer_common')
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_linux.cc | 31 | ||||
-rw-r--r-- | compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc | 35 |
2 files changed, 36 insertions, 30 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc index 592f424f719..7c3da0cb61c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cc @@ -19,7 +19,6 @@ #include "sanitizer_common.h" #include "sanitizer_flags.h" -#include "sanitizer_getauxval.h" #include "sanitizer_internal_defs.h" #include "sanitizer_libc.h" #include "sanitizer_linux.h" @@ -629,35 +628,7 @@ char **GetEnviron() { return envp; } -void ReExec() { - const char *pathname = "/proc/self/exe"; - -#if SANITIZER_NETBSD - static const int name[] = { - CTL_KERN, KERN_PROC_ARGS, -1, KERN_PROC_PATHNAME, - }; - char path[400]; - uptr len; - - len = sizeof(path); - if (internal_sysctl(name, ARRAY_SIZE(name), path, &len, NULL, 0) != -1) - pathname = path; -#elif SANITIZER_SOLARIS - pathname = getexecname(); - CHECK_NE(pathname, NULL); -#elif SANITIZER_USE_GETAUXVAL - // Calling execve with /proc/self/exe sets that as $EXEC_ORIGIN. Binaries that - // rely on that will fail to load shared libraries. Query AT_EXECFN instead. - pathname = reinterpret_cast<const char *>(getauxval(AT_EXECFN)); -#endif - - uptr rv = internal_execve(pathname, GetArgv(), GetEnviron()); - int rverrno; - CHECK_EQ(internal_iserror(rv, &rverrno), true); - Printf("execve failed, errno %d\n", rverrno); - Die(); -} -#endif +#endif // !SANITIZER_OPENBSD #if !SANITIZER_SOLARIS enum MutexState { diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc index 7859557c82d..84da23e3fad 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc @@ -23,6 +23,7 @@ #include "sanitizer_file.h" #include "sanitizer_flags.h" #include "sanitizer_freebsd.h" +#include "sanitizer_getauxval.h" #include "sanitizer_linux.h" #include "sanitizer_placement_new.h" #include "sanitizer_procmaps.h" @@ -806,6 +807,40 @@ u64 MonotonicNanoTime() { } #endif // SANITIZER_LINUX && !SANITIZER_GO +#if !SANITIZER_OPENBSD +void ReExec() { + const char *pathname = "/proc/self/exe"; + +#if SANITIZER_NETBSD + static const int name[] = { + CTL_KERN, + KERN_PROC_ARGS, + -1, + KERN_PROC_PATHNAME, + }; + char path[400]; + uptr len; + + len = sizeof(path); + if (internal_sysctl(name, ARRAY_SIZE(name), path, &len, NULL, 0) != -1) + pathname = path; +#elif SANITIZER_SOLARIS + pathname = getexecname(); + CHECK_NE(pathname, NULL); +#elif SANITIZER_USE_GETAUXVAL + // Calling execve with /proc/self/exe sets that as $EXEC_ORIGIN. Binaries that + // rely on that will fail to load shared libraries. Query AT_EXECFN instead. + pathname = reinterpret_cast<const char *>(getauxval(AT_EXECFN)); +#endif + + uptr rv = internal_execve(pathname, GetArgv(), GetEnviron()); + int rverrno; + CHECK_EQ(internal_iserror(rv, &rverrno), true); + Printf("execve failed, errno %d\n", rverrno); + Die(); +} +#endif // !SANITIZER_OPENBSD + } // namespace __sanitizer #endif |