diff options
author | Pali Rohár <pali@kernel.org> | 2024-02-24 16:12:26 +0100 |
---|---|---|
committer | Martin Mares <mj@ucw.cz> | 2024-02-24 20:47:05 +0100 |
commit | 0e48f9b7af7c4e9a76092db62a1a4d777f59c170 (patch) | |
tree | 5242300d0c0b3e4d7b734cb6869017b1e97af9a0 | |
parent | 26d05a62e4babea0fa364fd1690f8b9f5792bfc1 (diff) | |
download | pciutils-0e48f9b7af7c4e9a76092db62a1a4d777f59c170.tar.gz |
libpci: Define STATIC_ALIAS for DLL Windows builds
Windows builds for versioned symbols use inline asm .set directive which in
some cases makes x86-64 LTO compiler to drop the referenced value. Define
STATIC_ALIAS macro with VERSIONED_ABI (used) attribute which forces LTO
compiler to not drop the symbol from the final DLL library.
-rw-r--r-- | lib/internal.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/internal.h b/lib/internal.h index 549f94c..68e9fa0 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -24,14 +24,15 @@ #define DEFINE_ALIAS(_decl, _for) #define SYMBOL_VERSION(_int, _ext) #else -#define STATIC_ALIAS(_decl, _for) #define DEFINE_ALIAS(_decl, _for) extern _decl __attribute__((alias(#_for))) VERSIONED_ABI #ifdef _WIN32 +#define STATIC_ALIAS(_decl, _for) VERSIONED_ABI _decl { return _for; } /* GCC does not support asm .symver directive for Windows targets, so define new external global function symbol as alias to internal symbol */ #define SYMBOL_VERSION(_int, _ext) asm(".globl\t" PCI_STRINGIFY(__MINGW_USYMBOL(_ext)) "\n\t" \ ".def\t" PCI_STRINGIFY(__MINGW_USYMBOL(_ext)) ";\t.scl\t2;\t.type\t32;\t.endef\n\t" \ ".set\t" PCI_STRINGIFY(__MINGW_USYMBOL(_ext)) "," PCI_STRINGIFY(__MINGW_USYMBOL(_int))) #else +#define STATIC_ALIAS(_decl, _for) #define SYMBOL_VERSION(_int, _ext) asm(".symver " #_int "," #_ext) #endif #endif |