scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

lorder (552B)


      1 #!/bin/sh
      2 
      3 set -e
      4 trap 'rm -f $$sym?ef' EXIT HUP INT QUIT TERM
      5 
      6 case $# in
      7 0)
      8 	echo usage: lorder file ... >&2
      9 	exit 1
     10 esac
     11 
     12 rm -f $$sym?ef
     13 
     14 (echo $1:
     15  ${NM:-nm} -g "$@") | sed -n '
     16 	/:$/ {
     17 		s/://
     18 		h
     19 		s/.*/& &/
     20 		p
     21 	}
     22 	/ [ADTR] / {
     23 		s/.* //
     24 		G
     25 		s/\n/ /
     26 		w '$$symdef'
     27 	}
     28 	/ C / {
     29 		s/.* //
     30 		G
     31 		s/\n/ /
     32 		w '$$symcef'
     33 	}
     34 	/ U / {
     35 		s/.* //
     36 		G
     37 		s/\n/ /
     38 		w '$$symref'
     39 	}
     40 '
     41 sort $$symdef -o $$symdef
     42 sort $$symref -o $$symref
     43 sort $$symcef -o $$symcef
     44 (join $$symref $$symdef
     45  join $$symref $$symcef
     46  join $$symcef $$symdef) |
     47 sed 's/[^ ]* *//'