Add back stack size checking to altos linking phase
authorKeith Packard <keithp@keithp.com>
Sun, 21 Feb 2010 05:20:05 +0000 (21:20 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 21 Feb 2010 05:20:05 +0000 (21:20 -0800)
This verifies that the stack start specified during the compile
will work with the resulting program

Signed-off-by: Keith Packard <keithp@keithp.com>
src/Makefile.proto
src/check-stack

index c98abca60d101f84fd7fda12cbcfd21ba0bea50f..4f4252ad2848d5cb1043baf2db36246ea21b4a8a 100644 (file)
@@ -177,6 +177,7 @@ include Makefile.defs
 CFLAGS += $(PRODUCT_DEF) -I.
 
 NICKLE=nickle
 CFLAGS += $(PRODUCT_DEF) -I.
 
 NICKLE=nickle
+CHECK_STACK=sh ../check-stack
 
 REL=$(SRC:.c=.rel) ao_product.rel
 ADB=$(REL:.rel=.adb)
 
 REL=$(SRC:.c=.rel) ao_product.rel
 ADB=$(REL:.rel=.adb)
@@ -207,6 +208,7 @@ all: ../$(PROG)
 
 ../$(PROG): $(REL) Makefile Makefile.defs ../Makefile.proto
        $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && mv $(PROG) ..
 
 ../$(PROG): $(REL) Makefile Makefile.defs ../Makefile.proto
        $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && mv $(PROG) ..
+       $(call quiet,CHECK_STACK) ../ao.h $(@F:.ihx=.mem)
 
 ../altitude.h: make-altitude
        nickle $< > $@
 
 ../altitude.h: make-altitude
        nickle $< > $@
index 82680b88647e4ab8436753caf04d23b27fade369..1e8044e057534f88cbf5c31bb024ef6b0b56aac6 100755 (executable)
@@ -2,12 +2,11 @@
 HEADER=$1
 MEM=$2
 
 HEADER=$1
 MEM=$2
 
-HEADER_STACK=`awk '/#define AO_STACK_START/ {print $3}' $HEADER | nickle`
-MEM_STACK=`awk '/Stack starts at/ {print $4}' $MEM | nickle`
+HEADER_STACK=`awk '/#define AO_STACK_START/ {print strtonum($3)}' $HEADER`
+MEM_STACK=`awk '/Stack starts at/ {print strtonum ($4)}' $MEM`
 
 if [ "$HEADER_STACK" -lt "$MEM_STACK" ]; then
 
 if [ "$HEADER_STACK" -lt "$MEM_STACK" ]; then
-       MIN=0x`nickle -e "$MEM_STACK # 16"`
-       echo "Set AO_STACK_START to at least $MIN"
+        echo $MEM_STACK | awk '{ printf ("Set AO_STACK_START to at least 0x%x\n", $1); }'
        exit 1
 else
        exit 0
        exit 1
 else
        exit 0