tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: libtool, -fstack-protector, -nostdlib, and while we're at it -Bdirect on SunOS



There is one thing that has been bugging me for months is the fact that
(using my test case for graphviz) frequently the need for '-fstack-protector' comes from a dependant library, such as perl or cups or something.

That may be fine for programs, but for shared libraries, that can get quite complicated.

In libtool terms, there is a variable in the .la file named inherited_linker_flags that is added to the link command to the shared library... I guess a reasonably good example of this is '-pthread'.

I believe that '-fstack-protector*' is quite similar in this respect, and that if '-fstack-protector*' is required to build the shared library with libtool, then it will be necessary to ultimately link to this new shared library.

Keeping with my example, note the following:
richard@devzone:/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/tclpkg/gv/.libs$
 ldd -D libgv_perl.so
        libgvc.so.6 =>        
/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/gvc/.libs/libgvc.so.6
        libcgraph.so.6 =>     /opt/local/lib/libcgraph.so.6
        libcdt.so.5 =>        /opt/local/lib/libcdt.so.5
        libdl.so.1 =>         /lib/libdl.so.1
        libltdl.so.7 =>       /opt/local/lib/libltdl.so.7
        libxdot.so.4 =>       /opt/local/lib/libxdot.so.4
        libpathplan.so.4 =>   /opt/local/lib/libpathplan.so.4
        libexpat.so.1 =>      /opt/local/lib/libexpat.so.1
        libpthread.so.1 =>    /lib/libpthread.so.1
        librt.so.1 =>         /lib/librt.so.1
        libsocket.so.1 =>     /lib/libsocket.so.1
        libnsl.so.1 =>        /lib/libnsl.so.1
        libz.so.1 =>  /opt/local/lib/libz.so.1
        libm.so.2 =>  /lib/libm.so.2
        libperl.so =>         
/opt/local/lib/perl5/5.20.0/i386-solaris/CORE/libperl.so
        libstdc++.so.6 =>     
/opt/local/gcc47/i386-sun-solaris2.11/lib/./libstdc++.so.6
        libgcc_s.so.1 =>      
/opt/local/gcc47/i386-sun-solaris2.11/lib/./libgcc_s.so.1
        libc.so.1 =>  /lib/libc.so.1
        libssp.so.0 =>        /opt/local/gcc47/i386-sun-solaris2.11/lib/./libssp.so.0        
<<<<<<<<<<<<<<<<<<<<<<<<<
        libmp.so.2 =>         /lib/libmp.so.2
        libmd.so.1 =>         /lib/libmd.so.1
richard@devzone:/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/tclpkg/gv/.libs$
 nm libgv_perl.so |grep __stack
[680]   |         0|         0|FUNC |GLOB |0    |UNDEF  |__stack_chk_fail
[47]    |     83792|        29|FUNC |LOCL |2    |14     |__stack_chk_fail_local
[684]   |         0|         0|OBJT |GLOB |0    |UNDEF  |__stack_chk_guard

Even though on Solaris libssp_unshared.o is no longer needed, libssp.so still is, and that is provided with the spec '-fstack-protector*'.

So I revived my initial work with "inherited_linker_flags" and attach the complementary patch for testing prior to pushing patch-ac which is hereby updated, providing the attached output in the .la file, notably:
# Linker flags that can not go in dependency_libs.
inherited_linker_flags=' -fstack-protector -pthread'

Observations anyone?
# libgv_perl.la - a libtool library file
# Generated by libtool (GNU libtool) 2.4.2
#
# Please DO NOT delete this file!
# It is necessary for linking the library.

# The name that we can dlopen(3).
dlname='libgv_perl.so'

# Names of this library.
library_names='libgv_perl.so libgv_perl.so libgv_perl.so'

# The name of the static archive.
old_library='libgv_perl.a'

# Linker flags that can not go in dependency_libs.
inherited_linker_flags=' -fstack-protector -pthread'

