summaryrefslogtreecommitdiffstats
path: root/tools/fuzzing/libfuzzer/clone_libfuzzer.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /tools/fuzzing/libfuzzer/clone_libfuzzer.sh
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/fuzzing/libfuzzer/clone_libfuzzer.sh')
-rwxr-xr-xtools/fuzzing/libfuzzer/clone_libfuzzer.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/fuzzing/libfuzzer/clone_libfuzzer.sh b/tools/fuzzing/libfuzzer/clone_libfuzzer.sh
new file mode 100755
index 0000000000..ca01df2978
--- /dev/null
+++ b/tools/fuzzing/libfuzzer/clone_libfuzzer.sh
@@ -0,0 +1,36 @@
+#!/bin/bash -e
+
+# Optionally get revision from cmd line
+[ $1 ] && REVISION=$1 || REVISION=76d07503f0c69f6632e6d8d4736e2a4cb4055a92
+
+mkdir tmp
+git clone --single-branch --no-checkout --shallow-since "2020-07-01" https://github.com/llvm/llvm-project tmp
+
+(cd tmp && git reset --hard $REVISION)
+
+# libFuzzer source files
+CPPS=($(ls tmp/compiler-rt/lib/fuzzer/*.cpp | sort -r))
+CPPS=(${CPPS[@]##*/})
+CPPS=(${CPPS[@]##FuzzerMain*}) # ignored
+CPPS=(${CPPS[@]##FuzzerInterceptors*}) # ignored
+
+# Update SOURCES entries
+sed -e "/^SOURCES/,/^]/ {/'/d}" -i moz.build
+for CPP in ${CPPS[@]}; do sed -e "/^SOURCES/ a \\ '${CPP}'," -i moz.build; done
+
+# Remove previous files
+rm *.{cpp,h,def}
+
+# Copy files
+cp tmp/compiler-rt/lib/fuzzer/*.{cpp,h,def} .
+
+# Apply local patches
+for patch in patches/*.patch
+do
+ patch -p4 < $patch
+done
+
+# Remove the temporary directory
+rm -Rf tmp/
+
+echo "Updated libFuzzer to ${REVISION}"