1e1051a39Sopenharmony_ci#!/bin/sh 2e1051a39Sopenharmony_ci{- 3e1051a39Sopenharmony_ci use lib '.'; 4e1051a39Sopenharmony_ci use configdata; 5e1051a39Sopenharmony_ci use lib catdir($config{sourcedir}, 'Configurations'); 6e1051a39Sopenharmony_ci use platform; 7e1051a39Sopenharmony_ci-} 8e1051a39Sopenharmony_ci# To test this OpenSSL version's applications against another version's 9e1051a39Sopenharmony_ci# shared libraries, simply set 10e1051a39Sopenharmony_ci# 11e1051a39Sopenharmony_ci# OPENSSL_REGRESSION=/path/to/other/OpenSSL/build/tree 12e1051a39Sopenharmony_ciif [ -n "$OPENSSL_REGRESSION" ]; then 13e1051a39Sopenharmony_ci shlibwrap="$OPENSSL_REGRESSION/util/shlib_wrap.sh" 14e1051a39Sopenharmony_ci if [ -x "$shlibwrap" ]; then 15e1051a39Sopenharmony_ci # We clear OPENSSL_REGRESSION to avoid a loop, should the shlib_wrap.sh 16e1051a39Sopenharmony_ci # we exec also support that mechanism... 17e1051a39Sopenharmony_ci OPENSSL_REGRESSION= exec "$shlibwrap" "$@" 18e1051a39Sopenharmony_ci else 19e1051a39Sopenharmony_ci if [ -f "$shlibwrap" ]; then 20e1051a39Sopenharmony_ci echo "Not permitted to run $shlibwrap" >&2 21e1051a39Sopenharmony_ci else 22e1051a39Sopenharmony_ci echo "No $shlibwrap, perhaps OPENSSL_REGRESSION isn't properly set?" >&2 23e1051a39Sopenharmony_ci fi 24e1051a39Sopenharmony_ci exit 1 25e1051a39Sopenharmony_ci fi 26e1051a39Sopenharmony_cifi 27e1051a39Sopenharmony_ci 28e1051a39Sopenharmony_ci[ $# -ne 0 ] || set -x # debug mode without arguments:-) 29e1051a39Sopenharmony_ci 30e1051a39Sopenharmony_ciTHERE="`echo $0 | sed -e 's|[^/]*$||' 2>/dev/null`.." 31e1051a39Sopenharmony_ci[ -d "${THERE}" ] || exec "$@" # should never happen... 32e1051a39Sopenharmony_ci 33e1051a39Sopenharmony_ciLIBCRYPTOSO="${THERE}/{- platform->sharedlib('libcrypto') -}" 34e1051a39Sopenharmony_ciLIBSSLSO="${THERE}/{- platform->sharedlib('libssl') -}" 35e1051a39Sopenharmony_ci 36e1051a39Sopenharmony_ciSYSNAME=`(uname -s) 2>/dev/null`; 37e1051a39Sopenharmony_cicase "$SYSNAME" in 38e1051a39Sopenharmony_ciSunOS|IRIX*) 39e1051a39Sopenharmony_ci # SunOS and IRIX run-time linkers evaluate alternative 40e1051a39Sopenharmony_ci # variables depending on target ABI... 41e1051a39Sopenharmony_ci rld_var=LD_LIBRARY_PATH 42e1051a39Sopenharmony_ci case "`(/usr/bin/file "$LIBCRYPTOSO") 2>/dev/null`" in 43e1051a39Sopenharmony_ci *ELF\ 64*SPARC*|*ELF\ 64*AMD64*) 44e1051a39Sopenharmony_ci [ -n "$LD_LIBRARY_PATH_64" ] && rld_var=LD_LIBRARY_PATH_64 45e1051a39Sopenharmony_ci LD_PRELOAD_64="$LIBCRYPTOSO $LIBSSLSO"; export LD_PRELOAD_64 46e1051a39Sopenharmony_ci preload_var=LD_PRELOAD_64 47e1051a39Sopenharmony_ci ;; 48e1051a39Sopenharmony_ci *ELF\ 32*SPARC*|*ELF\ 32*80386*) 49e1051a39Sopenharmony_ci # We only need to change LD_PRELOAD_32 and LD_LIBRARY_PATH_32 50e1051a39Sopenharmony_ci # on a multi-arch system. Otherwise, trust the fallbacks. 51e1051a39Sopenharmony_ci if [ -f /lib/64/ld.so.1 ]; then 52e1051a39Sopenharmony_ci [ -n "$LD_LIBRARY_PATH_32" ] && rld_var=LD_LIBRARY_PATH_32 53e1051a39Sopenharmony_ci LD_PRELOAD_32="$LIBCRYPTOSO $LIBSSLSO"; export LD_PRELOAD_32 54e1051a39Sopenharmony_ci preload_var=LD_PRELOAD_32 55e1051a39Sopenharmony_ci fi 56e1051a39Sopenharmony_ci ;; 57e1051a39Sopenharmony_ci # Why are newly built .so's preloaded anyway? Because run-time 58e1051a39Sopenharmony_ci # .so lookup path embedded into application takes precedence 59e1051a39Sopenharmony_ci # over LD_LIBRARY_PATH and as result application ends up linking 60e1051a39Sopenharmony_ci # to previously installed .so's. On IRIX instead of preloading 61e1051a39Sopenharmony_ci # newly built .so's we trick run-time linker to fail to find 62e1051a39Sopenharmony_ci # the installed .so by setting _RLD_ROOT variable. 63e1051a39Sopenharmony_ci *ELF\ 32*MIPS*) 64e1051a39Sopenharmony_ci #_RLD_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD_LIST 65e1051a39Sopenharmony_ci _RLD_ROOT=/no/such/dir; export _RLD_ROOT 66e1051a39Sopenharmony_ci eval $rld_var=\"/usr/lib'${'$rld_var':+:$'$rld_var'}'\" 67e1051a39Sopenharmony_ci preload_var=_RLD_LIST 68e1051a39Sopenharmony_ci ;; 69e1051a39Sopenharmony_ci *ELF\ N32*MIPS*) 70e1051a39Sopenharmony_ci [ -n "$LD_LIBRARYN32_PATH" ] && rld_var=LD_LIBRARYN32_PATH 71e1051a39Sopenharmony_ci #_RLDN32_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLDN32_LIST 72e1051a39Sopenharmony_ci _RLDN32_ROOT=/no/such/dir; export _RLDN32_ROOT 73e1051a39Sopenharmony_ci eval $rld_var=\"/usr/lib32'${'$rld_var':+:$'$rld_var'}'\" 74e1051a39Sopenharmony_ci preload_var=_RLDN32_LIST 75e1051a39Sopenharmony_ci ;; 76e1051a39Sopenharmony_ci *ELF\ 64*MIPS*) 77e1051a39Sopenharmony_ci [ -n "$LD_LIBRARY64_PATH" ] && rld_var=LD_LIBRARY64_PATH 78e1051a39Sopenharmony_ci #_RLD64_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD64_LIST 79e1051a39Sopenharmony_ci _RLD64_ROOT=/no/such/dir; export _RLD64_ROOT 80e1051a39Sopenharmony_ci eval $rld_var=\"/usr/lib64'${'$rld_var':+:$'$rld_var'}'\" 81e1051a39Sopenharmony_ci preload_var=_RLD64_LIST 82e1051a39Sopenharmony_ci ;; 83e1051a39Sopenharmony_ci esac 84e1051a39Sopenharmony_ci eval $rld_var=\"${THERE}'${'$rld_var':+:$'$rld_var'}'\"; export $rld_var 85e1051a39Sopenharmony_ci unset rld_var 86e1051a39Sopenharmony_ci ;; 87e1051a39Sopenharmony_ciNONSTOP_KERNEL) 88e1051a39Sopenharmony_ci # HPE NonStop has a proprietary mechanism for specifying 89e1051a39Sopenharmony_ci # the location of DLLs. It does not use PATH or variables 90e1051a39Sopenharmony_ci # commonly used on other platforms. The platform has a limited 91e1051a39Sopenharmony_ci # environment space keeping extraneous variables to a minimum 92e1051a39Sopenharmony_ci # is recommended. 93e1051a39Sopenharmony_ci _RLD_LIB_PATH="${THERE}:$LD_LIBRARY_PATH" 94e1051a39Sopenharmony_ci export _RLD_LIB_PATH 95e1051a39Sopenharmony_ci ;; 96e1051a39Sopenharmony_ci*) LD_LIBRARY_PATH="${THERE}:$LD_LIBRARY_PATH" # Linux, ELF HP-UX 97e1051a39Sopenharmony_ci DYLD_LIBRARY_PATH="${THERE}:$DYLD_LIBRARY_PATH" # MacOS X 98e1051a39Sopenharmony_ci SHLIB_PATH="${THERE}:$SHLIB_PATH" # legacy HP-UX 99e1051a39Sopenharmony_ci LIBPATH="${THERE}:$LIBPATH" # AIX, OS/2 100e1051a39Sopenharmony_ci export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH 101e1051a39Sopenharmony_ci # Even though $PATH is adjusted [for Windows sake], it doesn't 102e1051a39Sopenharmony_ci # necessarily does the trick. Trouble is that with introduction 103e1051a39Sopenharmony_ci # of SafeDllSearchMode in XP/2003 it's more appropriate to copy 104e1051a39Sopenharmony_ci # .DLLs in vicinity of executable, which is done elsewhere... 105e1051a39Sopenharmony_ci if [ "$OSTYPE" != msdosdjgpp ]; then 106e1051a39Sopenharmony_ci PATH="${THERE}:$PATH"; export PATH 107e1051a39Sopenharmony_ci fi 108e1051a39Sopenharmony_ci ;; 109e1051a39Sopenharmony_ciesac 110e1051a39Sopenharmony_ci 111e1051a39Sopenharmony_ci{- output_off() unless grep (/-rpath\b/, @{$config{LDFLAGS}}); ""; -} 112e1051a39Sopenharmony_ciif [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then 113e1051a39Sopenharmony_ci # Following three lines are major excuse for isolating them into 114e1051a39Sopenharmony_ci # this wrapper script. Original reason for setting LD_PRELOAD 115e1051a39Sopenharmony_ci # was to make it possible to pass 'make test' when user linked 116e1051a39Sopenharmony_ci # with -rpath pointing to previous version installation. Wrapping 117e1051a39Sopenharmony_ci # it into a script makes it possible to do so on multi-ABI 118e1051a39Sopenharmony_ci # platforms. 119e1051a39Sopenharmony_ci case "$SYSNAME" in 120e1051a39Sopenharmony_ci *BSD) LD_PRELOAD="$LIBCRYPTOSO:$LIBSSLSO" ;; # *BSD 121e1051a39Sopenharmony_ci *) LD_PRELOAD="$LIBCRYPTOSO $LIBSSLSO" ;; # SunOS, Linux, ELF HP-UX 122e1051a39Sopenharmony_ci esac 123e1051a39Sopenharmony_ci _RLD_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT" # Tru64, o32 IRIX 124e1051a39Sopenharmony_ci DYLD_INSERT_LIBRARIES="$LIBCRYPTOSO:$LIBSSLSO" # MacOS X 125e1051a39Sopenharmony_ci export LD_PRELOAD _RLD_LIST DYLD_INSERT_LIBRARIES 126e1051a39Sopenharmony_cifi 127e1051a39Sopenharmony_ci{- output_on() unless grep (/-rpath\b/, @{$config{LDFLAGS}}); ""; -} 128e1051a39Sopenharmony_ci 129e1051a39Sopenharmony_cicmd="$1"; [ -x "$cmd" ] || cmd="$cmd${EXE_EXT}" 130e1051a39Sopenharmony_cishift 131e1051a39Sopenharmony_ciif [ $# -eq 0 ]; then 132e1051a39Sopenharmony_ci exec "$cmd" # old sh, such as Tru64 4.x, fails to expand empty "$@" 133e1051a39Sopenharmony_cielse 134e1051a39Sopenharmony_ci exec "$cmd" "$@" 135e1051a39Sopenharmony_cifi 136