diff options
| author | Marcos Pividori <mpividori@google.com> | 2017-02-08 06:31:56 +0000 |
|---|---|---|
| committer | Marcos Pividori <mpividori@google.com> | 2017-02-08 06:31:56 +0000 |
| commit | 0033fcf72e6408a209d93ca92d5d89cb04e20744 (patch) | |
| tree | 7bdea7cfa8dc0681509cf9da7a9b8581c3b31c02 | |
| parent | 417e0072d6af58b735cbbbf9454001ae8915a5dd (diff) | |
| download | bcm5719-llvm-0033fcf72e6408a209d93ca92d5d89cb04e20744.tar.gz bcm5719-llvm-0033fcf72e6408a209d93ca92d5d89cb04e20744.zip | |
[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
llvm-svn: 294409
5 files changed, 22 insertions, 1 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc index b00d36bf4d3..4f0e940a131 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc @@ -16,6 +16,11 @@ INTERFACE_FUNCTION(__sanitizer_set_report_fd) 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) diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h index 6ab3d3d6dfa..50a8dc1ed99 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h +++ b/compiler-rt/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 diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win_weak_interception.cc b/compiler-rt/lib/sanitizer_common/sanitizer_win_weak_interception.cc index 3a26f87467e..36431939819 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win_weak_interception.cc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_win_weak_interception.cc @@ -37,6 +37,18 @@ int interceptWhenPossible(uptr dll_function, const char *real_function) { } } // 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) diff --git a/compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.c b/compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.c index 04f1a9b03c1..9450575b4ec 100644 --- a/compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.c +++ b/compiler-rt/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 diff --git a/compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.c b/compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.c index dae90151cda..33fdd5ca1d8 100644 --- a/compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.c +++ b/compiler-rt/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 |

