[PATCH] D28596: [compiler-rt] General definition for weak functions.
Marcos Pividori via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 20 11:18:31 PST 2017
mpividori updated this revision to Diff 85159.
mpividori added a comment.
I updated the diff to include requested changes. I define 2 macros: `WEAK_DEF()` and `WEAK_INTERFACE_DECL()`.
Tests pass on Linux.
Now, if we use `WEAK_DEF()` to define a weak function, it will work on Windows too, as long as:
- We only define it once. This means, only one definition when linking. (This is different to weak symbols in linux, where we can define it many times in different TU, and the linker will choose the first that it finds). If this generates problems in the future (this doesn't happen now, but could happen when combining many sanitizers on Windows, providing the default weak implementation twice), this could be solved modifying the macro, `WEAK_DEFAULT_NAME()` to generate different default names for different sanitizers, for example, for asan, define `fun__def__asan` and for lsan, define `fun__def__lsan`.
- We link statically.
When linking dynamically, weak functions are exported with the `__dll` prefix.
So, on the client side, we can define a weak alias: ` WIN_WEAK_ALIAS(fun , fun__dll) ` and use the default implementation or override it, redefining "fun". This is what I do in nexts diffs to fix Sanitizer Coverage for Windows. With the difference that I include the "windows weak aliases" in a static library which is included by clang driver (`clang-rt_asan_dynamic_runtime_thunk-arch.lib`), so they don't need to do anything different to make it work on Windows.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 18159 bytes
Desc: not available
More information about the llvm-commits