On Wed, 2009-07-01 at 16:04 +0200, Michael Haubenwallner wrote: > No problem. It's just that the hpux10.20 box is shot down tomorrow, so I > cannot test this platform any more.
The hpux10.20 box finally has been brought down now, and I have less hope to get it up again even for testing only. This patch here was the last one tested there. > > * Michael Haubenwallner wrote on Mon, Jun 29, 2009 at 11:22:31AM CEST: > > > > > > Ok, here's the third way of supporting DESTDIR on hppa-hpux, now without > > > the +cdp linker flag (#2), but using the absolute target libdir in the > > > 'internal name' instead, to fix the security issue of #1. > > > > Using absolute paths seems like a step backward, with all the world > > wanting relocatable packages more than anything. I don't think we > > should go that way unless we cannot help it at all. But maybe I have > > misunderstood you latest approach? > > Do you mean subsequent linked binaries should not contain the location > the dependent shared library was originally targetted for? > Well, I can agree here. Patch#2 with the +cdp mess would avoid that. For completion: The "+cdp mess" means that for each required local shared library the linkline gets bloated by "+cdp $inst_prefix_dir$install_libdir/$soname:$install_libdir/$soname" Here's the fourth try: The uninstalled shared libraries get absolute "$install_libdir/$soname" into the internal name, to be able to create the local executables for fast_install, without any embedded $builddir or $inst_prefix_dir, and without the +cdp mess. But this needs to force each local shared library - even those without local dependencies - to be relinked for installation. Relinking is done with "$soname" only as internal name, requiring "+cdp $inst_prefix_dir:" only once to avoid inst_prefix_dir in the fallback path. The runpath is again hardcoded into shared libraries too. IMHO the basic problem here is that for binaries there is nothing known like $install_bindir, similar to $install_libdir for libraries. Same 12 tests change from SKIP/XFAIL to PASS as before, without any other test result change. > Another question: > HP-UX does support SHLIB_PATH for 32bit hppa, and both LD_LIBRARY_PATH > and SHLIB_PATH for hppa64 and ia64 (32/64), which can be enabled easily. This would require the +s linker flag for executables too, but I haven't found a way to do this. Thoughts? Thanks! /haubi/
diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index 1fe09d2..1727070 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -2332,6 +2332,10 @@ hpux9* | hpux10* | hpux11*) shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' + case $host_os in + hpux9*) ;; + *) hardcode_into_libs=yes ;; + esac ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... @@ -4760,25 +4764,59 @@ _LT_EOF ;; hpux10*) + # gcc-3.0.1 does some post-link processing which breaks when the + # just created binary has a nonexistent 'dynamic dependency'. + AC_CACHE_CHECK([whether absolute path of internal name works with $CC], + [_LT_TAGVAR(lt_cv_cdp_works, $1)], + [_LT_TAGVAR(lt_cv_cdp_works, $1)=: + if test "$GCC" = yes; then + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,+cdp -Wl,/usr/lib:/nonexistent -Wl,+cdp -Wl,/lib:/nonexistent" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [], [_LT_TAGVAR(lt_cv_cdp_works, $1)=false]) + LDFLAGS="$save_LDFLAGS" + fi + ]) if test "$GCC" = yes && test "$with_gnu_ld" = no; then - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + $_LT_TAGVAR(lt_cv_cdp_works, $1) && + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC`test $mode = relink && func_echo_all " ${wl}+cdp ${wl}$inst_prefix_dir: ${wl}+h ${wl}" || func_echo_all " ${wl}+h ${wl}$install_libdir/"`$soname -o $lib $libobjs $deplibs $compiler_flags~need_relink=yes' || + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' else - _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + $_LT_TAGVAR(lt_cv_cdp_works, $1) && + _LT_TAGVAR(archive_cmds, $1)='$LD -b`test $mode = relink && func_echo_all " +cdp $inst_prefix_dir: +h " || func_echo_all " +h $install_libdir/"`$soname -o $lib $libobjs $deplibs $linker_flags~need_relink=yes' || + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' - _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. + # but as the default location of the library, when it does not + # have an absolute path in 'internal name' (the +h linker flag). + $_LT_TAGVAR(lt_cv_cdp_works, $1) || _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) + case $host_cpu in hppa*64* | ia64*) ;; + *) + AC_CACHE_CHECK([whether absolute path of internal name works with $CC], + [_LT_TAGVAR(lt_cv_cdp_works, $1)], + [_LT_TAGVAR(lt_cv_cdp_works, $1)=: + if test "$GCC" = yes; then + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,+cdp -Wl,/usr/lib:/nonexistent -Wl,+cdp -Wl,/lib:/nonexistent" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [], [_LT_TAGVAR(lt_cv_cdp_works, $1)=false]) + LDFLAGS="$save_LDFLAGS" + fi + ]) + ;; + esac if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) @@ -4788,7 +4826,9 @@ _LT_EOF _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + $_LT_TAGVAR(lt_cv_cdp_works, $1) && + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC`test $mode = relink && func_echo_all " ${wl}+cdp ${wl}$inst_prefix_dir: ${wl}+h ${wl}" || func_echo_all " ${wl}+h ${wl}$install_libdir/"`$soname -o $lib $libobjs $deplibs $compiler_flags~need_relink=yes' || + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac else @@ -4805,9 +4845,16 @@ _LT_EOF # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], - [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], - [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) + [$_LT_TAGVAR(lt_cv_cdp_works, $1) && + _LT_TAGVAR(archive_cmds, $1)='$CC -b`test $mode = relink && func_echo_all " ${wl}+cdp ${wl}$inst_prefix_dir: ${wl}+h ${wl}" || func_echo_all " ${wl}+h ${wl}$install_libdir/"`$soname -o $lib $libobjs $deplibs $compiler_flags~need_relink=yes' || + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'], + [$_LT_TAGVAR(lt_cv_cdp_works, $1) && + _LT_TAGVAR(archive_cmds, $1)='$LD -b`test $mode = relink && func_echo_all " +cdp $inst_prefix_dir: +h " || func_echo_all " +h $install_libdir/"`$soname -o $lib $libobjs $deplibs $linker_flags~need_relink=yes' || + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'])], + [$_LT_TAGVAR(lt_cv_cdp_works, $1) && + _LT_TAGVAR(archive_cmds, $1)='$CC -b`test $mode = relink && func_echo_all " ${wl}+cdp ${wl}$inst_prefix_dir: ${wl}+h ${wl}" || func_echo_all " ${wl}+h ${wl}$install_libdir/"`$soname -o $lib $libobjs $deplibs $compiler_flags~need_relink=yes' || + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi @@ -4826,7 +4873,9 @@ _LT_EOF _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, - # but as the default location of the library. + # but as the default location of the library, when it does not + # have an absolute path in 'internal name' (the +h linker flag). + $_LT_TAGVAR(lt_cv_cdp_works, $1) || _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac @@ -5749,11 +5798,24 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) + AC_CACHE_CHECK([wheter absolute path of internal name works with $CC], + [_LT_TAGVAR(lt_cv_cdp_works, $1)], + [_LT_TAGVAR(lt_cv_cdp_works, $1)=: + if test "$GCC" = yes; then + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -Wl,+cdp -Wl,/usr/lib:/nonexistent -Wl,+cdp -Wl,/lib:/nonexistent" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [], [_LT_TAGVAR(lt_cv_cdp_works, $1)=false]) + LDFLAGS="$save_LDFLAGS" + fi + ]) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes - _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, - # but as the default - # location of the library. + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library, when it does not + # have an absolute path in 'internal name' (the +h linker flag). + $_LT_TAGVAR(lt_cv_cdp_works, $1) || + _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac @@ -5771,7 +5833,9 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + $_LT_TAGVAR(lt_cv_cdp_works, $1) && + _LT_TAGVAR(archive_cmds, $1)='$CC -b`test $mode = relink && func_echo_all " ${wl}+cdp ${wl}$inst_prefix_dir: ${wl}+h ${wl}" || func_echo_all " ${wl}+h ${wl}$install_libdir/"`$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~need_relink=yes' || + _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists @@ -5795,7 +5859,9 @@ if test "$_lt_caught_CXX_error" != yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) - _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + $_LT_TAGVAR(lt_cv_cdp_works, $1) && + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC`test $mode = relink && func_echo_all " ${wl}+cdp ${wl}$inst_prefix_dir: ${wl}+h ${wl}" || func_echo_all " ${wl}+h ${wl}$install_libdir/"`$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~need_relink=yes' || + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi diff --git a/tests/demo-hardcode.test b/tests/demo-hardcode.test index 31b2e1d..d7c2180 100755 --- a/tests/demo-hardcode.test +++ b/tests/demo-hardcode.test @@ -39,6 +39,7 @@ func_make "hardcode" # Extra tools we might need : ${DUMPSTABS=dumpstabs} +: ${CHATR=chatr} # Suck in all the hardcode_* variable settings. func_msg "Finding libtool.m4's guesses at hardcoding values" @@ -70,11 +71,31 @@ for file in hc-*; do # Discover whether the objdir really was hardcoded. hardcoded=no + # hppa-hpux (SOM) stores either the 'internal name' (+h), when it contains + # an absolute path, or the absolute location where the library was found + # at linktime in the the 'shared library list' of the resulting binary. + # When the type of such an entry is 'static', the runpath is ignored + # for that library. As this is unwanted, we treat this as hardcoded, + # even if it does not contain the objdir. + # For hppa64-hpux (ELF) and ia64-hpux (ELF), 'chatr' does not tell whether + # the shared library location is 'static' or 'dynamic', as the path + # component is not stored anyway when the library was found via '-L'. + # Additionally, aCC/cc store commandline and other information used to + # create object files into these (as 'ccom options', 'driver_command'), + # which may also lead to false positives when using 'cat'. + if { $CHATR $file ;} >/dev/null 2>&1; then + if $CHATR $file 2>/dev/null \ + | $SED -e "s|^ *static */|$objdir&|" \ + | $FGREP "$objdir" >/dev/null 2>&1; then + hardcoded=yes + else + hardcoded=no + fi # Solaris cc may store the command line in a debugging section, # which leads to false positives. Unfortunately, Solaris strip # is not capable to remove the section (unlike GNU binutils strip). # So we use dumpstabs if it seems to work. - if { $DUMPSTABS -d $file; } >/dev/null 2>&1; then + elif { $DUMPSTABS -d $file; } >/dev/null 2>&1; then if $DUMPSTABS -d $file 2>/dev/null | $FGREP "$objdir" >/dev/null 2>&1; then hardcoded=yes else