From 45205a28343a8953b55a9bebb3b30104dbb4ddf5 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Tue, 25 Sep 2018 19:50:39 +0000 Subject: [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 llvm-svn: 343015 --- compiler-rt/lib/sanitizer_common/sanitizer_win_defs.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'compiler-rt') diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_win_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_win_defs.h index 19596cf9c8a..1262630364a 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_win_defs.h +++ b/compiler-rt/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 -- cgit v1.2.3