ksyms.sh 1.02 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1 2 3 4 5 6 7 8 9 10 11 12
# This program will construct ksyms.s.  Ksyms.s contains a symbol table
# for all the kernel symbols included in the file ksyms.lst.  The following
# variables are defined in ksym.s:
#
#	int symbol_table_size;		/* number of symbols */
#	struct {
#		void *value;		/* value of symbol */
#		char *name;		/* name of symbol */
#	} symbol_table[];
#
#

Linus Torvalds's avatar
Linus Torvalds committed
13
trap "rm -f ksyms.tmp ksyms.lst" 1 2 
Linus Torvalds's avatar
Linus Torvalds committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

sed -e '/^#/d' -e '/^[	 ]*$/d' ksyms.lst | sort > ksyms.tmp

echo '	.data
	.globl	_symbol_table_size, _symbol_table

_symbol_table_size:'
echo "	.long" `wc -l < ksyms.tmp`
echo '
_symbol_table:'
awk 'BEGIN {stringloc = 0}
{print "	.long " $1; print "	.long strings+" stringloc; \
        stringloc += length($1) + 1;}' ksyms.tmp
echo '
strings:'
awk '{print "	.ascii \"" $1 "\\0\""}' ksyms.tmp
Linus Torvalds's avatar
Linus Torvalds committed
30
rm -f ksyms.tmp
Linus Torvalds's avatar
Linus Torvalds committed
31 32 33 34 35 36 37


#
# Alternativly, if the kernel is c++ compiled:
# By using gsub() we can forse all function names to appear as extern "C".
# This allows linkable drivers written in C or C++ - Jon
# awk '{gsub(/__F.*/, "") ; print "	.ascii \"" $0 "\\0\""}' ksyms.tmp