From a5215c2bd9249a285fc834db0c453fb3e7daed87 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 20 Feb 2010 21:20:05 -0800 Subject: [PATCH 1/1] Add back stack size checking to altos linking phase This verifies that the stack start specified during the compile will work with the resulting program Signed-off-by: Keith Packard --- src/Makefile.proto | 2 ++ src/check-stack | 7 +++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Makefile.proto b/src/Makefile.proto index c98abca6..4f4252ad 100644 --- a/src/Makefile.proto +++ b/src/Makefile.proto @@ -177,6 +177,7 @@ include Makefile.defs CFLAGS += $(PRODUCT_DEF) -I. NICKLE=nickle +CHECK_STACK=sh ../check-stack 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) .. + $(call quiet,CHECK_STACK) ../ao.h $(@F:.ihx=.mem) ../altitude.h: make-altitude nickle $< > $@ diff --git a/src/check-stack b/src/check-stack index 82680b88..1e8044e0 100755 --- a/src/check-stack +++ b/src/check-stack @@ -2,12 +2,11 @@ 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 - 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 -- 2.30.2