binutils-gdb/binutils/testsuite/binutils-all/nm.exp

304 lines
9.1 KiB
Plaintext
Raw Normal View History

# Copyright (C) 1993-2020 Free Software Foundation, Inc.
1999-05-03 15:29:11 +08:00
# 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
2007-07-06 00:54:46 +08:00
# the Free Software Foundation; either version 3 of the License, or
1999-05-03 15:29:11 +08:00
# (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
2005-05-08 22:17:41 +08:00
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
1999-05-03 15:29:11 +08:00
# 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)"
1999-05-03 15:29:11 +08:00
} else {
if [is_remote host] {
set tempfile [remote_download host tmpdir/bintest.o]
} else {
set tempfile tmpdir/bintest.o
}
1999-05-03 15:29:11 +08:00
# Test nm with no arguments.
1999-05-03 15:29:11 +08:00
# This test does not work correctly on ECOFF targets, because ECOFF
# stores most symbols twice, which messes up the nm output.
Remove netware support include/ * nlm/ChangeLog-9315: Delete. * nlm/alpha-ext.h: Delete. * nlm/common.h: Delete. * nlm/external.h: Delete. * nlm/i386-ext.h: Delete. * nlm/internal.h: Delete. * nlm/ppc-ext.h: Delete. * nlm/sparc32-ext.h: Delete. bfd/ * Makefile.am: Remove netware support. * bfd-in.h: Likewise. * bfd.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * doc/bfdint.texi: Likewise. * ecoff.c: Likewise. * targets.c: Likewise. * libnlm.h: Delete. * nlm-target.h: Delete. * nlm.c: Delete. * nlm32-alpha.c: Delete. * nlm32-i386.c: Delete. * nlm32-ppc.c: Delete. * nlm32-sparc.c: Delete. * nlm32.c: Delete. * nlm64.c: Delete. * nlmcode.h: Delete. * nlmswap.h: Delete. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * po/SRC-POTFILES.in: Regenerate. binutils/ * .gitignore: Remove netware support. * Makefile.am: Likewise. * configure.ac: Likewise. * doc/Makefile.am: Likewise. * doc/binutils.texi: Likewise. * testsuite/binutils-all/nm.exp: Likewise. * nlmconv.c: Delete. * nlmconv.h: Delete. * nlmheader.y: Delete. * Makefile.in: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. gas/ * Makefile.am: Remove netware support. * config/tc-i386.c: Likewise. * configure.tgt: Likewise. * config/te-netware.h: Delete. * Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. gprof/ * corefile.c: Remove netware support. ld/ * Makefile.am: Remove netware support. * configure.tgt: Likewise. * testsuite/ld-powerpc/powerpc.exp: Likewise. * emulparams/i386nw.sh: Delete. * emulparams/ppcnw.sh: Delete. * scripttempl/nw.sc: Delete. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate.
2018-04-16 13:41:22 +08:00
setup_xfail "alpha*-*-osf*"
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"
1999-05-03 15:29:11 +08:00
# This test does not work correctly on XCOFF targets, because XCOFF
# does not enter static symbols in the symbol table.
if [is_xcoff_format] {
setup_xfail *-*-*
}
1999-05-03 15:29:11 +08:00
set got [binutils_run $NM "$NMFLAGS $tempfile"]
1999-05-03 15:29:11 +08:00
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
}
1999-05-03 15:29:11 +08:00
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)"
}
1999-05-03 15:29:11 +08:00
# Test nm -g
1999-05-03 15:29:11 +08:00
set got [binutils_run $NM "$NMFLAGS -g $tempfile"]
1999-05-03 15:29:11 +08:00
if [info exists vars] then { unset vars }
while {[regexp "(\[a-z_\]*_symbol)(.*)" $got all symbol rest]} {
set vars($symbol) 1
set got $rest
}
1999-05-03 15:29:11 +08:00
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
1999-05-03 15:29:11 +08:00
# This test does not work correctly on ECOFF targets, because ECOFF
# stores most symbols twice, which messes up the nm output.
Remove netware support include/ * nlm/ChangeLog-9315: Delete. * nlm/alpha-ext.h: Delete. * nlm/common.h: Delete. * nlm/external.h: Delete. * nlm/i386-ext.h: Delete. * nlm/internal.h: Delete. * nlm/ppc-ext.h: Delete. * nlm/sparc32-ext.h: Delete. bfd/ * Makefile.am: Remove netware support. * bfd-in.h: Likewise. * bfd.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * doc/bfdint.texi: Likewise. * ecoff.c: Likewise. * targets.c: Likewise. * libnlm.h: Delete. * nlm-target.h: Delete. * nlm.c: Delete. * nlm32-alpha.c: Delete. * nlm32-i386.c: Delete. * nlm32-ppc.c: Delete. * nlm32-sparc.c: Delete. * nlm32.c: Delete. * nlm64.c: Delete. * nlmcode.h: Delete. * nlmswap.h: Delete. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * po/SRC-POTFILES.in: Regenerate. binutils/ * .gitignore: Remove netware support. * Makefile.am: Likewise. * configure.ac: Likewise. * doc/Makefile.am: Likewise. * doc/binutils.texi: Likewise. * testsuite/binutils-all/nm.exp: Likewise. * nlmconv.c: Delete. * nlmconv.h: Delete. * nlmheader.y: Delete. * Makefile.in: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. gas/ * Makefile.am: Remove netware support. * config/tc-i386.c: Likewise. * configure.tgt: Likewise. * config/te-netware.h: Delete. * Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. gprof/ * corefile.c: Remove netware support. ld/ * Makefile.am: Remove netware support. * configure.tgt: Likewise. * testsuite/ld-powerpc/powerpc.exp: Likewise. * emulparams/i386nw.sh: Delete. * emulparams/ppcnw.sh: Delete. * scripttempl/nw.sc: Delete. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate.
2018-04-16 13:41:22 +08:00
setup_xfail "alpha*-*-osf*"
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*"
1999-05-03 15:29:11 +08:00
# This test does not work correctly on XCOFF targets, because XCOFF
# does not enter static symbols in the symbol table.
if [is_xcoff_format] {
setup_xfail *-*-*
}
1999-05-03 15:29:11 +08:00
set got [binutils_run $NM "$NMFLAGS -P $tempfile"]
1999-05-03 15:29:11 +08:00
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\]*"
1999-05-03 15:29:11 +08:00
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"
}
1999-05-03 15:29:11 +08:00
}
# 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*]
Add support for the WebAssembly file format and the wasm32 ELF conversion to gas and the binutils. binutils * readelf.c: Add support for wasm32 ELF format WebAssembly files. (guess_is_rela): Likewise. (dump_relocations): Likewise. (is_32bit_abs_reloc): Likewise. (is_none_reloc_): Likewise. * NEWS: Mention the new support. * testsuite/lib/binutils-common.exp (is_elf_format): Mark wasm32 as ELF target. (supports_gnu_unique): Mark wasm32 as supporting STB_GNU_UNIQUE. * testsuite/binutils-all/nm.exp: Mark wasm32 as requiring .size annotations. * testsuite/binutils-all/wasm32: New directory. * testsuite/binutils-all/wasm32/create-wasm.d: New file. * testsuite/binutils-all/wasm32/create-wasm.s: Likewise. * testsuite/binutils-all/wasm32/custom-section.d: Likewise. * testsuite/binutils-all/wasm32/custom-section.s: Likewise. * testsuite/binutils-all/wasm32/invalid-wasm-1.d: Likewise. * testsuite/binutils-all/wasm32/invalid-wasm-1.s: Likewise. * testsuite/binutils-all/wasm32/long-sections.d: Likewise. * testsuite/binutils-all/wasm32/long-sections.s: Likewise. * testsuite/binutils-all/wasm32/parse-wasm.d: Likewise. * testsuite/binutils-all/wasm32/parse-wasm.s: Likewise. * testsuite/binutils-all/wasm32/parse-wasm-2.d: Likewise. * testsuite/binutils-all/wasm32/parse-wasm-2.s: Likewise. * testsuite/binutils-all/wasm32/prepared-section.d: Likewise. * testsuite/binutils-all/wasm32/prepared-section.s: Likewise. * testsuite/binutils-all/wasm32/wasm32.exp: New file, run tests. gas * config/tc-wasm32.h: New file: Add WebAssembly assembler target. * config/tc-wasm32.c: New file: Add WebAssembly assembler target. * Makefile.am: Add WebAssembly assembler target. * configure.tgt: Add WebAssembly assembler target. * doc/c-wasm32.texi: New file: Start documenting WebAssembly assembler. * doc/all.texi: Define WASM32. * doc/as.texinfo: Add WebAssembly entries. * NEWS: Mention the new support. * Makefile.in: Regenerate. * po/gas.pot: Regenerate. * po/POTFILES.in: Regenerate. * testsuite/gas/wasm32: New directory. * testsuite/gas/wasm32/allinsn.d: New file. * testsuite/gas/wasm32/allinsn.s: New file. * testsuite/gas/wasm32/illegal.l: New file. * testsuite/gas/wasm32/illegal.s: New file. * testsuite/gas/wasm32/illegal-2.l: New file. * testsuite/gas/wasm32/illegal-2.s: New file. * testsuite/gas/wasm32/illegal-3.l: New file. * testsuite/gas/wasm32/illegal-3.s: New file. * testsuite/gas/wasm32/illegal-4.l: New file. * testsuite/gas/wasm32/illegal-4.s: New file. * testsuite/gas/wasm32/illegal-5.l: New file. * testsuite/gas/wasm32/illegal-5.s: New file. * testsuite/gas/wasm32/illegal-6.l: New file. * testsuite/gas/wasm32/illegal-6.s: New file. * testsuite/gas/wasm32/illegal-7.l: New file. * testsuite/gas/wasm32/illegal-7.s: New file. * testsuite/gas/wasm32/illegal-8.l: New file. * testsuite/gas/wasm32/illegal-8.s: New file. * testsuite/gas/wasm32/illegal-9.l: New file. * testsuite/gas/wasm32/illegal-9.s: New file. * testsuite/gas/wasm32/illegal-10.l: New file. * testsuite/gas/wasm32/illegal-10.s: New file. * testsuite/gas/wasm32/illegal-11.l: New file. * testsuite/gas/wasm32/illegal-11.s: New file. * testsuite/gas/wasm32/illegal-12.l: New file. * testsuite/gas/wasm32/illegal-12.s: New file. * testsuite/gas/wasm32/illegal-13.l: New file. * testsuite/gas/wasm32/illegal-13.s: New file. * testsuite/gas/wasm32/illegal-14.l: New file. * testsuite/gas/wasm32/illegal-14.s: New file. * testsuite/gas/wasm32/illegal-15.l: New file. * testsuite/gas/wasm32/illegal-15.s: New file. * testsuite/gas/wasm32/illegal-16.l: New file. * testsuite/gas/wasm32/illegal-16.s: New file. * testsuite/gas/wasm32/illegal-17.l: New file. * testsuite/gas/wasm32/illegal-17.s: New file. * testsuite/gas/wasm32/illegal-18.l: New file. * testsuite/gas/wasm32/illegal-18.s: New file. * testsuite/gas/wasm32/illegal-19.l: New file. * testsuite/gas/wasm32/illegal-19.s: New file. * testsuite/gas/wasm32/illegal-20.l: New file. * testsuite/gas/wasm32/illegal-20.s: New file. * testsuite/gas/wasm32/illegal-21.l: New file. * testsuite/gas/wasm32/illegal-21.s: New file. * testsuite/gas/wasm32/illegal-22.l: New file. * testsuite/gas/wasm32/illegal-22.s: New file. * testsuite/gas/wasm32/illegal-24.l: New file. * testsuite/gas/wasm32/illegal-24.s: New file. * testsuite/gas/wasm32/illegal-25.l: New file. * testsuite/gas/wasm32/illegal-25.s: New file. * testsuite/gas/wasm32/reloc.d: New file. * testsuite/gas/wasm32/reloc.s: New file. * testsuite/gas/wasm32/wasm32.exp: New tests for WebAssembly architecture. opcodes * configure.ac: Add (empty) bfd_wasm32_arch target. * configure: Regenerate * po/opcodes.pot: Regenerate. include * opcode/wasm.h: New file to support wasm32 architecture. * elf/wasm32.h: Add R_WASM32_32 relocation. bfd * elf32-wasm32.c: Add relocation code, two relocs. * reloc.c: Add wasm32 relocations. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. * bfd/po/bfd.pot: Regenerate.
2017-03-30 17:57:21 +08:00
|| [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.
Remove netware support include/ * nlm/ChangeLog-9315: Delete. * nlm/alpha-ext.h: Delete. * nlm/common.h: Delete. * nlm/external.h: Delete. * nlm/i386-ext.h: Delete. * nlm/internal.h: Delete. * nlm/ppc-ext.h: Delete. * nlm/sparc32-ext.h: Delete. bfd/ * Makefile.am: Remove netware support. * bfd-in.h: Likewise. * bfd.c: Likewise. * config.bfd: Likewise. * configure.ac: Likewise. * doc/bfdint.texi: Likewise. * ecoff.c: Likewise. * targets.c: Likewise. * libnlm.h: Delete. * nlm-target.h: Delete. * nlm.c: Delete. * nlm32-alpha.c: Delete. * nlm32-i386.c: Delete. * nlm32-ppc.c: Delete. * nlm32-sparc.c: Delete. * nlm32.c: Delete. * nlm64.c: Delete. * nlmcode.h: Delete. * nlmswap.h: Delete. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. * configure: Regenerate. * po/SRC-POTFILES.in: Regenerate. binutils/ * .gitignore: Remove netware support. * Makefile.am: Likewise. * configure.ac: Likewise. * doc/Makefile.am: Likewise. * doc/binutils.texi: Likewise. * testsuite/binutils-all/nm.exp: Likewise. * nlmconv.c: Delete. * nlmconv.h: Delete. * nlmheader.y: Delete. * Makefile.in: Regenerate. * configure: Regenerate. * doc/Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. gas/ * Makefile.am: Remove netware support. * config/tc-i386.c: Likewise. * configure.tgt: Likewise. * config/te-netware.h: Delete. * Makefile.in: Regenerate. * po/POTFILES.in: Regenerate. gprof/ * corefile.c: Remove netware support. ld/ * Makefile.am: Remove netware support. * configure.tgt: Likewise. * testsuite/ld-powerpc/powerpc.exp: Likewise. * emulparams/i386nw.sh: Delete. * emulparams/ppcnw.sh: Delete. * scripttempl/nw.sc: Delete. * Makefile.in: Regenerate. * po/BLD-POTFILES.in: Regenerate.
2018-04-16 13:41:22 +08:00
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
}
}
}
1999-05-03 15:29:11 +08:00
# There are certainly other tests that could be run.