From e42a37b8d8205f9cebd97a6de793d64d1b5c0e78 Mon Sep 17 00:00:00 2001
From: Anh <zenpoems@gmail.com>
Date: Mon, 27 Aug 2018 14:17:37 +0000
Subject: [PATCH] Add script to setup binutils for testing

---
 test/bench/binutils.spec     |  3 +++
 test/bench/build_zafl.sh     | 31 +++++++++++++++++++++++++++++++
 test/bench/download.sh       |  7 +++++++
 test/bench/setup_binutils.sh |  8 ++++++++
 4 files changed, 49 insertions(+)
 create mode 100755 test/bench/binutils.spec
 create mode 100755 test/bench/build_zafl.sh
 create mode 100755 test/bench/download.sh
 create mode 100755 test/bench/setup_binutils.sh

diff --git a/test/bench/binutils.spec b/test/bench/binutils.spec
new file mode 100755
index 0000000..c425a16
--- /dev/null
+++ b/test/bench/binutils.spec
@@ -0,0 +1,3 @@
+#binutils_binaries="size strings readelf objdump cxxfilt ar"
+binutils_binaries="objdump cxxfilt ar strip-new nm-new"
+binutils_binaries="cxxfilt"
diff --git a/test/bench/build_zafl.sh b/test/bench/build_zafl.sh
new file mode 100755
index 0000000..3873e2e
--- /dev/null
+++ b/test/bench/build_zafl.sh
@@ -0,0 +1,31 @@
+SCRIPT=$(readlink -f $0)                                                                            
+
+cd $(dirname $SCRIPT)
+source binutils.spec
+
+echo "Zafl $binutils_binaries"
+
+for b in $binutils_binaries
+do
+	zafl_dir="${b}_zafl"
+	if [ ! -d $zafl_dir ];
+	then
+		mkdir ${b}_zafl
+	fi
+
+	cp binutils-gdb/binutils/$b ${b}_zafl/
+
+	pushd $zafl_dir
+	echo "Remove any remnants of previous analysis runs"
+	rm -fr peasoup_exec*
+	echo "Building Zafl version of $b"
+	$PSZ ./$b ${b}.zafl -c move_globals=on -c zafl=on -o move_globals:--elftables -o zipr:--traceplacement:on -o zipr:true -o zafl:--stars 
+
+	ln -s $SECURITY_TRANSFORMS_HOME/lib/libzafl.so .
+
+	if [ ! -d in ]; then
+		mkdir in
+	fi
+	echo "1" > in/1
+	popd
+done
diff --git a/test/bench/download.sh b/test/bench/download.sh
new file mode 100755
index 0000000..ec116fe
--- /dev/null
+++ b/test/bench/download.sh
@@ -0,0 +1,7 @@
+wget http://ftp.gnu.org/gnu/gzip/gzip-1.9.tar.gz
+tar -zxf gzip*.tar.gz
+
+wget http://ftp.gnu.org/gnu/bc/bc-1.07.tar.gz                                                                                 
+tar -zxf bc*.tar.gz
+
+git clone git://sourceware.org/git/binutils-gdb.git
diff --git a/test/bench/setup_binutils.sh b/test/bench/setup_binutils.sh
new file mode 100755
index 0000000..70f19c5
--- /dev/null
+++ b/test/bench/setup_binutils.sh
@@ -0,0 +1,8 @@
+pushd binutils-gdb
+make clean distclean
+rm -fr config.cache
+rm -fr */config.cache
+rm -fr */*/config.cache
+./configure
+make clean all
+popd
-- 
GitLab