Skip to contentSkip to conversation

Use __EXPORTED rather than EXPORT_SYMBOL

PATCH Applied Kevin Cernekee 2 participants 4 messages Jan 4, 2017 – Jan 16, 2017 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use __EXPORTED rather than EXPORT_SYMBOL

clang is sensitive to the ordering of __attribute__((visibility("default"))) relative to the function body. gcc is not. So if we try to re-declare an existing function with default visibility, clang prints a warning and generates a broken .so file in which nfct_timeout_* are not exported to library callers.

Move the attribute up into the function definition to make clang happy.

---
 doxygen.cfg.in               |  2 +-
 src/internal.h               |  5 ++---
 src/libnetfilter_cttimeout.c | 44 +++++++++++++++++---------------------------
 3 files changed, 20 insertions(+), 31 deletions(-)
doxygen.cfg.in +1 -1
index 8e5d4495eb41..09c3ce00e422 100644
@@ -72,7 +72,7 @@ RECURSIVE              = YES
 EXCLUDE                = 
 EXCLUDE_SYMLINKS       = NO
 EXCLUDE_PATTERNS       = */.git/* .*.d
-EXCLUDE_SYMBOLS        = EXPORT_SYMBOL nfct_timeout _container_policy_cb
+EXCLUDE_SYMBOLS        = nfct_timeout _container_policy_cb
 EXAMPLE_PATH           = 
 EXAMPLE_PATTERNS       = 
 EXAMPLE_RECURSIVE      = NO
src/internal.h +2 -3
index 3a88d1a1f7d8..5d781718ddad 100644
@@ -3,10 +3,9 @@
 
 #include "config.h"
 #ifdef HAVE_VISIBILITY_HIDDEN
-#	define __visible	__attribute__((visibility("default")))
-#	define EXPORT_SYMBOL(x)	typeof(x) (x) __visible
+#	define __EXPORTED	__attribute__((visibility("default")))
 #else
-#	define EXPORT_SYMBOL
+#	define __EXPORTED
 #endif
 
 #endif
src/libnetfilter_cttimeout.c +17 -27

188 lines not on this page · raw message

Signature · 1 line
2.11.0.390.gc69c2f50cf-goog
#1 lore raw

PATCH 1/1 Use __EXPORTED rather than EXPORT_SYMBOL

clang is sensitive to the ordering of __attribute__((visibility("default"))) relative to the function body. gcc is not. So if we try to re-declare an existing function with default visibility, clang prints a warning and generates a broken .so file in which nfct_helper_* are not exported to library callers.

Move the attribute up into the function definition to make clang happy.

---
 doxygen.cfg.in              |  2 +-
 src/internal.h              |  5 ++-
 src/libnetfilter_cthelper.c | 83 ++++++++++++++++++---------------------------
 3 files changed, 36 insertions(+), 54 deletions(-)
doxygen.cfg.in +1 -1
index cac9b0510b4d..190b7cd6e716 100644
@@ -72,7 +72,7 @@ RECURSIVE              = YES
 EXCLUDE                = 
 EXCLUDE_SYMLINKS       = NO
 EXCLUDE_PATTERNS       = */.git/* .*.d
-EXCLUDE_SYMBOLS        = EXPORT_SYMBOL
+EXCLUDE_SYMBOLS        = 
 EXAMPLE_PATH           = 
 EXAMPLE_PATTERNS       = 
 EXAMPLE_RECURSIVE      = NO
src/internal.h +2 -3
index 3a88d1a1f7d8..5d781718ddad 100644
@@ -3,10 +3,9 @@
 
 #include "config.h"
 #ifdef HAVE_VISIBILITY_HIDDEN
-#	define __visible	__attribute__((visibility("default")))
-#	define EXPORT_SYMBOL(x)	typeof(x) (x) __visible
+#	define __EXPORTED	__attribute__((visibility("default")))
 #else
-#	define EXPORT_SYMBOL
+#	define __EXPORTED
 #endif
 
 #endif
src/libnetfilter_cthelper.c +33 -50

302 lines not on this page · raw message

Signature · 1 line
2.11.0.390.gc69c2f50cf-goog
#2 lore raw
Quoted 8 lines · Kevin Cernekee

clang is sensitive to the ordering of __attribute__((visibility("default"))) relative to the function body. gcc is not. So if we try to re-declare an existing function with default visibility, clang prints a warning and generates a broken .so file in which nfct_helper_* are not exported to library callers.

Move the attribute up into the function definition to make clang happy.

Also applied, thanks.

maintainer Applied
#3 lore raw
In reply to Kevin Cernekee
Quoted 8 lines · Kevin Cernekee

clang is sensitive to the ordering of __attribute__((visibility("default"))) relative to the function body. gcc is not. So if we try to re-declare an existing function with default visibility, clang prints a warning and generates a broken .so file in which nfct_timeout_* are not exported to library callers.

Move the attribute up into the function definition to make clang happy.

Applied, thanks.