2010-02-25 23:50:23 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# pancake / nopcode.org
|
|
|
|
|
2010-06-29 14:50:15 +00:00
|
|
|
[ -z "${ARCH}" ] && ARCH=`rarc2 -A`
|
2010-02-25 23:50:23 +00:00
|
|
|
|
|
|
|
compile() {
|
|
|
|
spp -h 2>&1 >/dev/null
|
|
|
|
if [ $? = 0 ]; then
|
2010-06-29 14:50:15 +00:00
|
|
|
spp -Darch=${ARCH} $@ | rarc2 -s -${ARCH} > .a.S || exit $?
|
2010-02-25 23:50:23 +00:00
|
|
|
else
|
2010-06-29 14:50:15 +00:00
|
|
|
rarc2 -s -${ARCH} $@ > .a.S || exit $?
|
2010-02-25 23:50:23 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
flg=$1
|
|
|
|
shift
|
|
|
|
case "$flg" in
|
|
|
|
"-b")
|
|
|
|
compile $@
|
|
|
|
gcc -nostdlib .a.S -o .a.out
|
|
|
|
if [ -e .a.out ]; then
|
|
|
|
rabin2 -o d/S/.text .a.out
|
|
|
|
rm -f .a.S .a.out
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
"-S")
|
|
|
|
compile $@
|
|
|
|
;;
|
2010-06-28 18:30:20 +00:00
|
|
|
"-cx"|"-xc")
|
|
|
|
compile $@
|
|
|
|
gcc .a.S -o .a.out
|
|
|
|
[ -e .a.out ] && ./.a.out
|
|
|
|
rm -f .a.S .a.out
|
|
|
|
;;
|
2010-02-25 23:50:23 +00:00
|
|
|
"-c")
|
|
|
|
compile $@
|
|
|
|
gcc .a.S -o .a.out
|
2010-06-28 18:30:20 +00:00
|
|
|
[ -e .a.out ] && cp .a.out $1.out
|
2010-02-25 23:50:23 +00:00
|
|
|
rm -f .a.S .a.out
|
|
|
|
;;
|
|
|
|
"-x")
|
|
|
|
compile $@
|
|
|
|
gcc -nostdlib .a.S -o .a.out
|
|
|
|
if [ -e .a.out ]; then
|
2010-06-28 18:30:20 +00:00
|
|
|
bytes=`rabin2 -o d/S/.text .a.out`
|
2010-02-25 23:50:23 +00:00
|
|
|
rasc -s $bytes -X
|
|
|
|
fi
|
|
|
|
rm -f .a.S .a.out
|
|
|
|
;;
|
|
|
|
*)
|
2010-06-28 18:30:20 +00:00
|
|
|
echo "Usage: rarc2-tool [-flag] [file]"
|
2010-02-25 23:50:23 +00:00
|
|
|
echo " -b dump bytes"
|
|
|
|
echo " -x execute"
|
|
|
|
echo " -c compile against libc"
|
|
|
|
echo " -S only generate .S file"
|
2010-06-28 18:30:20 +00:00
|
|
|
echo "ARCH: environ to set architecture: arm, x86, x64"
|
2010-02-25 23:50:23 +00:00
|
|
|
;;
|
|
|
|
esac
|