mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-09 06:50:49 +00:00
3c7610bd9f
- Add -s flag to use att syntax instead of intel one - Flag -A is the new -a (show selected arch) - Some more work on the arm code generation backend - Simplify some code (-58LOC) - Finish manpage rarc2(1)
59 lines
1003 B
Bash
Executable File
59 lines
1003 B
Bash
Executable File
#!/bin/sh
|
|
# pancake / nopcode.org
|
|
|
|
[ -z "${ARCH}" ] && ARCH=`rarc2 -A`
|
|
|
|
compile() {
|
|
spp -h 2>&1 >/dev/null
|
|
if [ $? = 0 ]; then
|
|
spp -Darch=${ARCH} $@ | rarc2 -s -${ARCH} > .a.S || exit $?
|
|
else
|
|
rarc2 -s -${ARCH} $@ > .a.S || exit $?
|
|
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 $@
|
|
;;
|
|
"-cx"|"-xc")
|
|
compile $@
|
|
gcc .a.S -o .a.out
|
|
[ -e .a.out ] && ./.a.out
|
|
rm -f .a.S .a.out
|
|
;;
|
|
"-c")
|
|
compile $@
|
|
gcc .a.S -o .a.out
|
|
[ -e .a.out ] && cp .a.out $1.out
|
|
rm -f .a.S .a.out
|
|
;;
|
|
"-x")
|
|
compile $@
|
|
gcc -nostdlib .a.S -o .a.out
|
|
if [ -e .a.out ]; then
|
|
bytes=`rabin2 -o d/S/.text .a.out`
|
|
rasc -s $bytes -X
|
|
fi
|
|
rm -f .a.S .a.out
|
|
;;
|
|
*)
|
|
echo "Usage: rarc2-tool [-flag] [file]"
|
|
echo " -b dump bytes"
|
|
echo " -x execute"
|
|
echo " -c compile against libc"
|
|
echo " -S only generate .S file"
|
|
echo "ARCH: environ to set architecture: arm, x86, x64"
|
|
;;
|
|
esac
|