Fix symbol table generation for the AVR platform.

This commit is contained in:
barner 2006-12-22 17:21:50 +00:00
parent d4b3436d21
commit 01983e2a77

View file

@ -1,8 +1,20 @@
#!/bin/sh
echo \#include '"symbols.h"'
echo \#include '<avr/pgmspace.h>'
avr-nm $* | perl -ne 'print ".global $2\n$2 = 0x$1\n" if(/([0-9a-f]+) [ABDRST] (.+)$/);' | grep -v ^_ | grep -v _reset_vector | grep = | perl -ne 'print "static const prog_char s_$1 [] = \"$1\";\n" if(/(\w+) = (\w+)/)' | sort
echo "PROGMEM const struct symbols symbols[] = {"
avr-nm $* | perl -ne 'print ".global $2\n$2 = 0x$1\n" if(/([0-9a-f]+) [ABDRST] (.+)$/);' | grep -v ^_ | grep -v _reset_vector | grep = | perl -ne 'print "{s_$1, $2},\n" if(/(\w+) = (\w+)/)' | sort
echo "{(void *)0, 0} };"
NM=avr-nm
SYMBOLS=`$NM $* | perl -ne 'print ".global $2\n$2 = 0x$1\n" if(/([0-9a-f]+) [ABDRST] (.+)$/);' | grep -v ^_ | grep -v _reset_vector | grep = | perl -ne 'print "{\"$1\", (char *)$2},\n" if(/(\w+) = (\w+)/)' | wc -l`
SYMBOLS=`expr $SYMBOLS + 1`
echo \#ifndef __SYMBOLS_H__ > symbols.h
echo \#define __SYMBOLS_H__ >> symbols.h
echo \#include '"loader/symbols-def.h"' >> symbols.h
echo "extern const struct symbols symbols[$SYMBOLS];" >> symbols.h
echo \#endif >> symbols.h
echo \#include '"symbols.h"' > symbols.c
echo \#include '<avr/pgmspace.h>' >> symbols.c
$NM $* | perl -ne 'print ".global $2\n$2 = 0x$1\n" if(/([0-9a-f]+) [ABDRST] (.+)$/);' | grep -v ^_ | grep -v _reset_vector | grep = | perl -ne 'print "static const prog_char s_$1 [] = \"$1\";\n" if(/(\w+) = (\w+)/)' | sort >> symbols.c
echo "PROGMEM const struct symbols symbols[] = {" >> symbols.c
avr-nm $* | perl -ne 'print ".global $2\n$2 = 0x$1\n" if(/([0-9a-f]+) [ABDRST] (.+)$/);' | grep -v ^_ | grep -v _reset_vector | grep = | perl -ne 'print "{(const char*)s_$1, (void*)$2},\n" if(/(\w+) = (\w+)/)' | sort >> symbols.c
echo "{(const char *)0, (void*)0} };" >> symbols.c