fuzz-introspector icon indicating copy to clipboard operation
fuzz-introspector copied to clipboard

Make a linker wrapper and build compiler plugin out of tree

Open DavidKorczynski opened this issue 3 years ago • 0 comments

We currently have to build the plugin as part of clang rather than an out-of-tree plugin. This problem is described here in the code: https://github.com/ossf/fuzz-introspector/blob/9c0ea223b5148b71bc774842404a2317ba70a778/llvm/lib/Transforms/FuzzIntrospector/FuzzIntrospector.cpp#L1002-L1005

Specifically, we run into this issue: https://reviews.llvm.org/D77704

We can overcome this by using a custom linker that will call opt manually as part of the linking process. Something similar is used in OSS-Fuzz, for example, to ensure coverage instrumentation doesn't break in Rust (https://github.com/google/oss-fuzz/blob/master/projects/oak/rustc.py)

Another place where such an approach is used is AFL++, where the lto code also uses a custom linker, for more details see here: https://github.com/AFLplusplus/AFLplusplus/blob/08ca4d54a55fe73e64a994c41a12af61f52e497e/instrumentation/README.lto.md#history

Or, try and get the llvm PR pushed

DavidKorczynski avatar Mar 03 '22 21:03 DavidKorczynski