"Fossies" - the Fresh Open Source Software Archive

Member "mpr-2.8/config/mprnm.linux" (27 Oct 2001, 1003 Bytes) of package /linux/misc/old/mpr-2.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/sh
    2 
    3 MPRAWK=${MPRAWK-awk}
    4 popt=
    5 Dopt=
    6 
    7 for arg in "$@"; do
    8     case "$1" in
    9     -D) Dopt=-D;;
   10     -p) popt=-p;;
   11     --) shift; break;;
   12     *)  break;;
   13     esac
   14     shift
   15 done
   16 
   17 case "$#" in
   18 1)  aout=`mprwhich -s "$1"` || exit 1;;
   19 *)  echo "usage: mprnm [-D] [-p] a.out" >&2
   20     exit 1;;
   21 esac
   22 
   23 case `file "$aout"` in
   24 *ELF*)  offset=1;;
   25 *)  offset=2;;
   26 esac
   27 
   28 nm $Dopt -n --no-cplus "$aout" 2>/dev/null |
   29 
   30 $MPRAWK '
   31     BEGIN {
   32         for (i=0; i<10; i++) hexv[i""]=i
   33         hexv["a"]=10; hexv["b"]=11; hexv["c"]=12
   34         hexv["d"]=13; hexv["e"]=14; hexv["f"]=15
   35     }
   36     function hex(h, d,l) {
   37         d=0; l=length(h)
   38         for (i=1; i<=l; i++)
   39             d = d*16 + hexv[substr(h, i, 1)]
   40         return d
   41     }
   42     NF==3 && ($2 ~ /T|t|W|w/ || $3 ~ /^_init$/) && $3 !~ /(\.o$)|(g(nu|cc).*compiled)|(^\.L)/ {
   43         if ($3 !~ /^_/)
   44             printf "%s\t%s\n", hex($1), $3
   45         else
   46             printf "%s\t%s\n", hex($1), substr($3, '$offset')
   47     }' |
   48 
   49 mprdem $popt |
   50 
   51 sed -e 's/global destructors keyed to /_GLOBAL_$D$/' \
   52     -e 's/global constructors keyed to /_GLOBAL_$C$/' \
   53     -e 's/::/<>/g'
   54 
   55 exit 0