[Spice-devel] [PATCH spice-streaming-agent 3/3] Export symbols in the binary to use by the plugins

Lukáš Hrázký lhrazky at redhat.com
Tue Dec 4 10:41:51 UTC 2018


This commits adds the -export-dynamic linker flag to export dynamic
symbols to be used by the streaming agent's plugins. It also adds the
-fvisibility=hidden compiler flag to hide all symbols by default (along
with -fvisibility-inline-hidden for C++ inline functions).

Then it adds the visibility("default") attribute to the namespace
containing the Error class, as that one needs to be exported and have
its typeinfo defined for exception catching to work.

Signed-off-by: Lukáš Hrázký <lhrazky at redhat.com>
---
 include/spice-streaming-agent/error.hpp | 2 +-
 src/Makefile.am                         | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/spice-streaming-agent/error.hpp b/include/spice-streaming-agent/error.hpp
index 3202d78..c0d4755 100644
--- a/include/spice-streaming-agent/error.hpp
+++ b/include/spice-streaming-agent/error.hpp
@@ -11,7 +11,7 @@
 #include <string>
 
 
-namespace spice {
+namespace spice __attribute__ ((visibility ("default"))) {
 namespace streaming_agent {
 
 class Error : public std::runtime_error
diff --git a/src/Makefile.am b/src/Makefile.am
index dc64c29..bae3f9d 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -22,10 +22,13 @@ AM_CPPFLAGS = \
 	$(NULL)
 
 AM_CFLAGS = \
+	-fvisibility=hidden \
 	$(WARN_CFLAGS) \
 	$(NULL)
 
 AM_CXXFLAGS = \
+	-fvisibility=hidden \
+	-fvisibility-inlines-hidden \
 	$(WARN_CXXFLAGS) \
 	$(NULL)
 
@@ -38,6 +41,7 @@ libstreaming_utils_a_SOURCES = \
 	$(NULL)
 
 spice_streaming_agent_LDFLAGS = \
+	-export-dynamic \
 	$(RELRO_LDFLAGS) \
 	$(NO_INDIRECT_LDFLAGS) \
 	$(NULL)
-- 
2.19.2



More information about the Spice-devel mailing list