Skip to content

Commit 13d165d

Browse files
committed
Hide unnecessary exported library symbols
1 parent a69bc9d commit 13d165d

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed

configure.ac

+19
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ ACX_CHECK_SUNCC
9393
# to the link
9494
AC_PROG_LIBTOOL
9595

96+
# Check whether the linker supports version scripts
97+
AC_MSG_CHECKING([whether the linker supports version scripts])
98+
save_LDFLAGS=$LDFLAGS
99+
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
100+
cat > conftest.map <<EOF
101+
{
102+
global:
103+
main;
104+
local:
105+
*;
106+
};
107+
EOF
108+
AC_LINK_IFELSE(
109+
[AC_LANG_SOURCE([int main() { return 0; }])],
110+
[have_ld_version_script=yes; AC_MSG_RESULT(yes)],
111+
[have_ld_version_script=no; AC_MSG_RESULT(no)])
112+
LDFLAGS=$save_LDFLAGS
113+
AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT], [test "$have_ld_version_script" == "yes"])
114+
96115
# Checks for header files.
97116
AC_HEADER_STDC
98117
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])

src/Makefile.am

+15
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,10 @@ lib_LTLIBRARIES = libprotobuf-lite.la libprotobuf.la libprotoc.la
180180

181181
libprotobuf_lite_la_LIBADD = $(PTHREAD_LIBS)
182182
libprotobuf_lite_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
183+
if HAVE_LD_VERSION_SCRIPT
184+
libprotobuf_lite_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf-lite.map
185+
EXTRA_libprotobuf_lite_la_DEPENDENCIES = libprotobuf-lite.map
186+
endif
183187
libprotobuf_lite_la_SOURCES = \
184188
google/protobuf/stubs/atomicops_internals_x86_gcc.cc \
185189
google/protobuf/stubs/atomicops_internals_x86_msvc.cc \
@@ -221,6 +225,10 @@ libprotobuf_lite_la_SOURCES = \
221225

222226
libprotobuf_la_LIBADD = $(PTHREAD_LIBS)
223227
libprotobuf_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
228+
if HAVE_LD_VERSION_SCRIPT
229+
libprotobuf_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotobuf.map
230+
EXTRA_libprotobuf_la_DEPENDENCIES = libprotobuf.map
231+
endif
224232
libprotobuf_la_SOURCES = \
225233
$(libprotobuf_lite_la_SOURCES) \
226234
google/protobuf/any.pb.cc \
@@ -305,6 +313,10 @@ nodist_libprotobuf_la_SOURCES = $(nodist_libprotobuf_lite_la_SOURCES)
305313

306314
libprotoc_la_LIBADD = $(PTHREAD_LIBS) libprotobuf.la
307315
libprotoc_la_LDFLAGS = -version-info 12:0:0 -export-dynamic -no-undefined
316+
if HAVE_LD_VERSION_SCRIPT
317+
libprotoc_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libprotoc.map
318+
EXTRA_libprotoc_la_DEPENDENCIES = libprotoc.map
319+
endif
308320
libprotoc_la_SOURCES = \
309321
google/protobuf/compiler/code_generator.cc \
310322
google/protobuf/compiler/command_line_interface.cc \
@@ -580,6 +592,9 @@ EXTRA_DIST = \
580592
google/protobuf/compiler/ruby/ruby_generated_code_pb.rb \
581593
google/protobuf/compiler/package_info.h \
582594
google/protobuf/compiler/zip_output_unittest.sh \
595+
libprotobuf-lite.map \
596+
libprotobuf.map \
597+
libprotoc.map \
583598
README.md
584599

585600
protoc_lite_outputs = \

src/libprotobuf-lite.map

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
global:
3+
extern "C++" {
4+
*google*;
5+
};
6+
7+
local:
8+
*;
9+
};

src/libprotobuf.map

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
global:
3+
extern "C++" {
4+
*google*;
5+
};
6+
7+
local:
8+
*;
9+
};

src/libprotoc.map

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
global:
3+
extern "C++" {
4+
*google*;
5+
};
6+
7+
local:
8+
*;
9+
};

0 commit comments

Comments
 (0)