#! /bin/sh
#
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1986
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
#$Header:endcheck 12.0$
#$ACIS:endcheck 12.0$
#$Source: /ibm/acis/usr/sys/standca/RCS/endcheck,v $
#
# program to compare the end address of a program do an exit 1 if
# the greater than (given) hex number.
#	$1	program
#	$2	limit
#	$3 ... $* are a message to be printed if the check fails
#
file=${1?}
arg1=`nm -pg $file | grep end | awk ' $3 == "_end" { print $1 } '`
case "$arg1" in
"")
	exit 1;;
esac
arg2=${2?}
shift;shift
case `( echo 'ibase=16'; echo $arg2 - $arg1 | tr 'abcdef' 'ABCDEF') | bc` in
-*)
	echo "$0 $file(_end) $arg1 <= $arg2 failed ${*}"
	exit 1
	;;
esac
echo "$0: $file(_end) '$arg1 <= $arg2' ok"
exit 0
