3 # Copyright (c) International Business Machines Corp., 2000
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 # the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this pronram; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 # PURPOSE: To test the basic functionality of the `nm` command.
26 # 06/01 Robbie Williamson (robbiew@us.ibm.com)
30 #---------------------------------------------------------------------------
31 #Uncomment line below for debug output
32 #trace_logic=${trace_logic:-"set -x"}
36 TCtmp
=${TCtmp:-/tmp/nm$$}
43 $CC -o $TCtmp/nmfile
$TCdat/nmfile.c
44 $CC -o $TCtmp/nmfile1
$TCdat/nmfile1.c
45 $CC -o $TCtmp/nmfile2
$TCdat/nmfile2.c
46 $CC -o $TCtmp/nmfile3
$TCdat/nmfile3.c
61 echo "-------System test for $NM command------"
63 ar -cr $TCtmp/lib.a nmfile1.obj nmfile1.obj nmfile2.obj nmfile3.obj
65 # -A Displays either the full path name or library name of an object
72 mkdir
-p $TCtmp/a
/b
/c
/d
74 $NM -f posix
-A $TCtmp/lib.a |
grep "$TCtmp/lib.a\[nmfile2.obj\]\:" 2>&1 1>/dev
/null
76 cp $TCtmp/lib.a
$TCtmp/a
/b
/c
/d
/
77 $NM -f posix
-A $TCtmp/a
/b
/c
/d
/lib.a |
grep "$TCtmp/a/b/c/d/lib.a\[nmfile2.obj\]\:" 2>&1 1>/dev
/null
81 if [ $RC1 -eq '0' ] && [ $RC2 -eq '0' ]
89 #-------------------------------------------------------------------------------
91 #The nm -g Displays only external (global)symbols.
95 COUNT
=`$NM -f posix -g $TCtmp/nmfile1 | awk '{print $2 }' | grep "[a,b,d,f,t]" | wc -l` 2>&1 1>/dev
/null
104 #-------------------------------------------------------------------------------
105 # -t o Displays a symbol's value as an octal rather than
109 $NM -f posix
-t o
$TCtmp/nmfile1 |
awk '{print $3}' |
grep "[8-9]" >/dev
/null
2>&1
118 #-------------------------------------------------------------------------------
120 # -f sysv Displays information in a SysV output format
124 $NM -f sysv
$TCtmp/nmfile1 |
grep Name
> /dev
/null
2>&1
130 echo "nm -f sysv: FAIL"
135 #-------------------------------------------------------------------------------
137 # -f bsd Displays information in a BSD output format
139 $NM -f bsd
$TCtmp/nmfile1 |
grep printf |
awk '{print $2}' > $TCtmp/nm.diff1
140 $NM -f posix
$TCtmp/nmfile1 |
grep printf |
awk '{print $1}' > $TCtmp/nm.diff2
141 diff $TCtmp/nm.diff1
$TCtmp/nm.diff2
146 echo "nm -f bsd: FAIL"
151 #-----------------------------------------------------------------------------
152 #-u Displays only undefined symbols.Local and Global
156 $NM -f sysv
-u $TCtmp/nmfile1 |
grep "Undefined symbols from" 2>&1 1>/dev
/null
166 #-----------------------------------------------------------------------------
168 # -v Sorts output by value instead of alphabetically.
170 $NM $TCtmp/nmfile1 |
sort |
awk '{print $1}'|
grep [0-9] > $TCtmp/nm.res1
171 $NM -v $TCtmp/nmfile1 |
awk '{print $1}' |
grep [0-9] > $TCtmp/nm.res2
172 diff $TCtmp/nm.res1
$TCtmp/nm.res2
2>&1 1>/dev
/null
182 #------------------------------------------------------------------------------
183 # -s Print archive index.
186 $NM -s $TCtmp/lib.a |
grep "index" 2>&1 1>/dev
/null
195 #-----------------------------------------------------------------------------