# Libraries that this one depends upon.
dependency_libs=' -L/opt/local/gcc47/lib 
-L/var/tmp/pkgsrc/graphics/graphviz/work/.buildlink/lib 
-L/var/tmp/pkgsrc/graphics/graphviz/work/.buildlink/lib/perl5/5.20.0/i386-solaris/CORE
 -ldl -L/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/gvc/.libs 
/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/gvc/libgvc.la 
-L/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/xdot/.libs 
-L/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/cgraph/.libs 
-L/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/cdt/.libs 
-L/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/pathplan/.libs 
/var/tmp/pkgsrc/graphics/graphviz/work/.buildlink/lib/libltdl.la 
/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/xdot/libxdot.la 
/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/pathplan/libpathplan.la
 /var/tmp/pkgsrc/graphics/graphviz/work/.buildlink/lib/libexpat.la -lpthread 
-lrt -lsocket -lnsl 
/var/tmp/pkgsrc/graphics/graphviz/work/.buildlink/lib/libz.la 
/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/cgraph/libcgraph.la 
/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/lib/cdt/libcdt.la -lperl 
/opt/local/gcc47/lib/libstdc++.la'

# Names of additional weak libraries provided by this library
weak_library_names=''

# Version information for libgv_perl.
current=0
age=0
revision=0

# Is this an already installed library?
installed=no

# Should we warn about portability when linking against -modules?
shouldnotlink=yes

# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''

# Directory that this library needs to be installed in:
libdir='/opt/local/lib/graphviz/perl'
relink_command=' (cd 
/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/tclpkg/gv; 
/opt/local/bin/pdksh /opt/local/bin/libtool --silent --tag CXX --mode=relink 
g++ -O2 -module -avoid-version -R/opt/local/lib/perl5/5.20.0/i386-solaris/CORE 
-L/opt/local/gcc47/lib/gcc/i386-sun-solaris2.11/4.7.3 
-Wl,-R/opt/local/gcc47/lib/gcc/i386-sun-solaris2.11/4.7.3 
-L/opt/local/gcc47/lib -Wl,-R/opt/local/gcc47/lib 
-L/var/tmp/pkgsrc/graphics/graphviz/work/.buildlink/lib -Wl,-R/opt/local/lib 
-fstack-protector 
-L/var/tmp/pkgsrc/graphics/graphviz/work/.buildlink/lib/perl5/5.20.0/i386-solaris/CORE
 -lperl -lm -ldl -lsocket -lnsl -o libgv_perl.la -rpath 
/opt/local/lib/graphviz/perl libgv_perl_la-gv.lo libgv_perl_la-gv_builtins.lo 
libgv_perl_la-gv_dummy_init.lo libgv_perl_la-gv_perl.lo -L../../lib/gvc/.libs 
../../lib/gvc/libgvc.la -L../../lib/cgraph/.libs ../../lib/cgraph/libcgraph.la 
-L../../lib/cdt/.libs ../../lib/cdt/libcdt.la 
-Wl,-rpath,/opt/local/lib/perl5/5.20.0/i386-solaris/CORE -lperl -lc 
@inst_prefix_dir@)'

# Directory that this library was built in:
buildlibdir='/var/tmp/pkgsrc/graphics/graphviz/work/graphviz-2.38.0/tclpkg/gv'

# This file has been modified by buildlink3.
diff --git a/devel/libtool/distinfo b/devel/libtool/distinfo
index 2449eeb..6f91c72 100644
--- a/devel/libtool/distinfo
+++ b/devel/libtool/distinfo
@@ -5,5 +5,5 @@ RMD160 (libtool-2.4.2.tar.gz) = 
b7153f3f1e1c50d8c04787cafccd4e19af62ec7d
 Size (libtool-2.4.2.tar.gz) = 2632347 bytes
 SHA1 (patch-aa) = 8fa167bebf27b7bc3008edd61408a0aede6bdf69
 SHA1 (patch-ab) = f12b9f19c1e1a8905e1b3f66b9c1f55d8eae2ca4
-SHA1 (patch-ac) = b41459989ea1fbd906e48ac0a9948661b4a466ca
+SHA1 (patch-ac) = 9f0c2389ddc8101f0e832f4081fe9bc96a32d4da
 SHA1 (patch-ad) = 48c3832e9205777832ef2a6334033ff6099be8a4
