summaryrefslogtreecommitdiffstats
path: root/bin/oss-fuzz-build.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /bin/oss-fuzz-build.sh
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'bin/oss-fuzz-build.sh')
-rwxr-xr-xbin/oss-fuzz-build.sh81
1 files changed, 81 insertions, 0 deletions
diff --git a/bin/oss-fuzz-build.sh b/bin/oss-fuzz-build.sh
new file mode 100755
index 000000000..d0a206e33
--- /dev/null
+++ b/bin/oss-fuzz-build.sh
@@ -0,0 +1,81 @@
+#!/usr/bin/env bash
+
+set -e
+
+if [ -z "${OUT}" ] || [ -z "${SRC}" ] || [ -z "${WORK}" ]; then
+ echo "OUT, SRC or WORK not set - script expects to be called inside oss-fuzz build env"
+ exit 1
+fi
+
+print_stamp()
+{
+ local do_df="$1"; shift
+ echo "[[" `date -u` "]]" "build -" "$@"
+ if [ "$do_df" != "0" ]; then
+ df -h $OUT $WORK
+ fi
+}
+
+print_stamp 1 start
+echo git: `git -C $SRC/libreoffice log -1 --pretty=reference`
+
+#shuffle CXXFLAGS -stdlib=libc++ arg into CXX as well because we use
+#the CXX as the linker and need to pass -stdlib=libc++ to build
+export CXX="$CXX -stdlib=libc++ -fsanitize-blacklist=$SRC/libreoffice/bin/sanitize-excludelist.txt"
+export CXX_FOR_BUILD="$CXX"
+export CC="$CC -fsanitize-blacklist=$SRC/libreoffice/bin/sanitize-excludelist.txt"
+export CC_FOR_BUILD="$CC"
+#similarly force the -fsanitize etc args in as well as pthread to get
+#things to link successfully during the build
+export LDFLAGS="$CFLAGS -Wl,--compress-debug-sections,zlib -lpthread"
+#build-time concat-deps tool leaks a titch
+export ASAN_OPTIONS="detect_leaks=0"
+
+cd $WORK
+if [ -f Makefile ]; then
+ print_stamp 0 clean
+ make clean
+fi
+
+print_stamp 0 autogen.sh
+$SRC/libreoffice/autogen.sh --with-distro=LibreOfficeOssFuzz --with-external-tar=$SRC/external-tar
+
+print_stamp 1 make
+make
+
+print_stamp 1 prepare '$OUT'
+
+pushd instdir/program
+head -c -14 services.rdb > templateservices.rdb
+tail -c +85 ./services/services.rdb >> templateservices.rdb
+for a in *fuzzer; do
+ #some minimal fonts required
+ mv $a $OUT
+ mkdir -p $OUT/$a.fonts
+ tar -x -C $OUT/$a.fonts --strip-components=1 --wildcards --no-anchored '*.ttf' -f $SRC/external-tar/liberation-fonts-ttf*
+ cp $SRC/external-tar/*opens___.ttf $OUT/$a.fonts
+ #minimal runtime requirements
+ cp templateservices.rdb $OUT/$a.services.rdb
+ cp types.rdb $OUT/$a.types.rdb
+ cp types/offapi.rdb $OUT/$a.moretypes.rdb
+ cat > $OUT/$a.unorc << EOF
+[Bootstrap]
+URE_INTERNAL_LIB_DIR=\${ORIGIN}
+UNO_TYPES=\${ORIGIN}/$a.types.rdb \${ORIGIN}/$a.moretypes.rdb
+UNO_SERVICES=\${ORIGIN}/$a.services.rdb
+EOF
+done
+popd
+
+#starting corpuses
+for zip_file in $SRC/*_seed_corpus.zip; do
+ cp $zip_file $OUT
+done
+
+#fuzzing dictionaries
+cp $SRC/*.dict $OUT
+
+#options files
+cp $SRC/libreoffice/vcl/workben/*.options $OUT
+
+print_stamp 1 end