[libFuzzer] add weak hooks for strcmp

llvm-svn: 244083
This commit is contained in:
Kostya Serebryany 2015-08-05 18:20:54 +00:00
parent 823e85c37e
commit dd8b3952b8
2 changed files with 11 additions and 0 deletions

View File

@ -124,10 +124,16 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_memcmp(const void *s1, const void *s2,
return 0; return 0;
} }
DECLARE_WEAK_INTERCEPTOR_HOOK(dfsan_weak_hook_strcmp, uptr caller_pc,
const char *s1, const char *s2,
dfsan_label s1_label, dfsan_label s2_label)
SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_strcmp(const char *s1, const char *s2, SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_strcmp(const char *s1, const char *s2,
dfsan_label s1_label, dfsan_label s1_label,
dfsan_label s2_label, dfsan_label s2_label,
dfsan_label *ret_label) { dfsan_label *ret_label) {
CALL_WEAK_INTERCEPTOR_HOOK(dfsan_weak_hook_strcmp, GET_CALLER_PC(), s1, s2,
s1_label, s2_label);
for (size_t i = 0;; ++i) { for (size_t i = 0;; ++i) {
if (s1[i] != s2[i] || s1[i] == 0 || s2[i] == 0) { if (s1[i] != s2[i] || s1[i] == 0 || s2[i] == 0) {
if (flags().strict_data_dependencies) { if (flags().strict_data_dependencies) {

View File

@ -204,9 +204,14 @@ static inline int CharCmpX(unsigned char c1, unsigned char c2) {
return (c1 == c2) ? 0 : (c1 < c2) ? -1 : 1; return (c1 == c2) ? 0 : (c1 < c2) ? -1 : 1;
} }
DECLARE_WEAK_INTERCEPTOR_HOOK(__sanitizer_weak_hook_strcmp, uptr called_pc,
const char *s1, const char *s2)
INTERCEPTOR(int, strcmp, const char *s1, const char *s2) { INTERCEPTOR(int, strcmp, const char *s1, const char *s2) {
void *ctx; void *ctx;
COMMON_INTERCEPTOR_ENTER(ctx, strcmp, s1, s2); COMMON_INTERCEPTOR_ENTER(ctx, strcmp, s1, s2);
CALL_WEAK_INTERCEPTOR_HOOK(__sanitizer_weak_hook_strcmp, GET_CALLER_PC(), s1,
s2);
unsigned char c1, c2; unsigned char c1, c2;
uptr i; uptr i;
for (i = 0;; i++) { for (i = 0;; i++) {