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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299
|
# Copyright (C) 1993-2020 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 3 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., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, 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 ![is_remote host] {
if {[which $NM] == 0} then {
perror "$NM does not exist"
return
}
}
send_user "Version [binutil_version $NM]"
if {![binutils_assemble $srcdir/$subdir/bintest.s tmpdir/bintest.o]} then {
fail "nm (assembling)"
} else {
if [is_remote host] {
set tempfile [remote_download host tmpdir/bintest.o]
} else {
set tempfile tmpdir/bintest.o
}
# 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*"
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"
# This test does not work correctly on XCOFF targets, because XCOFF
# does not enter static symbols in the symbol table.
setup_xfail "*-*-aix*"
set got [binutils_run $NM "$NMFLAGS $tempfile"]
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" \
|| ![info exists vars(static_text_symbol)] \
|| $vars(static_text_symbol) != "t" \
|| ![info exists vars(static_data_symbol)] \
|| $vars(static_data_symbol) != "d"} {
fail "nm (no arguments)"
} else {
pass "nm (no arguments)"
}
# Test nm -g
set got [binutils_run $NM "$NMFLAGS -g $tempfile"]
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)] \
|| [info exists vars(static_text_symbol)] \
|| [info exists vars(static_data_symbol)]} {
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*"
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"
# This test does not work correctly on XCOFF targets, because XCOFF
# does not enter static symbols in the symbol table.
setup_xfail "*-*-aix*"
set got [binutils_run $NM "$NMFLAGS -P $tempfile"]
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\]*"
if [regexp $want $got] then {
pass "nm -P"
} else {
fail "nm -P"
}
# Test nm -t d
# Look for leading zeroes and only the digits 0..9 in the actual value.
set got [binutils_run $NM "$NMFLAGS -t d $tempfile"]
if [regexp "0+\[1-9\]\[0-9\]* T text_symbol3" $got] then {
pass "nm -t d"
} else {
fail "nm -t d"
}
# Test nm --format=posix
# ref: PR 24507 - no leading zeros.
set got [binutils_run $NM "$NMFLAGS --format=posix $tempfile"]
if [regexp "text_symbol3 T \[1-9a-f\]\[0-9a-f\]*" $got] then {
pass "nm --format posix"
} else {
fail "nm --format posix"
}
}
# Test nm --size-sort
# The target exceptions here are intended for targets that have ELF as
# an intermediate format or otherwise require the ELF-variant syntax
# for proper size annotation. It would be nice if is_elf_format found
# all the ELF variants, but adding the patterns here to that proc then
# introduces a whole slew of new regressions in the GAS and LD testsuites.
if { [is_elf_format]
|| [istarget *-*-beos]
|| [istarget *-*-dragonfly*]
|| [istarget *-*-*elf]
|| [istarget *-*-freebsd*]
|| [istarget *-*-lynxos*]
|| [istarget *-*-moss*]
|| [istarget "mmix-knuth-mmixware"]
|| [istarget *-*-nto*]
|| [istarget *-*-rdos*]
|| [istarget *-*-tpf*]
|| [istarget *-*-uclinux*]
|| [istarget ia64-*-*vms*]
|| [istarget *-*-vxworks*]
|| [istarget wasm32-*-*]
|| [istarget bpf-*-*]} {
set nm_1_src "nm-elf-1.s"
} else {
set nm_1_src "nm-1.s"
}
if {![binutils_assemble $srcdir/$subdir/$nm_1_src tmpdir/nm-1.o]} then {
fail "nm --size-sort (assembling)"
} else {
if [is_remote host] {
set tempfile [remote_download host tmpdir/nm-1.o]
} else {
set tempfile tmpdir/nm-1.o
}
# 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*"
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"
set got [binutils_run $NM "$NMFLAGS --size-sort $tempfile"]
set want "0*4 T text_symbol3.*0*8 T text_symbol2.*0*c T text_symbol1"
if [regexp $want $got] then {
pass "nm --size-sort"
} else {
fail "nm --size-sort"
}
}
if [is_elf_format] {
# PR binutils/12753
# Test nm -g on a unique global symbol.
if {![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o]} then {
unsupported "nm -g on unique symbols"
} else {
if [is_remote host] {
set tmpfile [remote_download host tmpdir/unique.o]
} else {
set tmpfile tmpdir/unique.o
}
set got [binutils_run $NM "$NMFLAGS -g $tmpfile"]
if [regexp "u foo" $got] then {
pass "nm -g on unique symbols"
} else {
fail "nm -g on unique symbols"
}
if { $verbose < 1 } {
remote_file host delete "tmpdir/unique.o"
}
}
# PR binutils/20751
# Test nm --with-symbol-versions
if {![binutils_assemble $srcdir/$subdir/nm-ver.s tmpdir/nm-ver.o]} then {
fail "nm --with-symbol-versions (assembling)"
} else {
if [is_remote host] {
set tmpfile [remote_download host tmpdir/nm-ver.o]
} else {
set tmpfile tmpdir/nm-ver.o
}
set got [binutils_run $NM "$NMFLAGS --with-symbol-versions --format sysv $tmpfile"]
if {! [regexp "foo@VER_1" $got]} then {
fail "nm --with-symbol-versions (grep for @VER_1)"
} else {
if {! [regexp "foo@VER_1" $got]} then {
fail "nm --with-symbol-versions (grep for @@VER_2)"
} else {
pass "nm --with-symbol-versions"
}
}
if { $verbose < 1 } {
remote_file host delete "tmpdir/nm-ver.o"
}
}
# PR binutils/25676
# Test nm --line-numbers on DWARF-4 debug info.
set testname "nm --line-numbers on DWARF-4 debug info"
# The RISCV target does not (currently) support .uleb128.
setup_xfail "riscv*-*-*"
# The SH targets complain that the pseudo-ops used to construct
# the DWARF data are misaligned.
setup_xfail "sh*-*-*"
# The pre-compiled dwarf info in dw4.s is not compatible with the
# ALPHA, HPPA, IA64 and MIPS targets.
setup_xfail "alpha*-*-*" "hppa*-*-*" "ia64*-*-*" "mips*-*-*"
# Assembling the source file triggers an ICE in the FT32 assembler.
# FIXME: Fix the ICE...
setup_xfail "ft32-*-*"
# The AVR, MSP430, NDS32, PRU and XTENSA targets do not assemble the
# (64-bit) source file.
setup_xfail "avr-*-*" "msp430-*-*" "nds32*-*-*" "pru-*-*" "xtensa-*-*"
if {![binutils_assemble $srcdir/$subdir/dw4.s tmpdir/dw4.o]} then {
fail "$testname (assembly)"
} else {
# The test source is only intended for 64-bit targets.
# FIXME: Create a 32-bit version of this test.
if {! [is_elf64 tmpdir/dw4.o]} {
unsupported "$testname (needs a 64-bit target)"
} else {
if [is_remote host] {
set tmpfile [remote_download host tmpdir/dw4r.o]
} else {
set tmpfile tmpdir/dw4.o
}
set got [binutils_run $NM "$NMFLAGS --line-numbers $tmpfile"]
if {! [regexp "g_my_externd_global.*tests/main.c:3" $got]} then {
fail "$testname (grep for externd global file/line)"
} else {
pass $testname
}
}
if { $verbose < 1 } {
remote_file host delete $tmpfile
}
}
}
# There are certainly other tests that could be run.
|