4 # Grrr, this should use stdin and stdout, but is encrufted for compatibility.
8 echo "usage: genassym [-o outfile] objfile"
13 while getopts "o:" option
16 o) outfile="$OPTARG";;
20 shift $(($OPTIND - 1))
26 ${NM:='nm'} "$1" | ${AWK:='awk'} '
28 sign = substr($1, length($1) - 3, 4)
34 w0 = substr($1, length($1) - 3, 4)
37 w1 = substr($1, length($1) - 3, 4)
40 w2 = substr($1, length($1) - 3, 4)
43 w3 = substr($1, length($1) - 3, 4)
49 # This still has minor problems representing INT_MIN, etc. E.g.,
50 # with 32-bit 2''s complement ints, this prints -0x80000000, which
51 # has the wrong type (unsigned int).
52 printf("#define\t%s\t%s0x%s\n", $3, sign, w)
54 ' 3>"$outfile" >&3 3>&-