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

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 01:21:56 PST 2017


mpividori created this revision.
mpividori added reviewers: kcc, rnk, aizatsky, zturner.
mpividori added a subscriber: llvm-commits.
mpividori set the repository for this revision to rL LLVM.
Herald added subscribers: dberris, kubabrecka.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D28601

Files:
  lib/asan/asan_win_dll_thunk.cc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28601.84088.patch
Type: text/x-patch
Size: 12670 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170112/9d171def/attachment-0001.bin>


More information about the llvm-commits mailing list