From 6e4adbf543f889d9bcdb296a86a7333ef4b6507b Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 1 Nov 2014 17:28:28 +0100 Subject: [PATCH] Work around problems with symbol versioning in globally optimizing GCC --- lib/access.c | 2 +- lib/internal.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/access.c b/lib/access.c index c23a2fd..61b3530 100644 --- a/lib/access.c +++ b/lib/access.c @@ -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) diff --git a/lib/internal.h b/lib/internal.h index 2c6d3ef..18a59e2 100644 --- a/lib/internal.h +++ b/lib/internal.h @@ -10,6 +10,10 @@ #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) -- 2.39.5