From 048725080b608d0d714f133a15e09dda6b6dd8ca Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 22 Oct 2020 12:05:29 +1300 Subject: [PATCH] fuzzing: Improve robustness and documentation of the ldd-base library copy This tries to make progress towards understanding why we sometime see errors like Step #6: Error occured while running fuzz_reg_parse: Step #6: /workspace/out/coverage/fuzz_reg_parse: error while loading shared libraries: libavahi-common.so.3: cannot open shared object file: No such file or directory in the previously failing coverage builds. Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall --- lib/fuzzing/oss-fuzz/build_samba.sh | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/fuzzing/oss-fuzz/build_samba.sh b/lib/fuzzing/oss-fuzz/build_samba.sh index 5980f88ad02..c9a5162f801 100755 --- a/lib/fuzzing/oss-fuzz/build_samba.sh +++ b/lib/fuzzing/oss-fuzz/build_samba.sh @@ -94,12 +94,25 @@ mkdir -p $OUT/lib for x in bin/fuzz_* do + # Copy any system libraries needed by this fuzzer to $OUT/lib. + + # We run ldd on $x, the fuzz_binary in bin/ which has not yet had + # the RUNPATH altered. This is clearer for debugging in local + # development builds as $OUT is not cleaned between runs. + # + # Otherwise trying to re-run this can see cp can fail with: + # cp: '/out/lib/libgcc_s.so.1' and '/out/lib/libgcc_s.so.1' are the same file + # which is really confusing! + + # The cut for ( and ' ' removes the special case references to: + # linux-vdso.so.1 => (0x00007ffe8f2b2000) + # /lib64/ld-linux-x86-64.so.2 (0x00007fc63ea6f000) + + ldd $x | cut -f 2 -d '>' | cut -f 1 -d \( | cut -f 2 -d ' ' | xargs -i cp \{\} $OUT/lib/ + cp $x $OUT/ bin=`basename $x` - # Copy any system libraries needed by this fuzzer to $OUT/lib - ldd $OUT/$bin | cut -f 2 -d '>' | cut -f 1 -d \( | cut -f 2 -d ' ' | xargs -i cp \{\} $OUT/lib/ - # Change any RPATH to RUNPATH. # # We use ld.bfd for the coverage builds, rather than the faster ld.gold.