From 6ec832644ddb5d5402bab2a7cb2c7cecbb7d5322 Mon Sep 17 00:00:00 2001 From: jdh8d <jdh8d@git.zephyr-software.com> Date: Tue, 30 Aug 2011 17:47:56 +0000 Subject: [PATCH] Fixes to makefiles to support more options. Also added ability to ps_analyze to turn on/off for dynamically applied transforms (like heaprand). --- .gitattributes | 1 + dyna_examples/Makefile | 43 +++++++++++++++++++++++++++++- examples/Makefile | 42 ++++++++++++++++++++++++++++- stock_examples/Makefile | 50 ++++++++++++++++++++++++++++++++--- tools/do_makepeasoupbinary.sh | 4 ++- tools/ps_analyze.sh | 16 ++++++++--- tools/ps_run.sh | 31 ++++++++++++---------- tools/update_env_var.sh | 8 ++++++ 8 files changed, 172 insertions(+), 23 deletions(-) create mode 100755 tools/update_env_var.sh diff --git a/.gitattributes b/.gitattributes index 2a0593105..6c69de08c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -160,4 +160,5 @@ tools/ps_validate.sh -text tools/ps_validate_ss.deprecated.sh -text tools/set_dyna_link.sh -text tools/test_controller.sh -text +tools/update_env_var.sh -text tools/validate.sh -text diff --git a/dyna_examples/Makefile b/dyna_examples/Makefile index dc5e4d6ea..f50d8017e 100644 --- a/dyna_examples/Makefile +++ b/dyna_examples/Makefile @@ -14,6 +14,27 @@ LDFLAGS= exes=hanoi.protected hanoi_overrun.protected hanoi_heap_overrun.protected hanoi_stack_overrun.protected print_ptr.protected malloc.protected block_copy.protected hello.protected hanoi_overrun_tainted.protected hanoi_overrun_taintedenv.protected memcpy.protected cmd_args_005.protected dumbledore_stdin.protected dumbledore_cmd.protected dumbledore_file.protected ilr=on +stratafy_with_pc_confine=on +create_binary_script=on +heaprand=on +double_free=on +pc_confine=on +isr=on +meds_static=on +pdb_register=on +pdb_create_tables=on +meds2pdb=on +fill_in_cfg=on +fill_in_indtargs=on +clone=on +fix_calls=on +p1transform=on +integertransform=on +ilr=on +generate_spri=on +spasm=on + + all: env_check ${exes} @@ -26,7 +47,27 @@ all: env_check ${exes} ${LD} ${LDFLAGS} $< -o $@ .stock.protected: - ${PEASOUP_HOME}/tools/ps_analyze.sh $< $@ --step ilr=${ilr} + ${PEASOUP_HOME}/tools/ps_analyze.sh $< $@ \ + --step ilr=${ilr}\ + --step stratafy_with_pc_confine=${stratafy_with_pc_confine}\ + --step create_binary_script=${create_binary_script}\ + --step heaprand=${heaprand}\ + --step double_free=${double_free}\ + --step pc_confine=${pc_confine}\ + --step isr=${isr}\ + --step meds_static=${meds_static}\ + --step pdb_register=${pdb_register}\ + --step pdb_create_tables=${pdb_create_tables}\ + --step meds2pdb=${meds2pdb}\ + --step fill_in_cfg=${fill_in_cfg}\ + --step fill_in_indtargs=${fill_in_indtargs}\ + --step clone=${clone}\ + --step fix_calls=${fix_calls}\ + --step p1transform=${p1transform}\ + --step integertransform=${integertransform}\ + --step generate_spri=${generate_spri}\ + --step spasm=${spasm}\ + .c.o: ${PEASOUP_HOME}/tools/ps_comp.sh $< diff --git a/examples/Makefile b/examples/Makefile index 72bbee29d..fc7040f95 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -12,6 +12,26 @@ LD=DO_NOT_USE exes=hanoi.protected hanoi_overrun.protected hanoi_heap_overrun.protected hanoi_stack_overrun.protected print_ptr.protected malloc.protected block_copy.protected hello.protected hanoi_overrun_tainted.protected hanoi_overrun_taintedenv.protected memcpy.protected cmd_args_005.protected dumbledore_stdin.protected dumbledore_cmd.protected dumbledore_file.protected ilr=on +stratafy_with_pc_confine=on +create_binary_script=on +heaprand=on +double_free=on +pc_confine=on +isr=on +meds_static=on +pdb_register=on +pdb_create_tables=on +meds2pdb=on +fill_in_cfg=on +fill_in_indtargs=on +clone=on +fix_calls=on +p1transform=on +integertransform=on +ilr=on +generate_spri=on +spasm=on + all: env_check ${exes} @@ -21,7 +41,27 @@ all: env_check ${exes} ${PEASOUP_HOME}/tools/ps_link.sh $< -o $@ .stock.protected: - ${PEASOUP_HOME}/tools/ps_analyze.sh $< $@ --step ilr=${ilr} + ${PEASOUP_HOME}/tools/ps_analyze.sh $< $@ \ + --step ilr=${ilr}\ + --step stratafy_with_pc_confine=${stratafy_with_pc_confine}\ + --step create_binary_script=${create_binary_script}\ + --step heaprand=${heaprand}\ + --step double_free=${double_free}\ + --step pc_confine=${pc_confine}\ + --step isr=${isr}\ + --step meds_static=${meds_static}\ + --step pdb_register=${pdb_register}\ + --step pdb_create_tables=${pdb_create_tables}\ + --step meds2pdb=${meds2pdb}\ + --step fill_in_cfg=${fill_in_cfg}\ + --step fill_in_indtargs=${fill_in_indtargs}\ + --step clone=${clone}\ + --step fix_calls=${fix_calls}\ + --step p1transform=${p1transform}\ + --step integertransform=${integertransform}\ + --step generate_spri=${generate_spri}\ + --step spasm=${spasm}\ + .c.o: ${PEASOUP_HOME}/tools/ps_comp.sh $< diff --git a/stock_examples/Makefile b/stock_examples/Makefile index 5e9943fbd..cac8a6d10 100644 --- a/stock_examples/Makefile +++ b/stock_examples/Makefile @@ -2,12 +2,33 @@ CC=gcc CXX=g++ CFLAGS=-O2 -ilr=on .SUFFIXES: .stock .protected protected_exes=awk.protected bzip2.protected cal.protected cat.protected clear.protected date.protected df.protected diff.protected du.protected expr.protected find.protected grep.protected hostname.protected ipcs.protected less.protected ls.protected nasm.protected objdump.protected ps.protected sdiff.protected wc.protected whoami.protected xeyes.protected xcalc.protected +ilr=on +stratafy_with_pc_confine=on +create_binary_script=on +heaprand=on +double_free=on +pc_confine=on +isr=off +meds_static=on +pdb_register=on +pdb_create_tables=on +meds2pdb=on +fill_in_cfg=on +fill_in_indtargs=on +clone=on +fix_calls=on +p1transform=on +integertransform=on +ilr=on +generate_spri=on +spasm=on + + all: env_check ${protected_exes} .PHONY: env_check @@ -15,10 +36,30 @@ all: env_check ${protected_exes} .stock.protected: .PHONY - ${PEASOUP_HOME}/tools/ps_analyze.sh $< $@ --step ilr=${ilr} + ${PEASOUP_HOME}/tools/ps_analyze.sh $< $@ \ + --step ilr=${ilr}\ + --step stratafy_with_pc_confine=${stratafy_with_pc_confine}\ + --step create_binary_script=${create_binary_script}\ + --step heaprand=${heaprand}\ + --step double_free=${double_free}\ + --step pc_confine=${pc_confine}\ + --step isr=${isr}\ + --step meds_static=${meds_static}\ + --step pdb_register=${pdb_register}\ + --step pdb_create_tables=${pdb_create_tables}\ + --step meds2pdb=${meds2pdb}\ + --step fill_in_cfg=${fill_in_cfg}\ + --step fill_in_indtargs=${fill_in_indtargs}\ + --step clone=${clone}\ + --step fix_calls=${fix_calls}\ + --step p1transform=${p1transform}\ + --step integertransform=${integertransform}\ + --step generate_spri=${generate_spri}\ + --step spasm=${spasm}\ + -$(protected_exes): ${STRATA}/lib/x86_linux/libstrata.a +$(protected_exes): ${STRATA}/lib/x86_linux/libstrata.a .PHONY @@ -40,6 +81,9 @@ env_check: echo STRATA_HOME environment variable should be set.; \ exit -1;\ fi ; + @echo ---------------------------------------------------------- + @echo -------- Note that ISR is off by default here ------------ + @echo ---------------------------------------------------------- clean: diff --git a/tools/do_makepeasoupbinary.sh b/tools/do_makepeasoupbinary.sh index 6c700125f..08f39bc09 100755 --- a/tools/do_makepeasoupbinary.sh +++ b/tools/do_makepeasoupbinary.sh @@ -8,6 +8,8 @@ peasoup_binary=$name.sh echo "#!/bin/sh" >> $peasoup_binary echo "" >> $peasoup_binary -echo "$PEASOUP_HOME/tools/ps_run.sh $current_dir \"\$@\"" >> $peasoup_binary +echo "$current_dir/ps_run.sh $current_dir \"\$@\"" >> $peasoup_binary chmod +x $peasoup_binary +cp $PEASOUP_HOME/tools/ps_run.sh $current_dir + diff --git a/tools/ps_analyze.sh b/tools/ps_analyze.sh index 196060816..ec20abc73 100755 --- a/tools/ps_analyze.sh +++ b/tools/ps_analyze.sh @@ -43,7 +43,6 @@ check_options() while true ; do case "$1" in -s|--step) - echo "found option --step with argument $2" check_step_option $2 phases_off=" $phases_off $2 " shift 2 @@ -216,11 +215,12 @@ report_logs() for i in $all_logs do + stepname=`basename $i .log` echo >> $logfile echo ------------------------------------------------------- >> $logfile echo ----- From $i ------------------- >> $logfile echo ------------------------------------------------------- >> $logfile - cat $i |sed "s/^# ATTRIBUTE */# ATTRIBUTE renamed_for_ps/" >> $logfile + cat $i |sed "s/^# ATTRIBUTE */# ATTRIBUTE ps_$i_/" >> $logfile echo ------------------------------------------------------- >> $logfile echo >> $logfile done @@ -291,7 +291,7 @@ fi # set the threshold value. if a step errors with a more severe error (1=most severe, >1 lesser severe) # than the error_threshold, we exit. # -error_threshold=1 +error_threshold=0 # # record when we started processing: @@ -370,6 +370,16 @@ perform_step stratafy_with_pc_confine sh $STRATA_HOME/tools/pc_confinement/strat # This binary will really be a shell script that calls the newly stratafied binary # perform_step create_binary_script $PEASOUP_HOME/tools/do_makepeasoupbinary.sh $name +perform_step heaprand $PEASOUP_HOME/tools/update_env_var.sh STRATA_HEAPRAND 1 +perform_step double_free $PEASOUP_HOME/tools/update_env_var.sh STRATA_DOUBLE_FREE 1 +perform_step pc_confine $PEASOUP_HOME/tools/update_env_var.sh STRATA_PC_CONFINE 1 +perform_step isr $PEASOUP_HOME/tools/update_env_var.sh STRATA_PC_CONFINE_XOR 1 + + +STRATA_DOUBLE_FREE=0 +STRATA_HEAPRAND=0 +STRATA_PC_CONFINE=0 +STRATA_PC_CONFINE_XOR=0 # diff --git a/tools/ps_run.sh b/tools/ps_run.sh index ee6948d2f..34e999dbc 100755 --- a/tools/ps_run.sh +++ b/tools/ps_run.sh @@ -21,23 +21,26 @@ fi # Run the program with the proper env. vars set., and the arguments to the program specified # + +command=" +STRATA_DOUBLE_FREE=0 +STRATA_HEAPRAND=0 +STRATA_PC_CONFINE=0 +STRATA_PC_CONFINE_XOR=0 +STRATA_PC_CONFINE_XOR_KEY_LENGTH=1024 +STRATA_ANNOT_FILE=$datapath/a.ncexe.annot +STRATA_SIEVE=1 +STRATA_RC=1 +STRATA_PARTIAL_INLINING=0 +STRATA_LOG=detectors +STRATA_OUTPUT_FILE=$datapath/diagnostics.out + $datapath/a.stratafied" + if [ ! -z $VERBOSE ]; then - echo STRATA_SPRI_FILE=$STRATA_SPRI_FILE STRATA_DOUBLE_FREE=1 STRATA_HEAPRAND=1 STRATA_PC_CONFINE=1 STRATA_PC_CONFINE_XOR=0 STRATA_PC_CONFINE_XOR_KEY_LENGTH=1024 STRATA_ANNOT_FILE=$datapath/a.ncexe.annot STRATA_SIEVE=1 STRATA_RC=1 STRATA_PARTIAL_INLINING=0 STRATA_LOG=detectors STRATA_OUTPUT_FILE=$datapath/diagnostics.out $datapath/a.stratafied "$@" + echo $command fi - -STRATA_DOUBLE_FREE=1 \ - STRATA_HEAPRAND=1 \ - STRATA_PC_CONFINE=1 \ - STRATA_PC_CONFINE_XOR=0 \ - STRATA_PC_CONFINE_XOR_KEY_LENGTH=1024 \ - STRATA_ANNOT_FILE=$datapath/a.ncexe.annot \ - STRATA_SIEVE=1 \ - STRATA_RC=1 \ - STRATA_PARTIAL_INLINING=0 \ - STRATA_LOG=detectors \ - STRATA_OUTPUT_FILE=$datapath/diagnostics.out \ - $datapath/a.stratafied "$@" +eval $command "$@" SAVE_EXIT_CODE=$? diff --git a/tools/update_env_var.sh b/tools/update_env_var.sh new file mode 100755 index 000000000..814e095d3 --- /dev/null +++ b/tools/update_env_var.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +var=$1 +value=$2 + +cat ps_run.sh |sed "s/$1=.*$/$1=$2/" > ps_run.sav +mv ps_run.sav ps_run.sh +chmod +x ps_run.sh -- GitLab