[PATCH] D53777: [sanitizer] Move interceptor initialization check into real_clock_gettime

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 29 18:23:10 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT345556: [sanitizer] Move interceptor initialization check into real_clock_gettime (authored by vitalybuka, committed by ).
Herald added a subscriber: Sanitizers.

Changed prior to commit:
  https://reviews.llvm.org/D53777?vs=171347&id=171619#toc

Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D53777

Files:
  lib/sanitizer_common/sanitizer_common_interceptors.inc
  lib/sanitizer_common/sanitizer_linux_libcdep.cc


Index: lib/sanitizer_common/sanitizer_linux_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -782,15 +782,12 @@
 
 // MonotonicNanoTime is a timing function that can leverage the vDSO by calling
 // clock_gettime. real_clock_gettime only exists if clock_gettime is
-// intercepted, so define it weakly and use it if available. MonotonicNanoTime
-// might also be called when interceptors are not yet initialized, so check for
-// that as well.
+// intercepted, so define it weakly and use it if available.
 extern "C" SANITIZER_WEAK_ATTRIBUTE
 int real_clock_gettime(u32 clk_id, void *tp);
-namespace __interception { int (*real_clock_gettime)(u32 clk_id, void *tp); }
 u64 MonotonicNanoTime() {
   timespec ts;
-  if (CanUseVDSO() && __interception::real_clock_gettime) {
+  if (CanUseVDSO()) {
     if (&real_clock_gettime)
       real_clock_gettime(CLOCK_MONOTONIC, &ts);
     else
Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -2149,6 +2149,8 @@
 namespace __sanitizer {
 extern "C" {
 int real_clock_gettime(u32 clk_id, void *tp) {
+  if (COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED)
+    return internal_clock_gettime(clk_id, tp);
   return REAL(clock_gettime)(clk_id, tp);
 }
 }  // extern "C"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53777.171619.patch
Type: text/x-patch
Size: 1541 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181030/88f494f6/attachment.bin>


More information about the llvm-commits mailing list