radare2/binr/old.rarc2/rarc2-tool
pancake 429a475ac0 * Deprecate rarc2 and rarc2-tool
- Replaced by ragg2 - the new r_egg based tool for r2
* Add r_egg_assemble as a 2nd step for compilation
* Fix memory leak in r_egg_free
* Add support for 'cmp' and more 'test' variants for x86.nz
  - Ignore 'dword ptr' string
  - More test cases
* Fix SCSIZE issue in rasc2 -s

--HG--
rename : binr/rarc2/Makefile => binr/old.rarc2/Makefile
rename : binr/rarc2/README => binr/old.rarc2/README
rename : binr/rarc2/config.def.h => binr/old.rarc2/config.def.h
rename : binr/rarc2/config.h => binr/old.rarc2/config.h
rename : binr/rarc2/emit_arm.c => binr/old.rarc2/emit_arm.c
rename : binr/rarc2/emit_x64.c => binr/old.rarc2/emit_x64.c
rename : binr/rarc2/emit_x86.c => binr/old.rarc2/emit_x86.c
rename : binr/rarc2/i/libc.r => binr/old.rarc2/i/libc.r
rename : binr/rarc2/i/socket.r => binr/old.rarc2/i/socket.r
rename : binr/rarc2/osxtest.r => binr/old.rarc2/osxtest.r
rename : binr/rarc2/out.c => binr/old.rarc2/out.c
rename : binr/rarc2/rarc2-tool => binr/old.rarc2/rarc2-tool
rename : binr/rarc2/rarc2.c => binr/old.rarc2/rarc2.c
rename : binr/rarc2/rarc2.h => binr/old.rarc2/rarc2.h
rename : binr/rarc2/t/Makefile => binr/old.rarc2/t/Makefile
rename : binr/rarc2/t/argv.r => binr/old.rarc2/t/argv.r
rename : binr/rarc2/t/bytedump.r => binr/old.rarc2/t/bytedump.r
rename : binr/rarc2/t/data.r => binr/old.rarc2/t/data.r
rename : binr/rarc2/t/dump.r => binr/old.rarc2/t/dump.r
rename : binr/rarc2/t/hello.r => binr/old.rarc2/t/hello.r
rename : binr/rarc2/t/hi.r => binr/old.rarc2/t/hi.r
rename : binr/rarc2/t/if.r => binr/old.rarc2/t/if.r
rename : binr/rarc2/t/inline.r => binr/old.rarc2/t/inline.r
rename : binr/rarc2/t/input.r => binr/old.rarc2/t/input.r
rename : binr/rarc2/t/loop.r => binr/old.rarc2/t/loop.r
rename : binr/rarc2/t/ptr.r => binr/old.rarc2/t/ptr.r
rename : binr/rarc2/t/rawsys.r => binr/old.rarc2/t/rawsys.r
rename : binr/rarc2/t/rawsys64.r => binr/old.rarc2/t/rawsys64.r
rename : binr/rarc2/t/regs.r => binr/old.rarc2/t/regs.r
rename : binr/rarc2/t/ret.r => binr/old.rarc2/t/ret.r
rename : binr/rarc2/t/room.r => binr/old.rarc2/t/room.r
rename : binr/rarc2/t/segfault.r => binr/old.rarc2/t/segfault.r
rename : binr/rarc2/t/shell.r => binr/old.rarc2/t/shell.r
rename : binr/rarc2/t/sub.r => binr/old.rarc2/t/sub.r
rename : binr/rarc2/t/syscall.r => binr/old.rarc2/t/syscall.r
rename : binr/rarc2/test.r => binr/old.rarc2/test.r
rename : libr/egg/t/syscall.r => binr/ragg2/syscall.r
2011-08-08 02:07:26 +02:00

92 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
# radare2 -- 2010-2011 -- pancake / nopcode.org
# TODO: execute in this way? rasc -s $bytes -X
[ -z "${ARCH}" ] && ARCH=`rarc2 -A`
[ -z "${CC}" ] && CC=gcc
RF="-s"
compile() {
spp -h >/dev/null 2>&1
if [ $? = 0 ]; then
spp -Darch=${ARCH} $@ | rarc2 $RF -a${ARCH} > .a.S || exit $?
else
rarc2 $RF -a${ARCH} $@ > .a.S || exit $?
fi
}
help() {
cat << EOF
Usage: rarc2-tool [-flag] [file]
-b dump bytes
-n use nasm instead of gas
-x execute
-c [elf,mach0,pe] - select output format (-r is implicit)
-r use intel syntax and rasm2 to display hexpairs
-c compile against libc
-S only generate .S file
ARCH: environ to set architecture: arm, x86, x64
EOF
exit 1
}
while getopts rnbSxc: o ; do
[ "$o" = "?" ] && help
case "$o" in
c) r=1; c="$OPTARG" ;;
*) eval $o=1 ;;
esac
done
shift $((${OPTIND}-1))
if [ -n "`echo $@`" ]; then
if [ -n "$r" ]; then
RF=""
ARCH=x86
n=1
elif [ -n "$n" ]; then
RF=""
fi
compile $@
if [ -n "$c" ]; then
# rasm2 and rabin2
rasm2 -a x86.olly -f .a.S > .a.x
rabin2 -a x86_32 -c $c:$(cat .a.x) $1.out
elif [ -n "$r" ]; then
rasm2 -a x86.olly -f .a.S
elif [ -n "$n" ]; then
# nasm
cat .a.S | grep -v '^#' | sed -e 's, ptr , ,g' | \
grep -v 'intel_syntax' | \
sed -e 's|^\.||' | \
awk '{if (/^equ /){gsub(","," ");/(.*) (.*) (.*)/;print $2" equ "$3;}else {print}}' | \
sed -e 's|lea eax, dword|lea eax, |g' > .a.S2
#echo 'section .text' > .a.S
mv .a.S2 .a.S
nasm -f elf .a.S
ld -e main .a.o -o .a.out
else
# gcc (default)
if [ -n "$c" ]; then
${CC} .a.S -o .a.out
else
${CC} -nostdlib .a.S -o .a.out
fi
fi
if [ -e .a.out ]; then
if [ -n "$b" ]; then
rabin2 -O d/S/.text .a.out
else
if [ -n "$x" ]; then
./.a.out
else
cp .a.out $1.out
fi
fi
fi
rm -f .a.S .a.x .a.out
else
help
fi