add __sanitizer_weak_hook_ support

This commit is contained in:
vanhauser-thc
2024-12-12 15:26:39 +01:00
parent 50e2f9d46c
commit 9160805f4a
3 changed files with 87 additions and 0 deletions

View File

@ -6,6 +6,9 @@
### Version ++4.31a (dev)
- loose file and shared memory permissions on Android and iPhone
- afl-cc:
- added __sanitizer_weak_hook_* functions (in case that is helpful in
weird setups)
### Version ++4.30c (release)

View File

@ -2670,6 +2670,89 @@ void __cmplog_rtn_llvm_stdstring_stdstring(u8 *stdstring1, u8 *stdstring2) {
}
/* llvm weak hooks */
void __sanitizer_weak_hook_memcmp(void *pc, const void *s1, const void *s2,
size_t n, int result) {
__cmplog_rtn_hook_n((u8 *)s1, (u8 *)s2, (u64)n);
(void)pc;
(void)result;
}
void __sanitizer_weak_hook_memmem(void *pc, const void *s1, size_t len1,
const void *s2, size_t len2, void *result) {
__cmplog_rtn_hook_n((u8 *)s1, (u8 *)s2, len1 < len2 ? (u64)len1 : (u64)len2);
(void)pc;
(void)result;
}
void __sanitizer_weak_hook_strncasecmp(void *pc, const void *s1, const void *s2,
size_t n, int result) {
__cmplog_rtn_hook_strn((u8 *)s1, (u8 *)s2, (u64)n);
(void)pc;
(void)result;
}
void __sanitizer_weak_hook_strncasestr(void *pc, const void *s1, const void *s2,
size_t n, char *result) {
__cmplog_rtn_hook_strn((u8 *)s1, (u8 *)s2, (u64)n);
(void)pc;
(void)result;
}
void __sanitizer_weak_hook_strncmp(void *pc, const void *s1, const void *s2,
size_t n, int result) {
__cmplog_rtn_hook_strn((u8 *)s1, (u8 *)s2, (u64)n);
(void)pc;
(void)result;
}
void __sanitizer_weak_hook_strcasecmp(void *pc, const void *s1, const void *s2,
int result) {
__cmplog_rtn_hook_str((u8 *)s1, (u8 *)s2);
(void)pc;
(void)result;
}
void __sanitizer_weak_hook_strcasestr(void *pc, const void *s1, const void *s2,
size_t n, char *result) {
__cmplog_rtn_hook_str((u8 *)s1, (u8 *)s2);
(void)pc;
(void)result;
}
void __sanitizer_weak_hook_strcmp(void *pc, const void *s1, const void *s2,
int result) {
__cmplog_rtn_hook_str((u8 *)s1, (u8 *)s2);
(void)pc;
(void)result;
}
void __sanitizer_weak_hook_strstr(void *pc, const void *s1, const void *s2,
char *result) {
__cmplog_rtn_hook_str((u8 *)s1, (u8 *)s2);
(void)pc;
(void)result;
}
/* COVERAGE manipulation features */
// this variable is then used in the shm setup to create an additional map

View File

@ -2614,6 +2614,7 @@ void add_misc_params(aflcc_state_t *aflcc) {
insert_param(aflcc, "-fno-builtin-strcasecmp");
insert_param(aflcc, "-fno-builtin-strncasecmp");
insert_param(aflcc, "-fno-builtin-memcmp");
insert_param(aflcc, "-fno-builtin-memmem");
insert_param(aflcc, "-fno-builtin-bcmp");
insert_param(aflcc, "-fno-builtin-strstr");
insert_param(aflcc, "-fno-builtin-strcasestr");