kevin@kosman.UUCP (Kevin O'Gorman) (06/30/88)
Here's a tool to create a cross-reference listing of your UNIX PC libraries. It is handy in a somewhat obscure set of circumstances, but it's short, too, so I thought I would send it out. #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh <file", e.g.. If this archive is complete, you # will see the following message at the end: # "End of shell archive." # Contents: README xref xref.awk # Wrapped by kevin@kosman on Wed Jun 29 17:06:03 1988 PATH=/bin:/usr/bin:/usr/ucb ; export PATH if test -f 'README' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'README'\" else echo shar: Extracting \"'README'\" \(1232 characters\) sed "s/^X//" >'README' <<'END_OF_FILE' XThese programs are designed to create a cross-reference listing of the Xsymbols defined in your libraries, showing where they are defined. X XThere are two files: X xref which I store as /usr/local/bin/xref X xref.awk which I store as /usr/local/lib/xref.awk X Xyou can change where these are stored, so long as you edit 'xref' to know Xwhere 'xref.awk' is located, and so long as 'xref' is where you can use it. X XThe awk script is correct for the 3.51 'dump' command, but will not work Xright with some of the earlier ones. Mostly, there is an extra column in Xthe later dump outputs. If you run into trouble, try changing the column Xnumbers. X XYou may need to edit the list of libraries in 'xref'. There are a few Xterminal-related libraries which I do not use, and I have some special Xlibraries which you may not have. You will get error messages for Xmissing libraries, but nothing awful happens. X XI find having the list is pretty handy once in a while when I am trying Xto link something obscure off the net, and getting undefined symbols. XThe list will tell me which library I left out of the command line. X XEnjoy! X X X--- XKevin O'Gorman ( kevin@kosman ) voice: 805-984-8042 X Vital Computer Systems, 5115 Beachcomber, Oxnard, CA 93035 END_OF_FILE if test 1232 -ne `wc -c <'README'`; then echo shar: \"'README'\" unpacked with wrong size! fi # end of 'README' fi if test -f 'xref' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xref'\" else echo shar: Extracting \"'xref'\" \(663 characters\) sed "s/^X//" >'xref' <<'END_OF_FILE' X# /usr/local/bin/xref: X# a shell script to create a cross-reference table of symbols defined X# in all libraries. You may have to edit it a bit to cover your X# own library suite. X# X# requires: an awk script in /usr/local/lib/xref.awk X# X# use: normally, through a command like X# xref | lp X X Xdump -t /lib/libc.a /lib/libPW.a /lib/libg.a /lib/libm.a /lib/libld.a \ X /usr/lib/libtam.a /usr/lib/libtermlib.a\ X /usr/lib/libcurses.a /usr/lib/libvt0.a /usr/lib/liby.a \ X /usr/lib/libdev.a /usr/lib/libg.a /usr/lib/libl.a /usr/lib/libld.a\ X /usr/lib/libmalloc.a /usr/lib/libmath.a /usr/lib/libmdbm.a \ X /usr/lib/libplot.a \ X | awk -f /usr/local/lib/xref.awk \ X | sort END_OF_FILE if test 663 -ne `wc -c <'xref'`; then echo shar: \"'xref'\" unpacked with wrong size! fi chmod +x 'xref' # end of 'xref' fi if test -f 'xref.awk' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'xref.awk'\" else echo shar: Extracting \"'xref.awk'\" \(1075 characters\) sed "s/^X//" >'xref.awk' <<'END_OF_FILE' X# /usr/local/lib/xref.awk X# processes the output of 3.51 'dump -t' command, to produce a list of X# defined symbols, and the objects which define them. X# X# used by the shell script /usr/local/bin/xref X XBEGIN { flag = 1 } X# blank lines (after the first ones) set state 3, and read the next line. X/^ *$/ { if (flag > 1) flag = 3 ; next } X# all the rest of this is non-blank lines. X# flag=1 or 2, getting header lines, to eliminate spurious copies later X# header is terminated by a blank line, setting flag=3 Xflag==1 { flag = 2; num = 1 } Xflag==2 { heading[num++] = $0; next } X# skip lines defining the sections X$3==".file" {next} X$3==".text" {next} X$3==".data" {next} X$3==".bss" {next} X# skip external references X$5=="0" {next} X# anything else is compared to the headers, and matches are thrown out X {for (i=1;i<num;i++) if (heading[i]==$0) next;} X# in state 3, we are looking at the name of this object. Save it. Xflag==3 {flag=4; owner=$1; next} X# anything else is likely to be a definition, but only if field 2 is "m1" X$2=="m1" {print $3 "\t" owner} END_OF_FILE if test 1075 -ne `wc -c <'xref.awk'`; then echo shar: \"'xref.awk'\" unpacked with wrong size! fi # end of 'xref.awk' fi echo shar: End of shell archive. exit 0