diff options
author | van Hauser <vh@thc.org> | 2021-12-09 11:55:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-09 11:55:36 +0100 |
commit | 08ca4d54a55fe73e64a994c41a12af61f52e497e (patch) | |
tree | 2d0f060cf98afbe80f5bf810fd6b167a5152be81 /qemu_mode/libcompcov/libcompcov.so.c | |
parent | 773baf9391ff5f1793deb7968366819e7fa07adc (diff) | |
parent | 4c6d94ea5f854071277ed9729de2d4ef7d07cc84 (diff) | |
download | afl++-08ca4d54a55fe73e64a994c41a12af61f52e497e.tar.gz |
Merge pull request #1101 from AFLplusplus/dev
Dev
Diffstat (limited to 'qemu_mode/libcompcov/libcompcov.so.c')
-rw-r--r-- | qemu_mode/libcompcov/libcompcov.so.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/qemu_mode/libcompcov/libcompcov.so.c b/qemu_mode/libcompcov/libcompcov.so.c index 4fc84e62..eba3d80a 100644 --- a/qemu_mode/libcompcov/libcompcov.so.c +++ b/qemu_mode/libcompcov/libcompcov.so.c @@ -41,6 +41,13 @@ #error "Sorry, this library is Linux-specific for now!" #endif /* !__linux__ */ +#ifndef likely + #define likely(x) __builtin_expect((!!(x)), 1) +#endif +#ifndef unlikely + #define unlikely(x) __builtin_expect((!!(x)), 0) +#endif + /* Change this value to tune the compare coverage */ #define MAX_CMP_LENGTH 32 @@ -199,6 +206,7 @@ static u8 __compcov_is_in_bound(const void *ptr) { int strcmp(const char *str1, const char *str2) { + if (unlikely(!__libc_strcmp)) { __libc_strcmp = dlsym(RTLD_NEXT, "strcmp"); } void *retaddr = __builtin_return_address(0); if (__compcov_is_in_bound(retaddr) && @@ -227,6 +235,12 @@ int strcmp(const char *str1, const char *str2) { int strncmp(const char *str1, const char *str2, size_t len) { + if (unlikely(!__libc_strncmp)) { + + __libc_strncmp = dlsym(RTLD_NEXT, "strncmp"); + + } + void *retaddr = __builtin_return_address(0); if (__compcov_is_in_bound(retaddr) && @@ -256,6 +270,12 @@ int strncmp(const char *str1, const char *str2, size_t len) { int strcasecmp(const char *str1, const char *str2) { + if (unlikely(!__libc_strcasecmp)) { + + __libc_strncasecmp = dlsym(RTLD_NEXT, "strcasecmp"); + + } + void *retaddr = __builtin_return_address(0); if (__compcov_is_in_bound(retaddr) && @@ -286,6 +306,12 @@ int strcasecmp(const char *str1, const char *str2) { int strncasecmp(const char *str1, const char *str2, size_t len) { + if (unlikely(!__libc_strncasecmp)) { + + __libc_strncasecmp = dlsym(RTLD_NEXT, "strncasecmp"); + + } + void *retaddr = __builtin_return_address(0); if (__compcov_is_in_bound(retaddr) && @@ -317,6 +343,7 @@ int strncasecmp(const char *str1, const char *str2, size_t len) { int memcmp(const void *mem1, const void *mem2, size_t len) { + if (unlikely(!__libc_memcmp)) { __libc_memcmp = dlsym(RTLD_NEXT, "memcmp"); } void *retaddr = __builtin_return_address(0); if (__compcov_is_in_bound(retaddr) && |