aboutsummaryrefslogtreecommitdiff
path: root/binutils/testsuite/binutils-all/nm.exp
blob: 2abc9dfdb42e77638a315b48b4f128965186bcbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#   Copyright (C) 1993, 1994 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

# Please email any bugs, comments, and/or additions to this file to:
# bug-dejagnu@prep.ai.mit.edu

# This file was written by Rob Savoye <rob@cygnus.com>
# and rewritten by Ian Lance Taylor <ian@cygnus.com>

if {[which $NM] == 0} then {
    perror "$NM does not exist"
    return
}

send_user "Version [binutil_version $NM]"


if {![binutils_assemble $AS $srcdir$subdir/bintest.s tmpdir/bintest.o]} then {
    return
}

# Test nm with no arguments.

# This test does not work correctly on ECOFF targets, because ECOFF
# stores most symbols twice, which messes up the nm output.
setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"

set got [binutils_run $NM "$NMFLAGS tmpdir/bintest.o"]

if [info exists vars] then { unset vars }
while {[regexp "(\[a-zA-Z\]) (\[a-z\]*_symbol)(.*)" $got all type symbol rest]} {
    set vars($symbol) $type
    set got $rest
}

if {![info exists vars(text_symbol)] \
     || $vars(text_symbol) != "t" \
     || ![info exists vars(data_symbol)] \
     || $vars(data_symbol) != "d" \
     || ![info exists vars(common_symbol)] \
     || $vars(common_symbol) != "C" \
     || ![info exists vars(external_symbol)] \
     || $vars(external_symbol) != "U"} then {
    fail "nm (no arguments)"
} else {
    pass "nm (no arguments)"
}

# Test nm -g

set got [binutils_run $NM "$NMFLAGS -g tmpdir/bintest.o"]

if [info exists vars] then { unset vars }
while {[regexp "(\[a-z\]*_symbol)(.*)" $got all symbol rest]} {
    set vars($symbol) 1
    set got $rest
}

if {[info exists vars(text_symbol)] \
     || [info exists vars(data_symbol)] \
     || ![info exists vars(common_symbol)] \
     || ![info exists vars(external_symbol)]} then {
    fail "nm -g"
} else {
    pass "nm -g"
}

# Test nm -P

# This test does not work correctly on ECOFF targets, because ECOFF
# stores most symbols twice, which messes up the nm output.
setup_xfail "alpha*-*-osf*" "alpha*-*-netware*"
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"

set got [binutils_run $NM "$NMFLAGS -P tmpdir/bintest.o"]

set want "common_symbol C \[0\]*4.*data_symbol d \[0-9a-fA-F\]*.*external_symbol U.*text_symbol t \[0-9a-fA-F\]*"

if [regexp $want $got] then {
    pass "nm -P"
} else {
    fail "nm -P"
}

# There are certainly other tests that could be run.