When considering MD, asan is implemented as an external dll: clang-rt_asan_dynamic-arch.dll
We provide default implementation for sanitizer coverage's weak functions like: __sanitizer_cov_trace_pc_guard, __sanitizer_cov_trace_cmp , etc, imported from asan dll as: __sanitizer_cov_trace_pc_guard__dll, __sanitizer_cov_trace_cmp__dll , etc.
But clients can redefine and export a new definition in the main executable, like:
extern "C" __declspec(dllexport) void __sanitizer_cov_trace_pc_guard(u32* guard) { // Different implementation provided by the client. }
However, other client's dlls, will continue using the default implementation imported from asan dll: __sanitizer_cov_trace_pc_guard__dll.
So, with the implementation in this diff, when asan dll is initialized, it will check if the main executable exports the definition of some weak function (for example __sanitizer_cov_trace_pc_guard). If it finds that function, then it will override the default function in the dll (__sanitizer_cov_trace_pc_guard__dll) with that pointer. So, all the client's dlls with instrumentation that import __sanitizer_cov_trace_pc_guard__dll() from asan dll, will be using the function provided by the main executable.
After this diff, sanitizer coverage is fixed for MD on Windows. In particular libFuzzer can provide custom implementation for all sanitizer coverage's weak functions, and they will be considered by asan dll.
Add asan_win_weak_interception.cc to ASAN_SOURCES instead.