[PATCH] D29562: [sanitizer] Add weak hooks for Windows,

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 22:43:26 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL294409: [sanitizer] Add weak hooks for Windows. (authored by mpividori).

Changed prior to commit:
  https://reviews.llvm.org/D29562?vs=87138&id=87592#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29562

Files:
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
  compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_weak_interception.cc
  compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
  compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c


Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_weak_interception.cc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_weak_interception.cc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_weak_interception.cc
@@ -37,6 +37,18 @@
 }
 } // namespace __sanitizer
 
+// Declare weak hooks.
+extern "C" {
+void __sanitizer_weak_hook_memcmp(uptr called_pc, const void *s1,
+                                  const void *s2, uptr n, int result);
+void __sanitizer_weak_hook_strcmp(uptr called_pc, const char *s1,
+                                  const char *s2, int result);
+void __sanitizer_weak_hook_strncmp(uptr called_pc, const char *s1,
+                                   const char *s2, uptr n, int result);
+void __sanitizer_weak_hook_strstr(uptr called_pc, const char *s1,
+                                  const char *s2, char *result);
+}
+
 // Include Sanitizer Common interface.
 #define INTERFACE_FUNCTION(Name)
 #define INTERFACE_WEAK_FUNCTION(Name) INTERCEPT_SANITIZER_WEAK_FUNCTION(Name)
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
@@ -17,9 +17,11 @@
 #include "sanitizer_internal_defs.h"
 
 #if !SANITIZER_WINDOWS
+# define SI_WINDOWS 0
 # define SI_NOT_WINDOWS 1
 # include "sanitizer_platform_limits_posix.h"
 #else
+# define SI_WINDOWS 1
 # define SI_NOT_WINDOWS 0
 #endif
 
@@ -310,7 +312,7 @@
 #define SANITIZER_INTERCEPT_CTERMID SI_LINUX || SI_MAC || SI_FREEBSD
 #define SANITIZER_INTERCEPT_CTERMID_R SI_MAC || SI_FREEBSD
 
-#define SANITIZER_INTERCEPTOR_HOOKS SI_LINUX || SI_MAC
+#define SANITIZER_INTERCEPTOR_HOOKS SI_LINUX || SI_MAC || SI_WINDOWS
 #define SANITIZER_INTERCEPT_RECV_RECVFROM SI_NOT_WINDOWS
 #define SANITIZER_INTERCEPT_SEND_SENDTO SI_NOT_WINDOWS
 #define SANITIZER_INTERCEPT_EVENTFD_READ_WRITE SI_LINUX
Index: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc
===================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc
@@ -16,6 +16,11 @@
 INTERFACE_FUNCTION(__sanitizer_verify_contiguous_container)
 INTERFACE_WEAK_FUNCTION(__sanitizer_report_error_summary)
 INTERFACE_WEAK_FUNCTION(__sanitizer_sandbox_on_notify)
+// Sanitizer weak hooks
+INTERFACE_WEAK_FUNCTION(__sanitizer_weak_hook_memcmp)
+INTERFACE_WEAK_FUNCTION(__sanitizer_weak_hook_strcmp)
+INTERFACE_WEAK_FUNCTION(__sanitizer_weak_hook_strncmp)
+INTERFACE_WEAK_FUNCTION(__sanitizer_weak_hook_strstr)
 // Stacktrace interface.
 INTERFACE_FUNCTION(__sanitizer_get_module_and_offset_for_pc)
 INTERFACE_FUNCTION(__sanitizer_symbolize_global)
Index: compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
@@ -21,6 +21,7 @@
 // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc    \
 // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface_posix.inc \
 // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc  \
+// RUN:  | grep -v "__sanitizer_weak_hook"                                     \
 // RUN:  | sed -e "s/.*(//" -e "s/).*//" > %t.imports
 //
 // RUN: cat %t.imports | sort | uniq > %t.imports-sorted
Index: compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
+++ compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
@@ -15,6 +15,7 @@
 // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface.inc    \
 // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_common_interface_posix.inc \
 // RUN:  %p/../../../../lib/sanitizer_common/sanitizer_coverage_interface.inc  \
+// RUN:  | grep -v "__sanitizer_weak_hook"                                     \
 // RUN:  | sed -e "s/.*(//" -e "s/).*//" > %t.imports
 //
 // RUN: cat %t.imports | sort | uniq > %t.imports-sorted


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29562.87592.patch
Type: text/x-patch
Size: 4491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170208/a404a6c4/attachment.bin>


More information about the llvm-commits mailing list