/usr/lib/radare/bin/asm is in radare-common 1:1.5.2-6.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | #!/bin/sh
#
# Commandline assembler tool for radare
#
# --author pancake
CODE="$1"
CODE=`echo ${CODE} | sed -e 's,;,\n,g'`
[ -z "${SYNTAX}" ] && SYNTAX="intel"
FILE=`mktemp`
[ "$1" = "-h" ] && CODE=""
if [ -z "${CODE}" ]; then
echo "Usage: rsc asm [-|'movl \$0x14b0, %eax']" > /dev/stderr
echo "NASM=0,1 ; use nasm or gas" > /dev/stderr
echo "AASM=0,1 ; use aasm or gas (aasm by default)" > /dev/stderr
echo "ARCH=intel,arm,java ; intel by default" > /dev/stderr
echo "CURSOR=0x804800 ; base address" > /dev/stderr
exit 0
fi
[ -z "${AASM}" ] && AASM="1"
# JAVA
if [ "${ARCH}" = "java" ]; then
rsc javasm -a "$CODE"
exit 0
fi
# ARM
if [ "${ARCH}" = "arm" ]; then
if [ "${AASM}" = "1" ]; then
echo "${CODE}" >> ${FILE}
armasm -x - ${FILE}
rm -f ${FILE}
echo
exit 0
else
NASM=0
fi
fi
# Intel NASM is used by default
[ -z "$NASM" ] && NASM=1
if [ -z "`rsc path nasm`" ]; then
NASM=0
fi
ORG="0x0"
if [ -n "${CURSOR}" ]; then
ORG="${CURSOR}"
fi
if [ 1 = ${NASM} ]; then
FILE="$FILE.asm"
printf "BITS 32\nSECTION .text\nORG ${ORG}\nglobal _start\n\n_start:\n" > $FILE
if [ "${CODE}" = "-" ]; then
cat >> $FILE
else
echo "${CODE}" >> $FILE
fi
nasm -o $FILE.o $FILE
if [ ! $? = 0 ]; then
exit 1
fi
echo ":pX && q" | radare -nv ${FILE}.o
rm -f $FILE $FILE.o
else
FILE="${FILE}.s"
if [ "$SYNTAX" = "intel" ]; then
echo .intel_syntax noprefix > $FILE
else
: > $FILE
fi
if [ "${CODE}" = "-" ]; then
cat >> $FILE
else
echo "$1" >> $FILE
fi
as $FILE -o $FILE.o
if [ -e $FILE.o ]; then
objdump -wd $FILE.o | perl -ne 'if(/\d:\t/) { /\t(.*)\t/; print join(" ", split(" ",$1))." " ;}'
echo
rm -f $FILE $FILE.o
else
exit 1
fi
fi
exit 0
|