#! /bin/sh
# 
# $Copyright
# Copyright 1991 , 1994, 1995 Intel Corporation
# INTEL CONFIDENTIAL
# The technical data and computer software contained herein are subject
# to the copyright notices; trademarks; and use and disclosure
# restrictions identified in the file located in /etc/copyright on
# this system.
# Copyright$
# 
 
#
# fixsyms [file] [outfile]
#
# clean up ncs symbols 
#
rmfile=
case "$1" in
"")
	file=/tmp/$$fixsym
	rmfile="rm -f $file"
	cat $1 > $file
	;;
*)
	file=$1
	;;
esac
if egrep -s '_\.' $file
then
	awk '
#
# script to fix up the output from nm by replacing 
# all symbols _x where a _.x exists.
#
# input is of form
#    $1      $2   $3
# address letter symbol
#
#
$2 == "T" && $3 ~ /^_\./ {
	name= "_" substr($3,3)
	names[name] = $1
	next
	}
names[$3] != "" {
	next
	}
{
names[$3] = $1
}

END {
	for (i in names)
		print names[i], "=", i
}
' $file | sort 
else
	cat $file 
fi >$2
eval "$rmfile"
