diff options
author | bde <bde@FreeBSD.org> | 2000-06-02 09:27:48 +0000 |
---|---|---|
committer | bde <bde@FreeBSD.org> | 2000-06-02 09:27:48 +0000 |
commit | 7fbccf3ef8c8a3d0433fdd6b1e01eb7f53f8bc58 (patch) | |
tree | 20f97f226c298833416dc01f9feb1c619e71b49d /sys/kern/genassym.sh | |
parent | ccec07bebecc44df0a01df9aab9fd0c7ebdfc957 (diff) | |
download | FreeBSD-src-7fbccf3ef8c8a3d0433fdd6b1e01eb7f53f8bc58.zip FreeBSD-src-7fbccf3ef8c8a3d0433fdd6b1e01eb7f53f8bc58.tar.gz |
Use "nm | awk ..." instead of genassym(1) to generate symbol value headers.
Symbol values are now represented using array sizes (4 arrays per symbol
so that 16-bit machines can represent 64-bit values) instead of being raw
binary values.
Reviewed by: marcel
Diffstat (limited to 'sys/kern/genassym.sh')
-rw-r--r-- | sys/kern/genassym.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/sys/kern/genassym.sh b/sys/kern/genassym.sh new file mode 100644 index 0000000..071ddb0 --- /dev/null +++ b/sys/kern/genassym.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# $FreeBSD$ + +# Grrr, this should use stdin and stdout, but is encrufted for compatibility. + +usage() { + echo "usage: genassym [-o outfile] objfile" + exit 1 +} + +outfile=/dev/stdout +while getopts "o:" option +do + case "$option" in + o) outfile="$OPTARG";; + *) usage;; + esac +done +shift $(($OPTIND - 1)) +case $# in +1) ;; +*) usage;; +esac + +nm "$1" | awk ' +/ C .*sign$/ { + sign = substr($1, length($1) - 3, 4) + sub("^0*", "", sign) + if (sign != "") + sign = "-" +} +/ C .*w0$/ { + w0 = substr($1, length($1) - 3, 4) +} +/ C .*w1$/ { + w1 = substr($1, length($1) - 3, 4) +} +/ C .*w2$/ { + w2 = substr($1, length($1) - 3, 4) +} +/ C .*w3$/ { + w3 = substr($1, length($1) - 3, 4) + w = w3 w2 w1 w0 + sub("^0*", "", w) + if (w == "") + w = "0" + sub("w3$", "", $3) + # This still has minor problems representing INT_MIN, etc. E.g., + # with 32-bit 2''s complement ints, this prints -0x80000000, which + # has the wrong type (unsigned int). + printf("#define\t%s\t%s0x%s\n", $3, sign, w) +} +' 3>"$outfile" >&3 3>&- |