[PATCH] D28598: [compiler-rt] [Sanitizer Coverage] Provide access to the default implementation of weak functions from sanitizer coverage for MD on Windows.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 00:39:25 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 MD, asan is implemented as an external dll: `clang-rt_asan_dynamic-arch.dll`

Also, a static library `clang-rt_asan_dynamic_runtime_thunk-arch.lib`,  which provides some functionalities, is statically linked with both, instrumented dlls and executables,

As I mentioned in the previous revision: https://reviews.llvm.org/D28596 , for dll on windows, we are exposing the default implementation of weak functions.
This diff includes the header file with the internal interface of sanitizer coverage to `asan_win_dynamic_runtime_thunk.cc`.
`sanitizer_interface_internal.h` includes all the weak declarations, like:

  WEAK_INTERFACE(void, __sanitizer_cov_trace_cmp, ());
  WEAK_INTERFACE(void, __sanitizer_cov_trace_cmp1, ());
  WEAK_INTERFACE(void, __sanitizer_cov_trace_cmp2, ());
  WEAK_INTERFACE(void, __sanitizer_cov_trace_cmp4, ());
  .....

In Windows, the macro will be expanded to "weak aliases":

  __sanitizer_cov_trace_cmp = __sanitizer_cov_trace_cmp__def 
  __sanitizer_cov_trace_cmp1 = __sanitizer_cov_trace_cmp1__def 
  .....

So, `clang-rt_asan_dynamic_runtime_thunk-arch.lib` will include weak aliases to the default implementation imported from asan dll.
After this diff, we are able to compile code with MD and sanitizer coverage instrumentation.  When the instrumented object files are linked with `clang-rt_asan_dynamic_runtime_thunk-arch.lib` all the symbols will be resolved to the default implementation imported from asan dll.


Repository:
  rL LLVM

https://reviews.llvm.org/D28598

Files:
  lib/asan/asan_win_dynamic_runtime_thunk.cc


Index: lib/asan/asan_win_dynamic_runtime_thunk.cc
===================================================================
--- lib/asan/asan_win_dynamic_runtime_thunk.cc
+++ lib/asan/asan_win_dynamic_runtime_thunk.cc
@@ -25,6 +25,7 @@
 // simplifies the build procedure.
 #ifdef ASAN_DYNAMIC_RUNTIME_THUNK
 #include "sanitizer_common/sanitizer_win_defs.h"
+#include "sanitizer_common/sanitizer_interface_internal.h"
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28598.84080.patch
Type: text/x-patch
Size: 464 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170112/dae42e4c/attachment.bin>


More information about the llvm-commits mailing list