lib/fuzzing/oss-fuzz: copy required libraries to the build target
authorAndrew Bartlett <abartlet@samba.org>
Thu, 7 Nov 2019 01:22:07 +0000 (14:22 +1300)
committerDouglas Bagnall <dbagnall@samba.org>
Wed, 20 Nov 2019 23:19:36 +0000 (23:19 +0000)
This is an alternative to static linking as we do not have static source
libraries for all the things we depend on.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Uri Simchoni <uri@samba.org>
lib/fuzzing/oss-fuzz/build_samba.sh

index 481af28f9edf82913d359a1cfbece3a750abb824..aa8e223b0a129a906d1669a89546c141294684c9 100755 (executable)
@@ -30,4 +30,17 @@ export LD
 
 make -j
 
-cp bin/fuzz_* $OUT/
+# Make a directory for the system shared libraries to be copied into
+mkdir -p $OUT/lib
+
+# We can't static link to all the system libs with waf, so copy them
+# to $OUT/lib and set the rpath to point there.  This is similar to how
+# firefox handles this.
+
+for x in bin/fuzz_*
+do
+    cp $x $OUT/
+    bin=`basename $x`
+    ldd $OUT/$bin | cut -f 2 -d '>' | cut -f 1 -d \( | cut -f 2 -d  ' ' | xargs -i cp \{\} $OUT/lib/
+    chrpath -r '$ORIGIN/lib' $OUT/$bin
+done