1. Jul 24, 2020
  2. Jul 23, 2020
    • Dokyung Song's avatar
      Recommit "[libFuzzer] Link libFuzzer's own interceptors when other compiler... · 831ae45e
      Dokyung Song authored
      Recommit "[libFuzzer] Link libFuzzer's own interceptors when other compiler runtimes are not linked."
      
      Summary: libFuzzer intercepts certain library functions such as memcmp/strcmp by defining weak hooks. Weak hooks, however, are called only when other runtimes such as ASan is linked. This patch defines libFuzzer's own interceptors, which is linked into the libFuzzer executable when other runtimes are not linked, i.e., when -fsanitize=fuzzer is given, but not others.
      
      The patch once landed but was reverted in 8ef9e2bf due to an assertion failure caused by calling an intercepted function, strncmp, while initializing the interceptors in fuzzerInit(). This issue is now fixed by calling libFuzzer's own implementation of library functions (i.e., internal_*) when the fuzzer has not been initialized yet, instead of recursively calling fuzzerInit() again.
      
      Reviewers: kcc, morehouse, hctim
      
      Subscribers: #sanitizers, krytarowski, mgorny, cfe-commits
      
      Tags: #clang, #sanitizers
      
      Differential Revision: https://reviews.llvm.org/D83494
      831ae45e