[compiler-rt] r343015 - [Sanitizers] [MinGW] Produce undecorated symbols for /export: directives when in MinGW mode

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 25 12:50:39 PDT 2018


Author: mstorsjo
Date: Tue Sep 25 12:50:39 2018
New Revision: 343015

URL: http://llvm.org/viewvc/llvm-project?rev=343015&view=rev
Log:
[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

Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_defs.h

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_defs.h?rev=343015&r1=343014&r2=343015&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_defs.h (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_win_defs.h Tue Sep 25 12:50:39 2018
@@ -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




More information about the llvm-commits mailing list