s3: make unresolved symbols in libs throw errors
authorBjörn Jacke <bj@sernet.de>
Mon, 19 Oct 2009 23:13:56 +0000 (01:13 +0200)
committerBjörn Jacke <bj@sernet.de>
Tue, 20 Oct 2009 08:52:06 +0000 (10:52 +0200)
except for the Samba internal plugins unresolved symbol references should not
show up in shared libraries. For historical reasons it's the default behaviour
of linkers to ignore those in shared libs. We use -z defs (alias
--no-undefined) to not ignore them in shared libs.

source3/Makefile.in
source3/configure.in

index 399d01f7939f6180d0c80f927c4a21e4ca54bfb5..6ce47695df7dd4fdcfaaab8e50f768f42a98c40a 100644 (file)
@@ -45,11 +45,11 @@ CPPFLAGS=-DHAVE_CONFIG_H @CPPFLAGS@
 
 EXEEXT=@EXEEXT@
 AR=@AR@
-LDSHFLAGS=@LDSHFLAGS@ @RELRO_LDFLAGS@ @LDFLAGS@
-LDPLUGINFLAGS=@LDSHFLAGS@ @RELRO_LDFLAGS@ @LDFLAGS@
+LDSHFLAGS=@LDSHFLAGS@ @RELRO_LDFLAGS@ @LDFLAGS@ @LDSHFLAGS_Z_DEFS@
+LDPLUGINFLAGS=@LDSHFLAGS@ @RELRO_LDFLAGS@ @LDFLAGS@ @LDSHFLAGS_Z_NODEFS@
 LDFLAGS=@PIE_LDFLAGS@ @RELRO_LDFLAGS@ @LDFLAGS@
 
-WINBIND_NSS_LDSHFLAGS=@WINBIND_NSS_LDSHFLAGS@ @LDFLAGS@
+WINBIND_NSS_LDSHFLAGS=@WINBIND_NSS_LDSHFLAGS@ @LDFLAGS@ @LDSHFLAGS_Z_DEFS@
 AWK=@AWK@
 PICFLAG=@PICFLAG@
 DYNEXP=@DYNEXP@
index 69596df46c4c10f4818a3c4aeac2f0a494c90a65..80a347cd4e1461e161813571695e006eba2804f6 100644 (file)
@@ -377,6 +377,10 @@ esac
 
 DYNEXP=
 AC_SUBST(DYNEXP)
+LDSHFLAGS_Z_DEFS=
+AC_SUBST(LDSHFLAGS_Z_DEFS)
+LDSHFLAGS_Z_NODEFS=
+AC_SUBST(LDSHFLAGS_Z_NODEFS)
 
 dnl Add modules that have to be built by default here
 dnl These have to be built static:
@@ -1557,10 +1561,9 @@ DSO_EXPORTS=""
                                AC_DEFINE(LINUX,1,[Whether the host os is linux]) ;;
                        esac
                        BLDSHARED="true"
+                       LDSHFLAGS="-shared -Wl,-Bsymbolic"
                        if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
-                               LDSHFLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
-                       else
-                               LDSHFLAGS="-shared -Wl,-Bsymbolic"
+                               LDSHFLAGS_Z_NODEFS="-Wl,--allow-shlib-undefined"
                        fi
                        DYNEXP="-Wl,--export-dynamic"
                        PICFLAG="-fPIC"
@@ -1772,6 +1775,27 @@ if test x"${ac_cv_prog_gnu_ld}" = x"yes"; then
        LDFLAGS="$LD_AS_NEEDED_FLAG $saved_ldflags"
 fi
 
+# for historical reasons almost all linkers don't complain about unresolved
+# symbols in shared libs. Except for the internal samba modules we want to get
+# errors when we produce a shared lib with unresolved symbols. On some
+# platforms unresolved symbols might be intended, so we might have to add
+# platform specific exceptions here.
+
+for flags in "-Wl,-z,defs" "-error_unresolved" "-Wl,-error_unresolved" ; do
+       saved_ldflags="$LDFLAGS"
+       AC_MSG_CHECKING([if $flags works])
+       LDFLAGS="$flags $saved_ldflags"
+       AC_TRY_LINK([],[],
+       [AC_MSG_RESULT([yes])
+       LDSHFLAGS_Z_DEFS=$flags
+       ldshflags_z_defs_found=yes],
+       AC_MSG_RESULT([no]))
+       LDFLAGS=$saved_ldflags
+       test x"$ldshflags_z_defs_found" = xyes && break
+done
+
+AC_MSG_CHECKING([LDSHFLAGS_Z_DEFS])
+AC_MSG_RESULT([$LDSHFLAGS_Z_DEFS])
 AC_MSG_CHECKING([LDFLAGS])
 AC_MSG_RESULT([$LDFLAGS])
 AC_MSG_CHECKING([DYNEXP])