mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
f96bd6c2d7
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.
243 lines
7.1 KiB
Plaintext
243 lines
7.1 KiB
Plaintext
# Copyright (C) 1993-2017 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 {
|
|
return
|
|
}
|
|
|
|
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*" "alpha*-*-netware*"
|
|
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
|
|
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
|
|
|
|
# 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"
|
|
}
|
|
|
|
if [is_elf_format] {
|
|
# PR binutils/12753
|
|
# Test nm -g on a unique global symbol.
|
|
|
|
# Only some targets support unique symbols.
|
|
if {([istarget "i?86-*-*"]
|
|
|| [istarget "x86_64-*-*"]
|
|
|| [istarget "arm-*-*"]
|
|
|| [istarget "powerpc*-*-*"]
|
|
|| [istarget "sparc*-*-*"])} then {
|
|
|
|
if {![binutils_assemble $srcdir/$subdir/unique.s tmpdir/unique.o]} then {
|
|
fail "nm -g on unique symbols (assembling)"
|
|
} 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"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
# 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*" "mips*-sony-bsd*"
|
|
|
|
# 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 --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 "mmix-knuth-mmixware"]
|
|
|| [istarget *-*-netware*]
|
|
|| [istarget *-*-nto*]
|
|
|| [istarget *-*-rdos*]
|
|
|| [istarget *-*-tpf*]
|
|
|| [istarget *-*-uclinux*]
|
|
|| [istarget ia64-*-*vms*]
|
|
|| [istarget *-*-vxworks*]
|
|
|| [istarget wasm32-*-*] } {
|
|
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 {
|
|
return
|
|
}
|
|
|
|
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*" "alpha*-*-netware*"
|
|
setup_xfail "mips*-*-ultrix*" "mips*-*-ecoff*" "mips*-*-irix4*"
|
|
setup_xfail "mips*-*-riscos*" "mips*-*-sysv3*" "mips*-sony-bsd*"
|
|
|
|
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/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"
|
|
}
|
|
}
|
|
}
|
|
|
|
# There are certainly other tests that could be run.
|