This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] [Sanitizer Coverage] Use interception to access to sanitizer coverage's functions defined in the main executable (for MT on Windows.)
AbandonedPublic

Authored by mpividori on Jan 12 2017, 1:21 AM.

Details

Summary

When considering MT, asan is implemented as a static library: clang-rt_asan-arch.lib , which is linked to the main executable.

Also, a static library clang-rt_asan_dll_thunk-arch.lib, is linked for dlls. Mainly, it uses interception to get a pointer to asan's functions in the main executable.

In this diff, I update current implementation of the interception in clang-rt_asan_dll_thunk-arch.lib, to consider the special case of weak functions.
First we check if the client has redefined the function in the main executable (for example: __sanitizer_cov_trace_pc_guard). It we can't find it, then we look for the default implementation (__sanitizer_cov_trace_pc_guard__def). The default implementation is always available because clang-rt_asan-arch.lib is linked to the main executable.

After this diff, sanitizer coverage is fixed for MT on Windows. In particular, we could provide a version of libFuzzer for MT.
libFuzzer has its own custom implementation for all sanitizer coverage's weak functions, and they will be considered by all client's instrumented dlls.

Diff Detail

Repository
rL LLVM

Event Timeline

mpividori updated this revision to Diff 84088.Jan 12 2017, 1:21 AM
mpividori retitled this revision from to [compiler-rt] [Sanitizer Coverage] Use interception to access to sanitizer coverage's functions defined in the main executable (for MT on Windows.).
mpividori updated this object.
mpividori added reviewers: kcc, rnk, aizatsky, zturner.
mpividori set the repository for this revision to rL LLVM.
mpividori added a subscriber: llvm-commits.
mpividori abandoned this revision.Jan 25 2017, 4:55 PM

Abandon revision, because this was redesigned in: https://reviews.llvm.org/D29155