Allow asan, msan and ubsan to be configured with shared libraries
authorRichard Levitte <levitte@openssl.org>
Wed, 7 Sep 2016 18:56:20 +0000 (20:56 +0200)
committerRichard Levitte <richard@levitte.org>
Wed, 7 Sep 2016 19:54:08 +0000 (21:54 +0200)
The background story is that util/shlib_wrap.sh was setting LD_PRELOAD
or similar platform dependent variables, just in case the shared
libraries were built with -rpath.  Unfortunately, this doesn't work
too well with asan, msan or ubsan.

So, the solution is to forbid the combination of shared libraries,
-rpath and any of the sanity analyzers we can configure.

This changes util/shlib_wrap.sh so it only contains the code that sets
LD_PRELOAD when -rpath has been used when configuring.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(cherry picked from commit 342a1a23793cb99921abeabe882adf8652ba715d)

Configurations/unix-Makefile.tmpl
Configure
util/build.info [new file with mode: 0644]
util/shlib_wrap.sh.in [moved from util/shlib_wrap.sh with 96% similarity]

index 1392295607aa04985c6f3a63fb7e4df57f1be46e..d486d9e2aba5597f583df740562add9f732d845b 100644 (file)
@@ -775,18 +775,14 @@ dist:
 
 # Helper targets #####################################################
 
-link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/shlib_wrap.sh
+link-utils: $(BLDDIR)/util/opensslwrap.sh
 
 $(BLDDIR)/util/opensslwrap.sh: configdata.pm
        @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
            mkdir -p "$(BLDDIR)/util"; \
            ln -sf "../$(SRCDIR)/util/opensslwrap.sh" "$(BLDDIR)/util"; \
        fi
-$(BLDDIR)/util/shlib_wrap.sh: configdata.pm
-       @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
-           mkdir -p "$(BLDDIR)/util"; \
-           ln -sf "../$(SRCDIR)/util/shlib_wrap.sh" "$(BLDDIR)/util"; \
-       fi
+
 FORCE:
 
 # Building targets ###################################################
index f77177f25c4173f83b8741c369351b025bfff650..4be1f33e534c29353d142f8e414d8aa7913802d2 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -284,7 +284,7 @@ my $default_ranlib;
 $config{fips}=0;
 
 # Top level directories to build
-$config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "tools", "fuzz" ];
+$config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "util", "tools", "fuzz" ];
 # crypto/ subdirectories to build
 $config{sdirs} = [
     "objects",
@@ -763,6 +763,13 @@ foreach (@argvcopy)
                }
        }
 
+if ($libs =~ /(^|\s)-Wl,-rpath,/
+    && !$disabled{shared}
+    && !($disabled{asan} && $disabled{msan} && $disabled{ubsan})) {
+    die "***** Cannot simultaneously use -rpath, shared libraries, and\n",
+       "***** any of asan, msan or ubsan\n";
+}
+
 if ($config{fips})
        {
        delete $disabled{"shared"} if ($disabled{"shared"} =~ /^default/);
diff --git a/util/build.info b/util/build.info
new file mode 100644 (file)
index 0000000..616fbd7
--- /dev/null
@@ -0,0 +1,2 @@
+SCRIPTS_NO_INST=shlib_wrap.sh
+SOURCE[shlib_wrap.sh]=shlib_wrap.sh.in
similarity index 96%
rename from util/shlib_wrap.sh
rename to util/shlib_wrap.sh.in
index ce463f17e8229183cde9719118dcb190e8d173ae..eff11417a5889fc6e8fec59f091164b414aac782 100755 (executable)
@@ -81,6 +81,7 @@ SunOS|IRIX*)
        ;;
 esac
 
+{- output_off() if $config{ex_libs} !~ /(^|\s)-Wl,-rpath,/; ""; -}
 if [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then
        # Following three lines are major excuse for isolating them into
        # this wrapper script. Original reason for setting LD_PRELOAD
@@ -96,6 +97,7 @@ if [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then
        DYLD_INSERT_LIBRARIES="$LIBCRYPTOSO:$LIBSSLSO"  # MacOS X
        export LD_PRELOAD _RLD_LIST DYLD_INSERT_LIBRARIES
 fi
+{- output_on() if $config{ex_libs} !~ /(^|\s)-Wl,-rpath,/; ""; -}
 
 cmd="$1"; [ -x "$cmd" ] || cmd="$cmd${EXE_EXT}"
 shift