Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
# With this step, we remove some additional debug infos from binaries, that, if
# present, some decompilers take advantage to perform optimizations orthogonal
# to our evaluation purposes.
if [ $# -eq 0 ]; then
echo "No arguments supplied"
exit 1
fi
arch=$1
basepath=$(pwd)
workdir=$basepath/workdir-$arch
stripped_dir=$workdir/stripped
if [ ! -d $stripped_dir ]; then
mkdir $stripped_dir;
fi
cd $arch
# Use the `objcopy` tool to remove the `.dynstr` section from the ELF
for filename in *
do
echo "Removing the .dynstr section from the ELF"
if [[ "$arch" == "x86-64"* ]]; then
cp $filename $stripped_dir/$filename.stripped
$basepath/scripting/ida-extraction-scripts/elf-replace-dynstr.py $stripped_dir/$filename.stripped
else
echo "Unsupported architecture"
exit 1
fi
done;
# Use the `strip` tool to remove dbg info
for filename in *
do
echo "Stripping input: $filename"
if [[ "$arch" == "x86-64"* ]]; then
strip --strip-debug $stripped_dir/$filename.stripped
elif [[ "$arch" == "arm"* ]]; then
armv7a-hardfloat-linux-uclibceabi-strip --strip-debug $stripped_dir/$filename.stripped
elif [[ "$arch" == "mips"* ]]; then
mips-unknown-linux-musl-strip --strip-debug $stripped_dir/$filename.stripped
else
echo "Unsupported architecture"
exit 1
fi
done;