File:  [HATARI the Atari ST Emulator] / hatari / tools / ahcc-symbols-convert.sh
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 9 08:49:01 2019 UTC (7 years, 3 months ago) by root
Branches: hatari, MAIN
CVS tags: hatari01620, hatari01610, hatari01600, hatari01500, hatari01400, HEAD
hatari 1.4.0

#!/bin/sh
#
# script to convert AHCC "linker -p" output for Hatari debugger.

usage ()
{
	name=${0##*/}
	echo
	echo "usage: $name <map file>"
	echo
	echo "convert AHCC 'linker -p' symbol address map output to 'nm'"
	echo "format understood by the Hatari debugger 'symbols' command."
	echo
	echo "For example:"
	echo "  $name etos512.map > etos512.sym"
	echo
	echo "ERROR: $1!"
	echo
	exit 1
}
if [ $# -ne 1 ]; then
	usage "incorrect number of arguments"
fi

if [ \! -f $1 ]; then
	usage "given '$1' address map file not found"
fi

# output only lines that have both address & symbol name,
# remove "[ size]" stuff that confuses awk field parsing,
# and convert those with awk to the "nm" format:
#   <address> <type> <symbol name>
egrep ' (TEXT|DATA|BSS) ' $1 | egrep -v '(TEXT|DATA|BSS)[[:space:]]*$' |\
sed 's/\[[^]]*\]//' | awk '
/^ .* TEXT / { print $1, "T", $4 }
/^ .* DATA / { print $1, "D", $4 }
/^ .* BSS /  { print $1, "B", $4 }'

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.