]> mj.ucw.cz Git - pciutils.git/commitdiff
Work around problems with symbol versioning in globally optimizing GCC
authorMartin Mares <mj@ucw.cz>
Sat, 1 Nov 2014 16:28:28 +0000 (17:28 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 1 Nov 2014 16:28:28 +0000 (17:28 +0100)
lib/access.c
lib/internal.h

index c23a2fd159723f62f9febcdb2f6bea26db600672..61b3530dc427dd31941357304c4af73d5c8d96d4 100644 (file)
@@ -153,7 +153,7 @@ pci_write_block(struct pci_dev *d, int pos, byte *buf, int len)
   return d->methods->write(d, pos, buf, len);
 }
 
-int
+int VERSIONED
 pci_fill_info_v32(struct pci_dev *d, int flags)
 {
   if (flags & PCI_FILL_RESCAN)
index 2c6d3ef58a16560200d6cb9baa9ac128c0b3ea57..18a59e2e02db7f02090d93bc3851ae934ff841ee 100644 (file)
 
 #ifdef PCI_SHARED_LIB
 #define PCI_ABI __attribute__((visibility("default")))
+// Functions, which are bound to externally visible symbols by the versioning
+// mechanism, have to be declared as VERSIONED. Otherwise, GCC with global
+// optimizations is happy to optimize them away, leading to linker failures.
+#define VERSIONED __attribute__((used))
 #ifdef __APPLE__
 #define STATIC_ALIAS(_decl, _for) _decl PCI_ABI { return _for; }
 #define DEFINE_ALIAS(_decl, _for) extern _decl __attribute__((alias(#_for)))
@@ -20,6 +24,7 @@
 #define SYMBOL_VERSION(_int, _ext)
 #endif
 #else
+#define VERSIONED
 #define STATIC_ALIAS(_decl, _for) _decl { return _for; }
 #define DEFINE_ALIAS(_decl, _for)
 #define SYMBOL_VERSION(_int, _ext)