summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-09-25 19:50:39 +0000
committerMartin Storsjo <martin@martin.st>2018-09-25 19:50:39 +0000
commit47a959c926d5170ccd6c4fd953da6929099b58c5 (patch)
treee11bd4c7e78fbbc3e06ac27d90d7144fd7624cb2 /lib
parenta9d51f10a4e9568d0a281fbf6f0b271b53846e04 (diff)
downloadcompiler-rt-47a959c926d5170ccd6c4fd953da6929099b58c5.tar.gz
[Sanitizers] [MinGW] Produce undecorated symbols for /export: directives when in MinGW mode
In MinGW mode, the /export: directives in object files are interpreted differently; the symbols are not assumed to be decorated. Since the GNU linker doesn't support the /alternatename and /include directives, there's no such distinction for them in lld. This assumes that the resulting sanitizer libraries will be linked by lld. Differential Revision: https://reviews.llvm.org/D51882 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@343015 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/sanitizer_common/sanitizer_win_defs.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/sanitizer_common/sanitizer_win_defs.h b/lib/sanitizer_common/sanitizer_win_defs.h
index 19596cf9c..126263036 100644
--- a/lib/sanitizer_common/sanitizer_win_defs.h
+++ b/lib/sanitizer_common/sanitizer_win_defs.h
@@ -30,6 +30,16 @@
#define WIN_SYM_PREFIX
#endif
+// For MinGW, the /export: directives contain undecorated symbols, contrary to
+// link/lld-link. The GNU linker doesn't support /alternatename and /include
+// though, thus lld-link in MinGW mode interprets them in the same way as
+// in the default mode.
+#ifdef __MINGW32__
+#define WIN_EXPORT_PREFIX
+#else
+#define WIN_EXPORT_PREFIX WIN_SYM_PREFIX
+#endif
+
// Intermediate macro to ensure the parameter is expanded before stringified.
#define STRINGIFY_(A) #A
#define STRINGIFY(A) STRINGIFY_(A)
@@ -62,8 +72,8 @@
__pragma(comment(linker, "/include:" WIN_SYM_PREFIX STRINGIFY(Name)))
#define WIN_EXPORT(ExportedName, Name) \
- __pragma(comment(linker, "/export:" WIN_SYM_PREFIX STRINGIFY(ExportedName) \
- "=" WIN_SYM_PREFIX STRINGIFY(Name)))
+ __pragma(comment(linker, "/export:" WIN_EXPORT_PREFIX STRINGIFY(ExportedName) \
+ "=" WIN_EXPORT_PREFIX STRINGIFY(Name)))
// We cannot define weak functions on Windows, but we can use WIN_WEAK_ALIAS()
// which defines an alias to a default implementation, and only works when