Newer
Older
#
# SMP-analyze.sh - perform SMP analysis on a binary file.
#
# Copyright (c) 2000, 2001, 2010 - University of Virginia
#
# This file is part of the Memory Error Detection System (MEDS) infrastructure.
# This file may be used and modified for non-commercial purposes as long as
# all copyright, permission, and nonwarranty notices are preserved.
# Redistribution is prohibited without prior written consent from the University
# of Virginia.
#
# Please contact the authors for restrictions applying to commercial use.
#
# THIS SOURCE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# Author: University of Virginia
# e-mail: jwd@virginia.com
# URL : http://www.cs.virginia.edu/
#
#
export TVOPT=ansi
# Set IDA path.
export IDADIR=$IDAROOT
# Make sure that the idal executable can be reached from PATH.
# Extract the code addresses with objdump.
$PS_OBJDUMP -d --prefix-addresses $1 | grep "^[0-9]" > $1.SMPobjdump
# Extract the exception-handling function target addresses.
# dwarfdump -F $1 | grep "^<" | cut --delimiter="<" --field=3 | cut --delimiter=":" --field=1 | cut --bytes 4-10 > $1.eh_frame_addrs
# Make readelf do the same thing as the above dwarfdump command, to
# eliminate configuration dependence on dwarfdump.
readelf -wF $1 | grep "pc=" | cut --delimiter="=" --field=3 | cut --delimiter="." --field=1 > $1.eh_frame_addrs
if [ "${IDAROOT}"X = "X" ]; then echo Please set IDAROOT; exit 1; fi
if [ ! -f ${IDAROOT}/libida.so ]; then echo IDAROOT is set poorly, please fix.; exit 1; fi
# remove tmp files
rm -f $1.id? $1.{nam,til,log,syms} `basename $1 .ncexe`.id?
OVERRIDE_PLUGIN=$GRACE_HOME/concolic/bin/liboverride_smpsa_plugin.so
fi
jdh8d
committed
# determine if this binary in question is 32-bit or 64-bit.
#file $1|grep -q "32-bit" >/dev/null 2>&1
#res=$?
#if [ $res = 1 ]; then
# myidal=idal64
# rm -f `basename $1 .ncexe`.i64
#else
# myidal=idal
#fi
# we can always use idal64, as it analyzes 32-bit binaries just fine. May use a bit more space, but isn't typically a problem.
myidal=idal64
jdh8d
committed
#
# if TVHEADLESS is set, call idal on the idapro server
#
echo TVHEADLESS is $TVHEADLESS
if [ $TVHEADLESS"X" != "X" ]; then
mc2zk
committed
case "$IDAROOT" in
*idapro5* )
mc2zk
committed
echo Please set \$STRATA
exit -1
fi
echo connecting...
$STRATA/tools/idaprod/idaprod_client $SMPSA_HOME $IDAROOT $PWD $1 `ulimit -t`
echo did server IDA
;;
TVHEADLESS=1 yes
| LD_PRELOAD=$OVERRIDE_PLUGIN time ${IDAROOT}/$myidal -A -SSMP.idc -L${IDALOG} $1 > $1.idaoutput 2>&1
echo "Finished TVHEADLESS IDA"
;;
*)
echo Cannot determine idapro version: $IDAROOT
exit 1
;;
mc2zk
committed
esac
LD_PRELOAD=$OVERRIDE_PLUGIN time ${IDAROOT}/$myidal -A -SSMP.idc $1
mc2zk
committed
# SMP seems to mess up the terminal, using this to fix it.
/usr/bin/reset || true
stty $old_stty || true
$PEASOUP_HOME/tools/add_ifunc_attr.sh $1 $1.annot
# SMP seems to mess up the terminal, using this to fix it.
mc2zk
committed
#/usr/bin/reset || true
#stty $old_stty || true