Skip to content

Commit

Permalink
Hide unnecessary exported library symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
afrantzis committed Mar 13, 2017
1 parent a69bc9d commit 13d165d
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 0 deletions.
19 changes: 19 additions & 0 deletions configure.ac
Expand Up @@ -93,6 +93,25 @@ ACX_CHECK_SUNCC
# to the link
AC_PROG_LIBTOOL

# Check whether the linker supports version scripts
AC_MSG_CHECKING([whether the linker supports version scripts])
save_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
cat > conftest.map <<EOF
{
global:
main;
local:
*;
};
EOF
AC_LINK_IFELSE(
[AC_LANG_SOURCE([int main() { return 0; }])],
[have_ld_version_script=yes; AC_MSG_RESULT(yes)],
[have_ld_version_script=no; AC_MSG_RESULT(no)])
LDFLAGS=$save_LDFLAGS
AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT], [test "$have_ld_version_script" == "yes"])

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
Expand Down
15 changes: 15 additions & 0 deletions src/Makefile.am
Expand Up @@ -180,6 +180,10 @@ lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la

libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)
libprotobuf_lite_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
if HAVE_LD_VERSION_SCRIPT
libprotobuf_lite_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf-lite.map
EXTRA_libprotobuf_lite_la_DEPENDENCIES = libprotobuf-lite.map
endif
libprotobuf_lite_la_SOURCES = \
google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
google/protobuf/stubs/atomicops_internals_x86_msvc.cc \
Expand Down Expand Up @@ -221,6 +225,10 @@ libprotobuf_lite_la_SOURCES = \

libprotobuf_la_LIBADD = $(PTHREAD_LIBS)
libprotobuf_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
if HAVE_LD_VERSION_SCRIPT
libprotobuf_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf.map
EXTRA_libprotobuf_la_DEPENDENCIES = libprotobuf.map
endif
libprotobuf_la_SOURCES = \
$(libprotobuf_lite_la_SOURCES) \
google/protobuf/any.pb.cc \
Expand Down Expand Up @@ -305,6 +313,10 @@ nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES)

libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la
libprotoc_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
if HAVE_LD_VERSION_SCRIPT
libprotoc_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotoc.map
EXTRA_libprotoc_la_DEPENDENCIES = libprotoc.map
endif
libprotoc_la_SOURCES = \
google/protobuf/compiler/code_generator.cc \
google/protobuf/compiler/command_line_interface.cc \
Expand Down Expand Up @@ -580,6 +592,9 @@ EXTRA_DIST = \
google/protobuf/compiler/ruby/ruby_generated_code_pb.rb \
google/protobuf/compiler/package_info.h \
google/protobuf/compiler/zip_output_unittest.sh \
libprotobuf-lite.map \
libprotobuf.map \
libprotoc.map \
README.md

protoc_lite_outputs = \
Expand Down
9 changes: 9 additions & 0 deletions src/libprotobuf-lite.map
@@ -0,0 +1,9 @@
{
global:
extern "C++" {
*google*;
};

local:
*;
};
9 changes: 9 additions & 0 deletions src/libprotobuf.map
@@ -0,0 +1,9 @@
{
global:
extern "C++" {
*google*;
};

local:
*;
};
9 changes: 9 additions & 0 deletions src/libprotoc.map
@@ -0,0 +1,9 @@
{
global:
extern "C++" {
*google*;
};

local:
*;
};

0 comments on commit 13d165d

Please sign in to comment.