[compiler-rt] r294409 - [sanitizer] Add weak hooks for Windows.
Marcos Pividori via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 7 22:31:56 PST 2017
Author: mpividori
Date: Wed Feb 8 00:31:56 2017
New Revision: 294409
URL: http://llvm.org/viewvc/llvm-project?rev=294409&view=rev
Log:
[sanitizer] Add weak hooks for Windows.
Add support for weak hooks on Windows, as we do on Linux and Darwin.
As we use the macro: `SANITIZER_INTERFACE_WEAK_DEF()` it was not necessary to
modify the header file: `sanitizer_common_interceptors.h`.
After this diff, many tests were fixed for libFuzzer.
Differential Revision: https://reviews.llvm.org/D29562
Modified:
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
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc?rev=294409&r1=294408&r2=294409&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_interface.inc Wed Feb 8 00:31:56 2017
@@ -16,6 +16,11 @@ INTERFACE_FUNCTION(__sanitizer_set_repor
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)
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h?rev=294409&r1=294408&r2=294409&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_interceptors.h Wed Feb 8 00:31:56 2017
@@ -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
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_weak_interception.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_weak_interception.cc?rev=294409&r1=294408&r2=294409&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_weak_interception.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_weak_interception.cc Wed Feb 8 00:31:56 2017
@@ -37,6 +37,18 @@ int interceptWhenPossible(uptr dll_funct
}
} // 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)
Modified: compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c?rev=294409&r1=294408&r2=294409&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/Darwin/interface_symbols_darwin.c Wed Feb 8 00:31:56 2017
@@ -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
Modified: compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c?rev=294409&r1=294408&r2=294409&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/interface_symbols_linux.c Wed Feb 8 00:31:56 2017
@@ -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
More information about the llvm-commits
mailing list