Skip to content

Commit bd950f3

Browse files
committed
csexec-symbiotic.sh: Improve the wrapper script
* `linux-ld` and `--argv0` arguments are now skipped automatically * Arguments for symbiotic are now parsed correctly
1 parent 19f3232 commit bd950f3

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

csexec-symbiotic.sh

+38-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,49 @@
1-
#!/bin/bash
1+
#!/usr/bin/bash
22

3-
# USAGE:
4-
#
5-
# 1) Build the source with gllvm and CFLAGS internally used by Symbiotic.
6-
# 2) CSEXEC_WRAP_DONT_USE_LD=1 \
7-
# CSEXEC_WRAP_CMD=$'csexec-symbiotic.sh\a--prp=memsafety' make check
8-
# 3) Wait for some time.
9-
# 4) ...
10-
# 5) Profit!
3+
usage() {
4+
cat << EOF
5+
USAGE:
6+
1) Build the source with gllvm and CFLAGS internally used by Symbiotic and
7+
LDFLAGS='-Wl,--dynamic-linker=/usr/bin/csexec-loader'.
8+
2) CSEXEC_WRAP_CMD=$'csexec-symbiotic.sh\a--prp=memsafety' make check
9+
3) Wait for some time.
10+
4) ...
11+
5) Profit!
12+
EOF
13+
}
1114

1215
set -e
1316

14-
SYMBIOTIC_ARGS="$1"
15-
BINARY="$2"
16-
BINARY_ARGV="$3"
17+
if [ $# -eq 0 ]; then
18+
usage
19+
exit 1
20+
fi
21+
22+
i=1
23+
while [ ! -e ${!i} ]; do
24+
SYMBIOTIC_ARGS="$SYMBIOTIC_ARGS ${!i}"
25+
((i++))
26+
done
27+
28+
# Skip LD_LINUX_SO
29+
((i++))
30+
31+
# Skip --argv0
32+
if [ ${!i} = "--argv0" ]; then
33+
((i += 2))
34+
fi
35+
36+
BINARY="${!i}"
37+
((i++))
38+
39+
BINARY_ARGV="${!i}"
40+
((i++))
1741

18-
i=4
1942
while [ $i -le $# ]; do
2043
BINARY_ARGV="$BINARY_ARGV,${!i}"
2144
((i++))
2245
done
2346

2447
get-bc "$BINARY" 1> /dev/tty 2>&1
25-
echo "Executing $SYMBIOTIC_ARGS --argv='$BINARY_ARGV' $BINARY.bc" 1> /dev/tty 2>&1
26-
symbiotic $SYMBIOTIC_ARGS --argv="'$BINARY_ARGV'" "$BINARY.bc" 1> /dev/tty 2>&1
48+
echo "Executing 'symbiotic$SYMBIOTIC_ARGS --argv='$BINARY_ARGV' $BINARY.bc'" 1> /dev/tty 2>&1
49+
exec symbiotic $SYMBIOTIC_ARGS --argv="'$BINARY_ARGV'" "$BINARY.bc" 1> /dev/tty 2>&1

do_SRPM.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ tar -Jcf "symbiotic-$VER.tar.xz" "symbiotic-$VER"
5858
cat > symbiotic.spec << EOF
5959
Name: $PKG
6060
Version: $VER
61-
Release: 2%{?dist}
61+
Release: 3%{?dist}
6262
Summary: Tool for analysis of sequential computer programs written in C
6363
License: Free
6464
URL: https://github.com/staticafi/%{name}

0 commit comments

Comments
 (0)