[patch] hide libsmbclient's private symbols

Julien Cristau jcristau at debian.org
Mon Jun 18 10:52:43 GMT 2007


Hi,

the following patch (against samba 3.0.25a) makes the build system use a
version script if it detects a recent enough gnu ld.  This makes
libsmbclient export about 50 symbols instead of about 4000, which
reduces the risk of symbols clashes due to private symbols which aren't
part of the API and have no business being exported.  The detection is
probably not optimal, but I think it's safe (support for version scripts
seems to have been added in 2002, before gnu ld 2.12).  Feedback
welcome.

Cheers,
Julien

Index: samba-3.0.25a/source/Makefile.in
===================================================================
--- samba-3.0.25a.orig/source/Makefile.in	2007-06-08 23:36:12.000000000 +0200
+++ samba-3.0.25a/source/Makefile.in	2007-06-08 23:36:12.000000000 +0200
@@ -1163,6 +1163,7 @@
 	@echo Linking libsmbclient shared library $@
 	@$(SHLD) $(LDSHFLAGS) -Wl,-z,defs -o $@ $(LIBSMBCLIENT_OBJ) $(LIBS) \
 		$(KRB5LIBS) $(LDAP_LIBS) $(NSCD_LIBS) \
+		@VERSIONLDFLAGS@ \
 		@SONAMEFLAG@`basename $@`.$(LIBSMBCLIENT_MAJOR)
 
 bin/libsmbclient.a: proto_exists $(LIBSMBCLIENT_OBJ)
Index: samba-3.0.25a/source/configure.in
===================================================================
--- samba-3.0.25a.orig/source/configure.in	2007-06-08 23:36:12.000000000 +0200
+++ samba-3.0.25a/source/configure.in	2007-06-08 23:36:36.000000000 +0200
@@ -267,6 +267,7 @@
 AC_SUBST(SHELL)
 AC_SUBST(LDSHFLAGS)
 AC_SUBST(SONAMEFLAG)
+AC_SUBST(VERSIONLDFLAGS)
 AC_SUBST(SHLD)
 AC_SUBST(HOST_OS)
 AC_SUBST(PICFLAG)
@@ -456,6 +457,9 @@
  	if test "$ac_cv_gnu_ld_date" -lt 20030217; then
  		ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
  	fi
+	if test "$ac_cv_gnu_ld_date" -gt 20030101; then
+		ac_cv_gnu_ld_version_script=yes
+	fi
         else
            AC_MSG_CHECKING(GNU ld release version)
            changequote(,)dnl
@@ -471,6 +475,9 @@
            if test "$ac_cv_gnu_ld_vernr_major" -lt 2 || test "$ac_cv_gnu_ld_vernr_minor" -lt 14; then
              ac_cv_gnu_ld_no_default_allow_shlib_undefined=yes
            fi
+           if test "$ac_cv_gnu_ld_vernr_major" -gt 2 || test "$ac_cv_gnu_ld_vernr_major" = 2 && test "$ac_cv_gnu_ld_vernr_minor" -ge 12; then
+             ac_cv_gnu_ld_version_script=yes
+           fi
         fi
 fi
 
@@ -1703,6 +1710,9 @@
 			DYNEXP="-Wl,--export-dynamic"
 			PICFLAG="-fPIC"
 			SONAMEFLAG="-Wl,-soname="
+			if test "${ac_cv_gnu_ld_version_script}" = yes; then
+				VERSIONLDFLAGS="-Wl,--version-script,libsmb/libsmbclient.syms"
+			fi
 			AC_DEFINE(STAT_ST_BLOCKSIZE,512)
 			;;
 		*solaris*) AC_DEFINE(SUNOS5,1,[Whether the host os is solaris])
Index: samba-3.0.25a/source/libsmb/libsmbclient.syms
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ samba-3.0.25a/source/libsmb/libsmbclient.syms	2007-06-08 23:36:12.000000000 +0200
@@ -0,0 +1,4 @@
+{
+	global: smbc_*;
+	local: *;
+};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.samba.org/archive/samba-technical/attachments/20070618/3c08b0fa/attachment.bin


More information about the samba-technical mailing list