#! /bin/sh
#
# Mach Operating System
# Copyright (c) 1986 Carnegie-Mellon University
# All rights reserved.  The CMU software License Agreement specifies
# the terms and conditions for use and redistribution.
#  
######################################################################
# HISTORY
# $Log:	endcheck,v $
# Revision 2.2  88/08/06  18:56:45  rpd
# Created.
# 
######################################################################

# 5799-CGZ (C) COPYRIGHT IBM CORPORATION 1986
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
#$Header: endcheck,v 2.2 88/08/06 18:56:45 rpd Exp $
#$ACIS:endcheck 9.0$
#$Source: /afs/cs.cmu.edu/source_mach/rcs/kernel/standca/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
