[PATCH] D40657: [sanitizer] Introduce a vDSO aware time function, and use it in the allocator
Roland McGrath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 30 11:47:13 PST 2017
mcgrathr added a comment.
Fuchsia bit LGTM. Linux bit highly suspect.
================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:468
+extern "C" SANITIZER_WEAK_ATTRIBUTE
+int __vdso_clock_gettime(clockid_t clock, struct timespec* ts);
+bool CanUseVDSO() {
----------------
Don't rely on these libc internals. Just look up the real `__vdso_clock_gettime` symbol in the vDSO itself. On some machines glibc defines a `__vdso_clock_gettime` symbol also, which is a mangled pointer, not a function as declared here. But that's purely a libc implementation detail (it's a `GLIBC_PRIVATE` symbol) and you shouldn't pay attention to that at all. On x86, there is no such symbol in libc and so `__vdso_clock_gettime` will reach the actual vDSO function. But since the name is sometimes overloaded, what you probably want to do is find the vDSO with `dlopen` or suchlike and then use `dlsym` to look up `__vdso_clock_gettime` directly in the vDSO.
https://reviews.llvm.org/D40657
More information about the llvm-commits
mailing list