forked from OSchip/llvm-project
[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
This commit is contained in:
parent
417e0072d6
commit
0033fcf72e
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue