[PATCH] D83494: [libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked.
Matt Morehouse via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 17 14:24:47 PDT 2020
morehouse added inline comments.
================
Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:62
+
+static int internal_strncmp(const char *s1, const char *s2, uintptr_t n) {
+ for (uintptr_t i = 0; i < n; i++) {
----------------
Can we use `size_t` instead of `uintptr_t`?
================
Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:77
+static int internal_memcmp(const void *s1, const void *s2, uintptr_t n) {
+ const char *t1 = (const char *)s1;
+ const char *t2 = (const char *)s2;
----------------
Can we use `uint8_t` and `static_cast`?
================
Comment at: compiler-rt/lib/fuzzer/FuzzerInterceptors.cpp:119
+ return internal_memcmp(s1, s2, n);
+ ensureFuzzerInited();
+ int result = REAL(memcmp)(s1, s2, n);
----------------
I think `ensureFuzzerInited` is no longer useful here.
================
Comment at: compiler-rt/test/fuzzer/CustomAllocatorTest.cpp:15
+ return 0;
+}
----------------
Do we need this file? Can we use `EmptyTest.cpp` instead?
================
Comment at: compiler-rt/test/fuzzer/custom-allocator.test:2
+UNSUPPORTED: freebsd
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address %S/CustomAllocatorTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorTest
----------------
Why do we need each of these flags?
================
Comment at: compiler-rt/test/fuzzer/memcmp.test:9
+RUN: %cpp_compiler -fno-sanitize=all -fno-builtin %S/CustomAllocator.cpp -fPIC %ld_flags_rpath_so1 -O0 -shared -o %dynamiclib1
+RUN: %cpp_compiler -fno-sanitize=address -fno-builtin-memcmp %S/MemcmpTest.cpp %ld_flags_rpath_exe1 -o %t-NoAsanCustomAllocatorMemcmpTest
+RUN: not %run %t-NoAsanCustomAllocatorMemcmpTest -seed=1 -runs=10000000 2>&1 | FileCheck %s
----------------
Why is the custom allocator test here useful?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D83494/new/
https://reviews.llvm.org/D83494
More information about the cfe-commits
mailing list