1 # Copyright
1993, 1994, 1995, 1997, 2007, 2009 Free Software Foundation
, Inc.
3 # This
program is free software
; you can redistribute it and
/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation
; either version
3 of the License
, or
6 #
(at your option
) any later version.
8 # This
program is distributed in the hope that it will be useful
,
9 # but WITHOUT
ANY WARRANTY
; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License
for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this
program; if not
, write to the Free Software
15 # Foundation
, Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, USA.
17 # Please email
any bugs
, comments
, and
/or additions to this file to
:
18 # bug
-dejagnu@prep.ai.mit.edu
20 # This file was written by Rob Savoye
<rob@cygnus.com
>
21 # and rewritten by Ian Lance Taylor
<ian@cygnus.com
>
23 if ![is_remote host
] {
24 if {[which $NM
] == 0} then {
25 perror
"$NM does not exist"
30 send_user
"Version [binutil_version $NM]"
33 if {![binutils_assemble $srcdir
/$subdir
/bintest.s tmpdir
/bintest.o
]} then {
38 set tempfile
[remote_download host tmpdir
/bintest.o
]
40 set tempfile tmpdir
/bintest.o
43 # Test nm with no arguments.
45 # This test does not work correctly
on ECOFF targets
, because ECOFF
46 # stores most symbols twice
, which messes up the nm output.
47 setup_xfail
"alpha*-*-osf*" "alpha*-*-netware*"
48 setup_xfail
"mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
49 setup_xfail
"mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
51 # This test does not work correctly
on XCOFF targets
, because XCOFF
52 # does not enter static symbols in the symbol table.
53 setup_xfail
"*-*-aix*"
55 set got
[binutils_run $NM
"$NMFLAGS $tempfile"]
57 if [info exists vars
] then { unset vars
}
58 while {[regexp
"(\[a-zA-Z\]) (\[a-z_\]*_symbol)(.*)" $got all type symbol rest]} {
59 set vars
($symbol
) $type
63 if {![info exists vars
(text_symbol
)] \
64 || $vars
(text_symbol
) != "T" \
65 ||
![info exists vars
(data_symbol
)] \
66 || $vars
(data_symbol
) != "D" \
67 ||
![info exists vars
(common_symbol
)] \
68 || $vars
(common_symbol
) != "C" \
69 ||
![info exists vars
(external_symbol
)] \
70 || $vars
(external_symbol
) != "U" \
71 ||
![info exists vars
(static_text_symbol
)] \
72 || $vars
(static_text_symbol
) != "t" \
73 ||
![info exists vars
(static_data_symbol
)] \
74 || $vars
(static_data_symbol
) != "d"} {
75 fail
"nm (no arguments)"
77 pass
"nm (no arguments)"
82 set got
[binutils_run $NM
"$NMFLAGS -g $tempfile"]
84 if [info exists vars
] then { unset vars
}
85 while {[regexp
"(\[a-z_\]*_symbol)(.*)" $got all symbol rest]} {
90 if {![info exists vars
(text_symbol
)] \
91 ||
![info exists vars
(data_symbol
)] \
92 ||
![info exists vars
(common_symbol
)] \
93 ||
![info exists vars
(external_symbol
)] \
94 ||
[info exists vars
(static_text_symbol
)] \
95 ||
[info exists vars
(static_data_symbol
)]} {
103 # Test nm
-g
on a unique global symbol.
105 # Only some targets support unique symbols.
106 if {([istarget
"i?86-*-*"]
107 ||
[istarget
"x86_64-*-*"]
108 ||
[istarget
"arm-*-*"]
109 ||
[istarget
"powerpc*-*-*"]
110 ||
[istarget
"sparc*-*-*"])} then {
112 if {![binutils_assemble $srcdir
/$subdir
/unique.s tmpdir
/unique.o
]} then {
113 fail
"nm -g on unique symbols (assembling)"
115 if [is_remote host
] {
116 set tmpfile
[remote_download host tmpdir
/unique.o
]
118 set tmpfile tmpdir
/unique.o
121 set got
[binutils_run $NM
"$NMFLAGS -g $tmpfile"]
123 if [regexp
"u foo" $got] then {
124 pass
"nm -g on unique symbols"
126 fail
"nm -g on unique symbols"
129 if { $verbose
< 1 } {
130 remote_file host
delete "tmpdir/unique.o"
138 # This test does not work correctly
on ECOFF targets
, because ECOFF
139 # stores most symbols twice
, which messes up the nm output.
140 setup_xfail
"alpha*-*-osf*" "alpha*-*-netware*"
141 setup_xfail
"mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
142 setup_xfail
"mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
144 # This test does not work correctly
on XCOFF targets
, because XCOFF
145 # does not enter static symbols in the symbol table.
146 setup_xfail
"*-*-aix*"
148 set got
[binutils_run $NM
"$NMFLAGS -P $tempfile"]
150 set want
"common_symbol C \[0\]*4.*data_symbol D \[0-9a-fA-F\]*.*external_symbol U.*static_data_symbol d \[0-9a-fA-F\]*.*static_text_symbol t \[0-9a-fA-F\]*.*text_symbol T \[0-9a-fA-F\]*"
152 if [regexp $want $got
] then {
158 # There are certainly other tests that could be run.