diff --git a/devel/libtool/patches/patch-ac b/devel/libtool/patches/patch-ac
index 2111649..dc79ce8 100644
--- a/devel/libtool/patches/patch-ac
+++ b/devel/libtool/patches/patch-ac
@@ -31,23 +31,25 @@ for solaris2 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
        # don't eliminate duplications in $postdeps and $predeps
        opt_duplicate_compiler_generated_deps=:
        ;;
-@@ -5847,13 +5850,14 @@ func_mode_link ()
-       # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
-       # -F/path              path to uninstalled frameworks, gcc on darwin
-       # -p, -pg, --coverage, -fprofile-*  profiling flags for GCC
-+      # -fstack-protector*   stack protector flags for GCC
-       # @file                GCC response files
-       # -tp=*                Portland pgcc target processor selection
-       # --sysroot=*          for sysroot support
-       # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
-       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
-       
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
--      -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
-+      -O*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*)
-         func_quote_for_eval "$arg"
-       arg="$func_quote_for_eval_result"
-         func_append compile_command " $arg"
-@@ -7391,6 +7395,7 @@ func_mode_link ()
+@@ -5656,7 +5659,7 @@ func_mode_link ()
+       ;;
+ 
+       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+-      |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
++      |-threads|-fopenmp|-fstack-protector*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+       func_append compiler_flags " $arg"
+       func_append compile_command " $arg"
+       func_append finalize_command " $arg"
+@@ -6161,7 +6164,7 @@ func_mode_link ()
+       found=no
+       case $deplib in
+       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
+-        |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
++        |-threads|-fopenmp|-fstack-protector*| 
-openmp|-mp|-xopenmp|-omp|-qsmp=*)
+         if test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$deplib $compile_deplibs"
+           finalize_deplibs="$deplib $finalize_deplibs"
+@@ -7391,6 +7394,7 @@ func_mode_link ()
        # Calculate the version variables.
        major=
        versuffix=
@@ -55,7 +57,7 @@ for solaris2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
        verstring=
        case $version_type in
        none) ;;
-@@ -7451,6 +7456,7 @@ func_mode_link ()
+@@ -7451,6 +7455,7 @@ func_mode_link ()
          func_arith $current - $age
          major=.$func_arith_result
          versuffix="$major.$age.$revision"
@@ -63,7 +65,7 @@ for solaris2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
          ;;
  
        osf)
-@@ -7511,8 +7517,10 @@ func_mode_link ()
+@@ -7511,8 +7516,10 @@ func_mode_link ()
          esac
          if test "$need_version" = no; then
            versuffix=
@@ -74,7 +76,7 @@ for solaris2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
          fi
        fi
  
-@@ -7520,6 +7528,7 @@ func_mode_link ()
+@@ -7520,6 +7527,7 @@ func_mode_link ()
        if test "$avoid_version" = yes && test "$need_version" = no; then
          major=
          versuffix=
@@ -82,7 +84,7 @@ for solaris2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
          verstring=""
        fi
  
-@@ -7630,7 +7639,7 @@ func_mode_link ()
+@@ -7630,7 +7638,7 @@ func_mode_link ()
          *-*-netbsd*)
            # Don't link with libc until the a.out ld.so is fixed.
            ;;
@@ -91,7 +93,7 @@ for solaris2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
            # Do not include libc due to us having libc/libc_r.
            ;;
          *-*-sco3.2v5* | *-*-sco5v6*)
-@@ -7653,12 +7662,14 @@ func_mode_link ()
+@@ -7653,12 +7661,14 @@ func_mode_link ()
        libname_save=$libname
        release_save=$release
        versuffix_save=$versuffix
@@ -106,7 +108,7 @@ for solaris2 
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
        major=""
        newdeplibs=
        droppeddeps=no
-@@ -7935,6 +7946,7 @@ EOF
+@@ -7935,6 +7945,7 @@ EOF
          ;;
        esac
        versuffix=$versuffix_save


Home | Main Index | Thread Index | Old Index