Skip to content
Snippets Groups Projects
Commit ff32faad authored by an7s's avatar an7s
Browse files

Generate a shload of mul overflow tests

parent b97e7679
No related branches found
No related tags found
No related merge requests found
...@@ -147,6 +147,7 @@ examples/dumbledore_cmd.c -text ...@@ -147,6 +147,7 @@ examples/dumbledore_cmd.c -text
examples/integerbug.c -text examples/integerbug.c -text
examples/mul/generate_cprogs.sh -text examples/mul/generate_cprogs.sh -text
examples/mul/mul.ctmpl -text examples/mul/mul.ctmpl -text
examples/mul/mul.shtmpl -text
examples/overflow1.c -text examples/overflow1.c -text
examples/test1.c -text examples/test1.c -text
libIRDB/Makefile -text libIRDB/Makefile -text
......
#!/bin/bash #!/bin/bash
#types="char short int long unsigned+char unsigned+short unsigned+int unsigned+long"; #types="char short int long unsigned+char unsigned+short unsigned+int unsigned+long";
types="int char" types="char short"
sharedlib_gccflags="-O -O2 -fomit-frame-pointer"
#types="int char"
#
# The flags passed to the compiler
#
# note use of + to denote multiple parameters together.
# (but you can't use + as an argument to gcc.)
#
create_test()
{
my_benchname=$1
my_benchflag=$2
my_gccflag=$3
my_libtype=$4
#
# demangle the internal representation of the benchflags and gcc flags
# substitute a + with a space
#
real_benchflag=`echo $my_benchflag | sed "s/+/ /g"`
real_gccflag=`echo $my_gccflag | sed "s/+/ /g"`
#
# mangle the benchflags and gccflags for filename display.
#
disp_benchflag=$my_benchflag
disp_gccflag=$my_gccflag
#
# if the name is empty, reset to a nice string for naming. Note: This means you should not use "empty" as a parameter.
#
if [ $my_benchflag"X" = "X" ]; then disp_benchflag="nobenchflag"; fi;
if [ $my_gccflag"X" = "X" ]; then disp_gccflag="nogccflag"; fi;
scriptname=$my_benchname.$disp_gccflag.$disp_benchflag.test.sh
#
# demangle the internal representation of the benchflags and gcc flags
# substitute a + with a space
#
real_gccflag=`echo $my_gccflag | sed "s/+/ /g"`
cat mul.shtmpl | \
sed "s/@BENCHNAME@/$my_benchname/g" | \
sed "s/@LIBTYPE@/$my_libtype/g" | \
sed "s/@COMPFLAGS@/$real_gccflag/g" \
> $scriptname
added_files="$scriptname $added_files"
}
create_prog() create_prog()
{ {
...@@ -29,7 +82,7 @@ create_prog() ...@@ -29,7 +82,7 @@ create_prog()
"unsigned+long") format_specifier="%ul" ;; "unsigned+long") format_specifier="%ul" ;;
esac esac
# create the program. # create the source .c program.
cat mul.ctmpl | \ cat mul.ctmpl | \
sed "s/#FUNCTION_NAME#/$function_name/g" | \ sed "s/#FUNCTION_NAME#/$function_name/g" | \
sed "s/#FORMAT_SPECIFIER#/$format_specifier/g" | \ sed "s/#FORMAT_SPECIFIER#/$format_specifier/g" | \
...@@ -37,9 +90,11 @@ create_prog() ...@@ -37,9 +90,11 @@ create_prog()
sed "s/#TYPE2#/$real_type2/g" \ sed "s/#TYPE2#/$real_type2/g" \
> $progname.c > $progname.c
gcc -w $progname.c -o $progname.orig.exe for gccflag in $sharedlib_gccflags
do
$PEASOUP_HOME/tools/ps_analyze.sh $progname.orig.exe $progname.protected.exe --step ilr=off --step p1transform=off --step concolic=off create_test $progname_c "" "$gccflag" shared_lib
done
} }
for type1 in $types for type1 in $types
...@@ -48,6 +103,11 @@ do ...@@ -48,6 +103,11 @@ do
do do
progname_c=mul.$type1.$type2 progname_c=mul.$type1.$type2
# actually create the .c program # actually create the .c program
create_prog $progname_c "$type1" "$type2" static_lib create_prog $progname_c "$type1" "$type2"
done done
done done
chmod +x *.sh
echo "would have added: $added_files"
#!/bin/sh
# Assumptions:
# $1 is the full pathname to output file
# For PEASOUP, Required XML fields are
# name - name of the test
# host - name of the host where the test was run
# project - project name
# date_time - date time in specific format date +%FT%R:%S
# key_value pairs, any number
# may include result, user, host platform, build platform
# Fixed attributes
# ATTRIBUTE ModDep=strata
# ATTRIBUTE ModDep=diablo_toolchain
# ATTRIBUTE ModDep=binutils-2.19
# ATTRIBUTE ModDep=stratafier
# ATTRIBUTE ModDep=idapro51
# ATTRIBUTE ModDep=idapro51_sdk
# ATTRIBUTE TestsWhat=lang_C
# ATTRIBUTE TestsWhat=strata
# ATTRIBUTE TestsWhat=interoverflow
# ATTRIBUTE TestsWhat=@LIBTYPE@
# ATTRIBUTE OS=linux
# ATTRIBUTE BenchmarkSuite=IntegerOverflow
# ATTRIBUTE Compiler=gcc
# ATTRIBUTE Arch=x86_32
# Filled in by test generator
# ATTRIBUTE TestName="@BENCHNAME@.c"
# ATTRIBUTE BenchmarkName=@BENCHNAME@
# ATTRIBUTE CompilerFlags="@COMPFLAGS@"
BENCHNAME=@BENCHNAME@
COMPFLAGS="@COMPFLAGS@"
outfile=$1
cleanup()
{
exit_code=$1
shift
msg=$*
if [ $exit_code -ne 0 ]; then
report_test_failure $outfile "Intermediate step failed, exit code is $exit_code, msg='$msg'"
fi
basename_orig=`basename $orig .ncexe`
rm -f $orig strata.$$ tmp1.$$ stratafier.o.exe $orig.annot $orig.{log,SMPobjdump} $basename_orig.{idb,asm}
exit $exit_code
}
# suck in utils
. ${TEST_HARNESS_HOME}/test_utils.sh || cleanup 1 "Cannot source utils file"
assert_test_args $*
assert_test_env $outfile STRATAFIER STRATA TOOLCHAIN STRATAFIER_OBJCOPY IDAROOT IDASDK
# path to source
testloc=`pwd`
orig=orig$$.exe
# compile
gcc ${testloc}/$BENCHNAME.c $COMPFLAGS -o $orig || cleanup 2 "gcc failed"
# sanity check compile
if [ ! -f $orig ]; then cleanup 3 "Failed to create $orig"; fi
$PEASOUP_HOME/tools/ps_analyze.sh $orig $orig.protected --step ilr=off --step p1transform=off --step concolic=off
${testloc}/$orig.protected | grep -i "overflow detected"
if [ ! $? -eq 0 ]; then
report_test_failure $outfile "Did not detect overflow" || cleanup 4 "Reporting failed?"
fi
# cleanup
cleanup 0 "Success!"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment