From 39983b5bf1835e217b8e26985a2a33ba52b3e41c Mon Sep 17 00:00:00 2001
From: jdh8d <jdh8d@git.zephyr-software.com>
Date: Tue, 28 Dec 2010 19:38:06 +0000
Subject: [PATCH] Reorganized and fixed makefile

---
 .gitattributes                                |  53 ++---
 Makefile                                      | 210 +-----------------
 chopzero.c => chopzero_src/chopzero.c         |   9 +-
 examples/Makefile                             | 209 +++++++++++++++++
 block_copy.c => examples/block_copy.c         |   0
 cmd_args_005.c => examples/cmd_args_005.c     |   0
 .../concolic_test_handshake.c                 |   0
 fptest.c => examples/fptest.c                 |   0
 globalfield.c => examples/globalfield.c       |   0
 hanoi.c => examples/hanoi.c                   |   0
 .../hanoi_heap_overrun.c                      |   0
 hanoi_nostrata.c => examples/hanoi_nostrata.c |   0
 hanoi_overrun.c => examples/hanoi_overrun.c   |   0
 .../hanoi_overrun_tainted.c                   |   0
 .../hanoi_overrun_taintedenv.c                |   0
 .../hanoi_stack_overrun.c                     |   0
 hello.c => examples/hello.c                   |   0
 ld_script => examples/ld_script               |   0
 malloc.c => examples/malloc.c                 |   0
 memcpy.c => examples/memcpy.c                 |   0
 myhanoi.c => examples/myhanoi.c               |   0
 print_ptr.c => examples/print_ptr.c           |   0
 .../recover_example.c                         |   0
 getsyms.sh                                    |   3 -
 do_concolic.sh => tools/do_concolic.sh        |   0
 generate_exe.sh => tools/generate_exe.sh      |   7 +-
 tools/getsyms.sh                              |   3 +
 peasoup_link => tools/peasoup_link            |   2 +-
 peasoup_link++ => tools/peasoup_link++        |   2 +-
 .../test_controller.sh                        |   0
 30 files changed, 256 insertions(+), 242 deletions(-)
 rename chopzero.c => chopzero_src/chopzero.c (51%)
 create mode 100644 examples/Makefile
 rename block_copy.c => examples/block_copy.c (100%)
 rename cmd_args_005.c => examples/cmd_args_005.c (100%)
 rename concolic_test_handshake.c => examples/concolic_test_handshake.c (100%)
 rename fptest.c => examples/fptest.c (100%)
 rename globalfield.c => examples/globalfield.c (100%)
 rename hanoi.c => examples/hanoi.c (100%)
 rename hanoi_heap_overrun.c => examples/hanoi_heap_overrun.c (100%)
 rename hanoi_nostrata.c => examples/hanoi_nostrata.c (100%)
 rename hanoi_overrun.c => examples/hanoi_overrun.c (100%)
 rename hanoi_overrun_tainted.c => examples/hanoi_overrun_tainted.c (100%)
 rename hanoi_overrun_taintedenv.c => examples/hanoi_overrun_taintedenv.c (100%)
 rename hanoi_stack_overrun.c => examples/hanoi_stack_overrun.c (100%)
 rename hello.c => examples/hello.c (100%)
 rename ld_script => examples/ld_script (100%)
 rename malloc.c => examples/malloc.c (100%)
 rename memcpy.c => examples/memcpy.c (100%)
 rename myhanoi.c => examples/myhanoi.c (100%)
 rename print_ptr.c => examples/print_ptr.c (100%)
 rename recover_example.c => examples/recover_example.c (100%)
 delete mode 100755 getsyms.sh
 rename do_concolic.sh => tools/do_concolic.sh (100%)
 rename generate_exe.sh => tools/generate_exe.sh (66%)
 create mode 100755 tools/getsyms.sh
 rename peasoup_link => tools/peasoup_link (92%)
 rename peasoup_link++ => tools/peasoup_link++ (92%)
 rename test_controller.sh => tools/test_controller.sh (100%)

diff --git a/.gitattributes b/.gitattributes
index 58d98c1ac..eaabbbdb7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,28 +1,29 @@
 * text=auto !eol
 /Makefile -text
-/block_copy.c -text
-/chopzero.c -text
-/cmd_args_005.c -text
-/concolic_test_handshake.c -text
-/do_concolic.sh -text
-/fptest.c -text
-/generate_exe.sh -text
-/getsyms.sh -text
-/globalfield.c -text
-/hanoi.c -text
-/hanoi_heap_overrun.c -text
-/hanoi_nostrata.c -text
-/hanoi_overrun.c -text
-/hanoi_overrun_tainted.c -text
-/hanoi_overrun_taintedenv.c -text
-/hanoi_stack_overrun.c -text
-/hello.c -text
-/ld_script -text
-/malloc.c -text
-/memcpy.c -text
-/myhanoi.c -text
-/peasoup_link -text
-/peasoup_link++ -text
-/print_ptr.c -text
-/recover_example.c -text
-/test_controller.sh -text
+chopzero_src/chopzero.c -text
+examples/Makefile -text
+examples/block_copy.c -text
+examples/cmd_args_005.c -text
+examples/concolic_test_handshake.c -text
+examples/fptest.c -text
+examples/globalfield.c -text
+examples/hanoi.c -text
+examples/hanoi_heap_overrun.c -text
+examples/hanoi_nostrata.c -text
+examples/hanoi_overrun.c -text
+examples/hanoi_overrun_tainted.c -text
+examples/hanoi_overrun_taintedenv.c -text
+examples/hanoi_stack_overrun.c -text
+examples/hello.c -text
+examples/ld_script -text
+examples/malloc.c -text
+examples/memcpy.c -text
+examples/myhanoi.c -text
+examples/print_ptr.c -text
+examples/recover_example.c -text
+tools/do_concolic.sh -text
+tools/generate_exe.sh -text
+tools/getsyms.sh -text
+tools/peasoup_link -text
+tools/peasoup_link++ -text
+tools/test_controller.sh -text
diff --git a/Makefile b/Makefile
index b0361cad5..3aa56f12e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,209 +1,9 @@
 
 
-
-
-CC=gcc -fno-stack-protector
-CXX=g++ -fno-stack-protector
-
-all: env_check chopzero hanoi hanoi_overrun hanoi_heap_overrun hanoi_stack_overrun print_ptr malloc block_copy hello hanoi_overrun_tainted hanoi_overrun_taintedenv memcpy cmd_args_005
-
-
-
-#
-# So, why is hanoi build this way, and the rest are built with nicecap link?  
-# Debug time.  If it's built this way, the makefile figures out when the .annot file needs
-# needs updating and when we just need to re-stratafy hanoi.  Since building the annot file takes
-# 1-min+, and stratafying takes 15 seconds, this optimization is a big bonus in a development cycle.
-#
-# If someone knows a neat trick of makefiles to get all of the exe's to build this way, go for it.
-# I expect some of the other tests will get cut/pasted versions of hanoi in the future.
-#
-#
-hanoi:  .PHONY hanoi.ncexe hanoi.stratafied hanoi.ncexe.annot
-	@echo hanoi built
-
-hanoi.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a hanoi.ncexe 
-	${STRATAFIER}/do_stratafy.sh -k hanoi.ncexe 
-	mv new.exe hanoi.stratafied
-	${PEASOUP_HOME}/generate_exe.sh hanoi hanoi.stratafied hanoi.ncexe hanoi.ncexe.annot 
-
-hanoi.ncexe: hanoi.o 
-	$(CC) -Bstatic -static -O3 -fomit-frame-pointer hanoi.o -o hanoi.ncexe
-
-hanoi.ncexe.annot: hanoi.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
-	${SMPSA_HOME}/SMP-analyze.sh hanoi.ncexe
-	@if [ ! -f hanoi.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
-
-globalfield:  .PHONY globalfield.ncexe globalfield.stratafied globalfield.ncexe.annot
-	@echo globalfield built
-
-globalfield.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a globalfield.ncexe 
-	${STRATA_HOME}/tools/stratafier/do_stratafy.sh globalfield.ncexe 
-	mv new.exe globalfield.stratafied
-	${PEASOUP_HOME}/generate_exe.sh globalfield globalfield.stratafied globalfield.ncexe globalfield.ncexe.annot 
-
-globalfield.ncexe: globalfield.o 
-	$(CC) -Bstatic -static -O3 -fomit-frame-pointer globalfield.o -o globalfield.ncexe
-
-globalfield.ncexe.annot: globalfield.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
-	${SMPSA_HOME}/SMP-analyze.sh globalfield.ncexe
-	@if [ ! -f globalfield.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
-
-
-recover_example:  .PHONY recover_example.ncexe recover_example.stratafied recover_example.ncexe.annot
-	@echo recover_example built
-
-recover_example.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a recover_example.ncexe
-	${STRATA_HOME}/tools/stratafier/do_stratafy.sh recover_example.ncexe
-	mv new.exe recover_example.stratafied
-	${PEASOUP_HOME}/generate_exe.sh recover_example recover_example.stratafied recover_example.ncexe recover_example.ncexe.annot
-
-recover_example.ncexe: recover_example.o
-	$(CC) -Bstatic -static -O -fomit-frame-pointer recover_example.o -o recover_example.ncexe
-
-recover_example.ncexe.annot: recover_example.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
-	${SMPSA_HOME}/SMP-analyze.sh recover_example.ncexe
-	@if [ ! -f recover_example.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
-
-
-memcpy:  .PHONY memcpy.ncexe memcpy.stratafied memcpy.ncexe.annot
-	@echo memcpy built
-
-memcpy.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a memcpy.ncexe
-	${STRATA_HOME}/tools/stratafier/do_stratafy.sh memcpy.ncexe
-	mv new.exe memcpy.stratafied
-	${PEASOUP_HOME}/generate_exe.sh memcpy memcpy.stratafied memcpy.ncexe memcpy.ncexe.annot
-
-memcpy.ncexe: memcpy.o
-	$(CC) -Bstatic -static -O3 -fomit-frame-pointer memcpy.o -o memcpy.ncexe
-
-memcpy.ncexe.annot: memcpy.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
-	${SMPSA_HOME}/SMP-analyze.sh memcpy.ncexe
-	@if [ ! -f memcpy.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
-
-
-
-hanoi_overrun_tainted:  .PHONY hanoi_overrun_tainted.ncexe hanoi_overrun_tainted.stratafied hanoi_overrun_tainted.ncexe.annot
-	@echo hanoi_overrun_tainted built
-
-hanoi_overrun_tainted.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a hanoi_overrun_tainted.ncexe
-	${STRATA_HOME}/tools/stratafier/do_stratafy.sh hanoi_overrun_tainted.ncexe
-	mv new.exe hanoi_overrun_tainted.stratafied
-	${PEASOUP_HOME}/generate_exe.sh hanoi_overrun_tainted hanoi_overrun_tainted.stratafied hanoi_overrun_tainted.ncexe hanoi_overrun_tainted.ncexe.annot
-
-hanoi_overrun_tainted.ncexe: hanoi_overrun_tainted.o
-	$(CC) -Bstatic -static hanoi_overrun_tainted.o -o hanoi_overrun_tainted.ncexe
-
-hanoi_overrun_tainted.ncexe.annot: hanoi_overrun_tainted.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
-	${SMPSA_HOME}/SMP-analyze.sh hanoi_overrun_tainted.ncexe
-	@if [ ! -f hanoi_overrun_tainted.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
-
-
-hanoi_overrun_taintedenv:  .PHONY hanoi_overrun_taintedenv.ncexe hanoi_overrun_taintedenv.stratafied hanoi_overrun_taintedenv.ncexe.annot
-	@echo hanoi_overrun_taintedenv built
-
-hanoi_overrun_taintedenv.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a hanoi_overrun_taintedenv.ncexe
-	${STRATA_HOME}/tools/stratafier/do_stratafy.sh hanoi_overrun_taintedenv.ncexe
-	mv new.exe hanoi_overrun_taintedenv.stratafied
-	${PEASOUP_HOME}/generate_exe.sh hanoi_overrun_taintedenv hanoi_overrun_taintedenv.stratafied hanoi_overrun_taintedenv.ncexe hanoi_overrun_taintedenv.ncexe.annot
-
-hanoi_overrun_taintedenv.ncexe: hanoi_overrun_taintedenv.o
-	$(CC) -Bstatic -static hanoi_overrun_taintedenv.o -o hanoi_overrun_taintedenv.ncexe
-
-hanoi_overrun_taintedenv.ncexe.annot: hanoi_overrun_taintedenv.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
-	${SMPSA_HOME}/SMP-analyze.sh hanoi_overrun_taintedenv.ncexe
-	@if [ ! -f hanoi_overrun_taintedenv.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
-
-
-
-hanoi++:  .PHONY hanoi++.ncexe hanoi++.stratafied
-	@echo hanoi++ built
-
-hanoi++.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a hanoi++.ncexe
-	${STRATA_HOME}/tools/stratafier/do_stratafy.sh hanoi++.ncexe
-	mv new.exe hanoi++.stratafied
-	${PEASOUP_HOME}/generate_exe.sh hanoi++ hanoi++.stratafied hanoi++.ncexe hanoi++.ncexe.annot
-
-hanoi++.ncexe: hanoi++.o
-	$(CC) -Bstatic -static hanoi++.o -o hanoi++.ncexe
-	${SMPSA_HOME}/SMP-analyze.sh hanoi++.ncexe
-	@if [ ! -f hanoi++.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
-
-hanoi_overrun: hanoi_overrun.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
-	./peasoup_link hanoi_overrun.o -o hanoi_overrun
-	${SMPSA_HOME}/SMP-analyze.sh hanoi_overrun.ncexe
-
-hanoi_heap_overrun: hanoi_heap_overrun.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
-	./peasoup_link hanoi_heap_overrun.o -o hanoi_heap_overrun
-	${SMPSA_HOME}/SMP-analyze.sh hanoi_heap_overrun.ncexe
-
-
-hanoi_stack_overrun: hanoi_stack_overrun.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
-	./peasoup_link hanoi_stack_overrun.o -o hanoi_stack_overrun
-	${SMPSA_HOME}/SMP-analyze.sh hanoi_stack_overrun.ncexe
-
-print_ptr: print_ptr.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
-	./peasoup_link print_ptr.o -o print_ptr
-	${SMPSA_HOME}/SMP-analyze.sh print_ptr.ncexe
-
-block_copy: block_copy.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
-	./peasoup_link block_copy.o -o block_copy
-	${SMPSA_HOME}/SMP-analyze.sh block_copy.ncexe
-
-malloc: malloc.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
-	./peasoup_link malloc.o -o malloc
-	${SMPSA_HOME}/SMP-analyze.sh malloc.ncexe
-
-hello: hello.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
-	./peasoup_link hello.o -o hello
-	${SMPSA_HOME}/SMP-analyze.sh hello.ncexe
-
-cmd_args_005: cmd_args_005.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
-	./peasoup_link++ cmd_args_005.o -o cmd_args_005
-	${SMPSA_HOME}/SMP-analyze.sh cmd_args_005.ncexe
-
-.PHONY: env_check chopzero
-
-.c.o:
-	$(CC) -O3 -fomit-frame-pointer $< -c
-
-.cpp.o:
-	$(CXX) -O3 $< -c
-
-chopzero:
-	@ if [ ! -f chopzero ]; then gcc chopzero.c -o chopzero -O3 ; fi
-
-
-
-env_check:
-	@echo checking env vars; \
-	if [ "X${TOOLCHAIN}" = "X" ]; then \
-		echo TOOLCHAIN environment variable should be set.; \
-		exit -1;\
- 	elif [ "X${STRATA}" = "X" ]; then \
-		echo STRATA environment variable should be set. ;\
-		exit -1;\
- 	elif [ "X${SMPSA_HOME}" = "X" ]; then \
-		echo SMPSA_HOME environment variable should be set.; \
-		exit -1;\
- 	elif [ "X${PEASOUP_HOME}" = "X" ]; then \
-		echo PEASOUP_HOME environment variable should be set.; \
-		exit -1;\
- 	elif [ "X${STRATA_HOME}" = "X" ]; then \
-		echo STRATA_HOME environment variable should be set.; \
-		exit -1;\
-	fi ; 
-
-
-double_free_suite:
-	cd double_free_tests; make
+all:
+	cd chopzero_src; make
 
 clean:
-	rm -f *.o *.syms *.map chopzero hanoi hanoi_overrun hanoi_heap_overrun malloc block_copy print_ptr hanoi_stack_overrun
-	rm -f *.exe *.dis *.data *.idb *.log *.ncexe *.annot *.readelf temp.* *.temp *.stratafied *.asm *.SMPobjdump *.id0 *.id1 *.til *.nam
-	rm -Rf concolic.files_*
-	rm strata.log.*
-
-concclean:
-	rm -Rf concolic.files_*
-	rm strata.log.*
+	cd chopzero_src; make clean
+	cd examples; make clean
+	
diff --git a/chopzero.c b/chopzero_src/chopzero.c
similarity index 51%
rename from chopzero.c
rename to chopzero_src/chopzero.c
index 0a359cd73..42ca81e27 100644
--- a/chopzero.c
+++ b/chopzero_src/chopzero.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <assert.h>
 
 #define MAXLINE 1000
 
@@ -7,8 +8,12 @@ int main() {
    int addr, size;
 
    while (!feof(stdin)) {
-      fgets(linebuf, MAXLINE-1, stdin);
-      sscanf(linebuf, "%x %d", &addr, &size);
+      int res;
+      char* resp;
+      resp=fgets(linebuf, MAXLINE-1, stdin);
+      assert(resp==NULL || resp==linebuf);
+      res=sscanf(linebuf, "%x %d", &addr, &size);
+      assert(res>=0);
       if ((size != 0) && (addr != 0)) {
          fputs(linebuf, stdout);
       }
diff --git a/examples/Makefile b/examples/Makefile
new file mode 100644
index 000000000..ef365305f
--- /dev/null
+++ b/examples/Makefile
@@ -0,0 +1,209 @@
+
+
+
+
+CC=gcc -fno-stack-protector
+CXX=g++ -fno-stack-protector
+
+all: env_check hanoi hanoi_overrun hanoi_heap_overrun hanoi_stack_overrun print_ptr malloc block_copy hello hanoi_overrun_tainted hanoi_overrun_taintedenv memcpy cmd_args_005
+
+
+
+#
+# So, why is hanoi build this way, and the rest are built with nicecap link?  
+# Debug time.  If it's built this way, the makefile figures out when the .annot file needs
+# needs updating and when we just need to re-stratafy hanoi.  Since building the annot file takes
+# 1-min+, and stratafying takes 15 seconds, this optimization is a big bonus in a development cycle.
+#
+# If someone knows a neat trick of makefiles to get all of the exe's to build this way, go for it.
+# I expect some of the other tests will get cut/pasted versions of hanoi in the future.
+#
+#
+hanoi:  .PHONY hanoi.ncexe hanoi.stratafied hanoi.ncexe.annot
+	@echo hanoi built
+
+hanoi.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a hanoi.ncexe 
+	${STRATAFIER}/do_stratafy.sh -k hanoi.ncexe 
+	mv new.exe hanoi.stratafied
+	${PEASOUP_HOME}/tools/generate_exe.sh hanoi hanoi.stratafied hanoi.ncexe hanoi.ncexe.annot 
+
+hanoi.ncexe: hanoi.o 
+	$(CC) -Bstatic -static -O3 -fomit-frame-pointer hanoi.o -o hanoi.ncexe
+
+hanoi.ncexe.annot: hanoi.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
+	${SMPSA_HOME}/SMP-analyze.sh hanoi.ncexe
+	@if [ ! -f hanoi.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
+
+globalfield:  .PHONY globalfield.ncexe globalfield.stratafied globalfield.ncexe.annot
+	@echo globalfield built
+
+globalfield.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a globalfield.ncexe 
+	${STRATAFIER}/do_stratafy.sh globalfield.ncexe 
+	mv new.exe globalfield.stratafied
+	${PEASOUP_HOME}/tools/generate_exe.sh globalfield globalfield.stratafied globalfield.ncexe globalfield.ncexe.annot 
+
+globalfield.ncexe: globalfield.o 
+	$(CC) -Bstatic -static -O3 -fomit-frame-pointer globalfield.o -o globalfield.ncexe
+
+globalfield.ncexe.annot: globalfield.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
+	${SMPSA_HOME}/SMP-analyze.sh globalfield.ncexe
+	@if [ ! -f globalfield.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
+
+
+recover_example:  .PHONY recover_example.ncexe recover_example.stratafied recover_example.ncexe.annot
+	@echo recover_example built
+
+recover_example.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a recover_example.ncexe
+	${STRATAFIER}/do_stratafy.sh recover_example.ncexe
+	mv new.exe recover_example.stratafied
+	${PEASOUP_HOME}/tools/generate_exe.sh recover_example recover_example.stratafied recover_example.ncexe recover_example.ncexe.annot
+
+recover_example.ncexe: recover_example.o
+	$(CC) -Bstatic -static -O -fomit-frame-pointer recover_example.o -o recover_example.ncexe
+
+recover_example.ncexe.annot: recover_example.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
+	${SMPSA_HOME}/SMP-analyze.sh recover_example.ncexe
+	@if [ ! -f recover_example.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
+
+
+memcpy:  .PHONY memcpy.ncexe memcpy.stratafied memcpy.ncexe.annot
+	@echo memcpy built
+
+memcpy.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a memcpy.ncexe
+	${STRATAFIER}/do_stratafy.sh memcpy.ncexe
+	mv new.exe memcpy.stratafied
+	${PEASOUP_HOME}/tools/generate_exe.sh memcpy memcpy.stratafied memcpy.ncexe memcpy.ncexe.annot
+
+memcpy.ncexe: memcpy.o
+	$(CC) -Bstatic -static -O3 -fomit-frame-pointer memcpy.o -o memcpy.ncexe
+
+memcpy.ncexe.annot: memcpy.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
+	${SMPSA_HOME}/SMP-analyze.sh memcpy.ncexe
+	@if [ ! -f memcpy.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
+
+
+
+hanoi_overrun_tainted:  .PHONY hanoi_overrun_tainted.ncexe hanoi_overrun_tainted.stratafied hanoi_overrun_tainted.ncexe.annot
+	@echo hanoi_overrun_tainted built
+
+hanoi_overrun_tainted.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a hanoi_overrun_tainted.ncexe
+	${STRATAFIER}/do_stratafy.sh hanoi_overrun_tainted.ncexe
+	mv new.exe hanoi_overrun_tainted.stratafied
+	${PEASOUP_HOME}/tools/generate_exe.sh hanoi_overrun_tainted hanoi_overrun_tainted.stratafied hanoi_overrun_tainted.ncexe hanoi_overrun_tainted.ncexe.annot
+
+hanoi_overrun_tainted.ncexe: hanoi_overrun_tainted.o
+	$(CC) -Bstatic -static hanoi_overrun_tainted.o -o hanoi_overrun_tainted.ncexe
+
+hanoi_overrun_tainted.ncexe.annot: hanoi_overrun_tainted.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
+	${SMPSA_HOME}/SMP-analyze.sh hanoi_overrun_tainted.ncexe
+	@if [ ! -f hanoi_overrun_tainted.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
+
+
+hanoi_overrun_taintedenv:  .PHONY hanoi_overrun_taintedenv.ncexe hanoi_overrun_taintedenv.stratafied hanoi_overrun_taintedenv.ncexe.annot
+	@echo hanoi_overrun_taintedenv built
+
+hanoi_overrun_taintedenv.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a hanoi_overrun_taintedenv.ncexe
+	${STRATAFIER}/do_stratafy.sh hanoi_overrun_taintedenv.ncexe
+	mv new.exe hanoi_overrun_taintedenv.stratafied
+	${PEASOUP_HOME}/tools/generate_exe.sh hanoi_overrun_taintedenv hanoi_overrun_taintedenv.stratafied hanoi_overrun_taintedenv.ncexe hanoi_overrun_taintedenv.ncexe.annot
+
+hanoi_overrun_taintedenv.ncexe: hanoi_overrun_taintedenv.o
+	$(CC) -Bstatic -static hanoi_overrun_taintedenv.o -o hanoi_overrun_taintedenv.ncexe
+
+hanoi_overrun_taintedenv.ncexe.annot: hanoi_overrun_taintedenv.ncexe ${IDAROOT}/plugins/SMPStaticAnalyzer.plx ${SMPSA_HOME}/SMP-analyze.sh
+	${SMPSA_HOME}/SMP-analyze.sh hanoi_overrun_taintedenv.ncexe
+	@if [ ! -f hanoi_overrun_taintedenv.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
+
+
+
+hanoi++:  .PHONY hanoi++.ncexe hanoi++.stratafied
+	@echo hanoi++ built
+
+hanoi++.stratafied: ${STRATA}/lib/x86_linux/libstrata_normal.a hanoi++.ncexe
+	${STRATAFIER}/do_stratafy.sh hanoi++.ncexe
+	mv new.exe hanoi++.stratafied
+	${PEASOUP_HOME}/tools/generate_exe.sh hanoi++ hanoi++.stratafied hanoi++.ncexe hanoi++.ncexe.annot
+
+hanoi++.ncexe: hanoi++.o
+	$(CC) -Bstatic -static hanoi++.o -o hanoi++.ncexe
+	${SMPSA_HOME}/SMP-analyze.sh hanoi++.ncexe
+	@if [ ! -f hanoi++.ncexe.annot ]; then echo Failed to generate annotations file; exit 1; fi
+
+hanoi_overrun: hanoi_overrun.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
+	${PEASOUP_HOME}/tools/peasoup_link hanoi_overrun.o -o hanoi_overrun
+	${SMPSA_HOME}/SMP-analyze.sh hanoi_overrun.ncexe
+
+hanoi_heap_overrun: hanoi_heap_overrun.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
+	${PEASOUP_HOME}/tools/peasoup_link hanoi_heap_overrun.o -o hanoi_heap_overrun
+	${SMPSA_HOME}/SMP-analyze.sh hanoi_heap_overrun.ncexe
+
+
+hanoi_stack_overrun: hanoi_stack_overrun.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
+	${PEASOUP_HOME}/tools/peasoup_link hanoi_stack_overrun.o -o hanoi_stack_overrun
+	${SMPSA_HOME}/SMP-analyze.sh hanoi_stack_overrun.ncexe
+
+print_ptr: print_ptr.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
+	${PEASOUP_HOME}/tools/peasoup_link print_ptr.o -o print_ptr
+	${SMPSA_HOME}/SMP-analyze.sh print_ptr.ncexe
+
+block_copy: block_copy.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
+	${PEASOUP_HOME}/tools/peasoup_link block_copy.o -o block_copy
+	${SMPSA_HOME}/SMP-analyze.sh block_copy.ncexe
+
+malloc: malloc.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
+	${PEASOUP_HOME}/tools/peasoup_link malloc.o -o malloc
+	${SMPSA_HOME}/SMP-analyze.sh malloc.ncexe
+
+hello: hello.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
+	${PEASOUP_HOME}/tools/peasoup_link hello.o -o hello
+	${SMPSA_HOME}/SMP-analyze.sh hello.ncexe
+
+cmd_args_005: cmd_args_005.o ${STRATA}/lib/x86_linux/libstrata_normal.a .PHONY
+	${PEASOUP_HOME}/tools/peasoup_link++ cmd_args_005.o -o cmd_args_005
+	${SMPSA_HOME}/SMP-analyze.sh cmd_args_005.ncexe
+
+.PHONY: env_check 
+
+.c.o:
+	$(CC) -O3 -fomit-frame-pointer $< -c
+
+.cpp.o:
+	$(CXX) -O3 $< -c
+
+chopzero:
+	@ if [ ! -f chopzero ]; then gcc chopzero.c -o chopzero -O3 ; fi
+
+
+
+env_check:
+	@echo checking env vars; \
+	if [ "X${TOOLCHAIN}" = "X" ]; then \
+		echo TOOLCHAIN environment variable should be set.; \
+		exit -1;\
+ 	elif [ "X${STRATA}" = "X" ]; then \
+		echo STRATA environment variable should be set. ;\
+		exit -1;\
+ 	elif [ "X${SMPSA_HOME}" = "X" ]; then \
+		echo SMPSA_HOME environment variable should be set.; \
+		exit -1;\
+ 	elif [ "X${PEASOUP_HOME}" = "X" ]; then \
+		echo PEASOUP_HOME environment variable should be set.; \
+		exit -1;\
+ 	elif [ "X${STRATA_HOME}" = "X" ]; then \
+		echo STRATA_HOME environment variable should be set.; \
+		exit -1;\
+	fi ; 
+
+
+double_free_suite:
+	cd double_free_tests; make
+
+clean:
+	rm -f *.o *.syms *.map chopzero hanoi hanoi_overrun hanoi_heap_overrun malloc block_copy print_ptr hanoi_stack_overrun
+	rm -f *.exe *.dis *.data *.idb *.log *.ncexe *.annot *.readelf temp.* *.temp *.stratafied *.asm *.SMPobjdump *.id0 *.id1 *.til *.nam
+	rm -Rf concolic.files_*
+	rm -f strata.log.*
+
+concclean:
+	rm -Rf concolic.files_*
+	rm strata.log.*
diff --git a/block_copy.c b/examples/block_copy.c
similarity index 100%
rename from block_copy.c
rename to examples/block_copy.c
diff --git a/cmd_args_005.c b/examples/cmd_args_005.c
similarity index 100%
rename from cmd_args_005.c
rename to examples/cmd_args_005.c
diff --git a/concolic_test_handshake.c b/examples/concolic_test_handshake.c
similarity index 100%
rename from concolic_test_handshake.c
rename to examples/concolic_test_handshake.c
diff --git a/fptest.c b/examples/fptest.c
similarity index 100%
rename from fptest.c
rename to examples/fptest.c
diff --git a/globalfield.c b/examples/globalfield.c
similarity index 100%
rename from globalfield.c
rename to examples/globalfield.c
diff --git a/hanoi.c b/examples/hanoi.c
similarity index 100%
rename from hanoi.c
rename to examples/hanoi.c
diff --git a/hanoi_heap_overrun.c b/examples/hanoi_heap_overrun.c
similarity index 100%
rename from hanoi_heap_overrun.c
rename to examples/hanoi_heap_overrun.c
diff --git a/hanoi_nostrata.c b/examples/hanoi_nostrata.c
similarity index 100%
rename from hanoi_nostrata.c
rename to examples/hanoi_nostrata.c
diff --git a/hanoi_overrun.c b/examples/hanoi_overrun.c
similarity index 100%
rename from hanoi_overrun.c
rename to examples/hanoi_overrun.c
diff --git a/hanoi_overrun_tainted.c b/examples/hanoi_overrun_tainted.c
similarity index 100%
rename from hanoi_overrun_tainted.c
rename to examples/hanoi_overrun_tainted.c
diff --git a/hanoi_overrun_taintedenv.c b/examples/hanoi_overrun_taintedenv.c
similarity index 100%
rename from hanoi_overrun_taintedenv.c
rename to examples/hanoi_overrun_taintedenv.c
diff --git a/hanoi_stack_overrun.c b/examples/hanoi_stack_overrun.c
similarity index 100%
rename from hanoi_stack_overrun.c
rename to examples/hanoi_stack_overrun.c
diff --git a/hello.c b/examples/hello.c
similarity index 100%
rename from hello.c
rename to examples/hello.c
diff --git a/ld_script b/examples/ld_script
similarity index 100%
rename from ld_script
rename to examples/ld_script
diff --git a/malloc.c b/examples/malloc.c
similarity index 100%
rename from malloc.c
rename to examples/malloc.c
diff --git a/memcpy.c b/examples/memcpy.c
similarity index 100%
rename from memcpy.c
rename to examples/memcpy.c
diff --git a/myhanoi.c b/examples/myhanoi.c
similarity index 100%
rename from myhanoi.c
rename to examples/myhanoi.c
diff --git a/print_ptr.c b/examples/print_ptr.c
similarity index 100%
rename from print_ptr.c
rename to examples/print_ptr.c
diff --git a/recover_example.c b/examples/recover_example.c
similarity index 100%
rename from recover_example.c
rename to examples/recover_example.c
diff --git a/getsyms.sh b/getsyms.sh
deleted file mode 100755
index e4b5e6931..000000000
--- a/getsyms.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-readelf -s $1 |grep -e FUNC -e OBJECT|cut -d: -f2|$NICECAP_HOME/chopzero|sort --key=1,9 --key=13,21|cut -c 2-31,44-200|uniq -w 14 > $1.syms
-
diff --git a/do_concolic.sh b/tools/do_concolic.sh
similarity index 100%
rename from do_concolic.sh
rename to tools/do_concolic.sh
diff --git a/generate_exe.sh b/tools/generate_exe.sh
similarity index 66%
rename from generate_exe.sh
rename to tools/generate_exe.sh
index 20f983627..f03b31890 100755
--- a/generate_exe.sh
+++ b/tools/generate_exe.sh
@@ -6,22 +6,21 @@
 
 
 if [ "$PEASOUP_HOME"X = X ]; then echo Please set PEASOUP_HOME; exit 1; fi
-if [ ! -f  $PEASOUP_HOME/getsyms.sh ]; then echo PEASOUP_HOME is set poorly, please fix.; exit 1; fi
+if [ ! -f  $PEASOUP_HOME/tools/getsyms.sh ]; then echo PEASOUP_HOME is set poorly, please fix.; exit 1; fi
 if [ "$SMPSA_HOME"X = X ]; then echo Please set SMPSA_HOME; exit 1; fi
 if [ ! -f  $SMPSA_HOME/SMP-analyze.sh ]; then echo SMPSA_HOME is set poorly, please fix.; exit 1; fi
 
 
-# $PEASOUP_HOME/generate_exe_script.sh hanoi hanoi.stratafied hanoi.exe hanoi.annot
 output=$1
 stratafied_exe=$2
 orig_exe=$3
 annot_file=$4
 
-sh $PEASOUP_HOME/getsyms.sh $orig_exe
+sh $PEASOUP_HOME/tools/getsyms.sh $orig_exe
 mv $orig_exe.syms $orig_exe.readelf
 
 echo "#!/bin/sh" > $output
-echo "STRATA_ANNOT_FILE=$annot_file STRATA_SYM_FILE=$orig_exe.readelf $stratafied_exe \$*" >> $output
+echo "PATH=$PATH:. STRATA_ANNOT_FILE=$annot_file STRATA_SYM_FILE=$orig_exe.readelf $stratafied_exe \$*" >> $output
 chmod 755 $output
 
 
diff --git a/tools/getsyms.sh b/tools/getsyms.sh
new file mode 100755
index 000000000..87c314801
--- /dev/null
+++ b/tools/getsyms.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+readelf -s $1 |grep -e FUNC -e OBJECT|cut -d: -f2|$PEASOUP_HOME/chopzero_src/chopzero|sort --key=1,9 --key=13,21|cut -c 2-31,44-200|uniq -w 14 > $1.syms
+
diff --git a/peasoup_link b/tools/peasoup_link
similarity index 92%
rename from peasoup_link
rename to tools/peasoup_link
index a72c21a1f..e5c28b965 100755
--- a/peasoup_link
+++ b/tools/peasoup_link
@@ -57,5 +57,5 @@ mv $exe $exe.ncexe
 
 ${STRATAFIER}/do_stratafy.sh $exe.ncexe
 mv new.exe $exe.stratafied
-${PEASOUP_HOME}/generate_exe.sh $exe $PWD/$exe.stratafied $PWD/$exe.ncexe $PWD/$exe.ncexe.annot
+${PEASOUP_HOME}/tools/generate_exe.sh $exe $PWD/$exe.stratafied $PWD/$exe.ncexe $PWD/$exe.ncexe.annot
 
diff --git a/peasoup_link++ b/tools/peasoup_link++
similarity index 92%
rename from peasoup_link++
rename to tools/peasoup_link++
index e5e397a4c..ff6ae83f1 100755
--- a/peasoup_link++
+++ b/tools/peasoup_link++
@@ -57,5 +57,5 @@ mv $exe $exe.ncexe
 
 ${STRATAFIER}/do_stratafy.sh $exe.ncexe
 mv new.exe $exe.stratafied
-${PEASOUP_HOME}/generate_exe.sh $exe $PWD/$exe.stratafied $PWD/$exe.ncexe $PWD/$exe.ncexe.annot
+${PEASOUP_HOME}/tools/generate_exe.sh $exe $PWD/$exe.stratafied $PWD/$exe.ncexe $PWD/$exe.ncexe.annot
 
diff --git a/test_controller.sh b/tools/test_controller.sh
similarity index 100%
rename from test_controller.sh
rename to tools/test_controller.sh
-- 
GitLab