#!/bin/sh -x # # 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/ # # # Make terminal ansi-color export TVOPT=ansi # Set IDA path. export IDADIR=$IDAROOT # Make sure that the idal executable can be reached from PATH. export PATH=$PATH:$IDADIR export IDALOG=$1.log export IDALOG_SILENT=1 # Extract the code addresses with objdump. objdump -d --prefix-addresses $1 | grep "^[0-9]" > $1.SMPobjdump 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? old_stty=`stty -g` || true # Run the linux IDA Pro with the SMPStaticAnalyzer plugin. # jdh - added -B for batch mode, avoids any prompts. # jdh - note: can't use -B, as the plugin doesn't run! #time ${IDAROOT}/idal -A -Telf -OSMPStaticAnalyzer:run $1 2>&1 >/dev/null # # if TVHEADLESS is set, call idal on the idapro server # echo TVHEADLESS is $TVHEADLESS if [ $TVHEADLESS"X" != "X" ]; then echo attempting server IDA if [ ! -n $STRATA ]; then 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 else time ${IDAROOT}/idal -A -SSMP.idc $1 echo did local IDA fi # SMP seems to mess up the terminal, using this to fix it. /usr/bin/reset || true stty $old_stty || true # Get the output file SMP.syms into $1.syms. # mv SMP.annot $1.annot