mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 09:08:59 +00:00
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.
This commit is contained in:
@@ -175,7 +175,8 @@ if { [is_elf_format]
|
||||
|| [istarget *-*-tpf*]
|
||||
|| [istarget *-*-uclinux*]
|
||||
|| [istarget ia64-*-*vms*]
|
||||
|| [istarget *-*-vxworks*] } {
|
||||
|| [istarget *-*-vxworks*]
|
||||
|| [istarget wasm32-*-*] } {
|
||||
set nm_1_src "nm-elf-1.s"
|
||||
} else {
|
||||
set nm_1_src "nm-1.s"
|
||||
|
||||
10
binutils/testsuite/binutils-all/wasm32/create-wasm.d
Normal file
10
binutils/testsuite/binutils-all/wasm32/create-wasm.d
Normal file
@@ -0,0 +1,10 @@
|
||||
#PROG: objcopy
|
||||
#source: create-wasm.s
|
||||
#as:
|
||||
#objcopy: -Ielf32-wasm32 -Owasm
|
||||
#objdump: -bbinary -s
|
||||
|
||||
.*:.*file format binary
|
||||
|
||||
Contents of section .data:
|
||||
0000 0061736d 01000000 01030100 00030100 .asm............
|
||||
6
binutils/testsuite/binutils-all/wasm32/create-wasm.s
Normal file
6
binutils/testsuite/binutils-all/wasm32/create-wasm.s
Normal file
@@ -0,0 +1,6 @@
|
||||
.section .wasm.function
|
||||
.byte 0
|
||||
.section .wasm.type
|
||||
.byte 1
|
||||
.byte 0
|
||||
.byte 0
|
||||
11
binutils/testsuite/binutils-all/wasm32/custom-section.d
Normal file
11
binutils/testsuite/binutils-all/wasm32/custom-section.d
Normal file
@@ -0,0 +1,11 @@
|
||||
#PROG: objcopy
|
||||
#source: custom-section.s
|
||||
#as:
|
||||
#objcopy: -Ielf32-wasm32 -Owasm
|
||||
#objdump: -bbinary -s
|
||||
|
||||
.*:.*file format binary
|
||||
|
||||
Contents of section .data:
|
||||
0000 0061736d 01000000 0008046e 616d6502 .asm.......name.
|
||||
0010 0100 .. *$
|
||||
4
binutils/testsuite/binutils-all/wasm32/custom-section.s
Normal file
4
binutils/testsuite/binutils-all/wasm32/custom-section.s
Normal file
@@ -0,0 +1,4 @@
|
||||
.section .wasm.name
|
||||
.byte 2
|
||||
.byte 1
|
||||
.byte 0
|
||||
6
binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.d
Normal file
6
binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.d
Normal file
@@ -0,0 +1,6 @@
|
||||
#PROG: objcopy
|
||||
#source: invalid-wasm-1.s
|
||||
#as:
|
||||
#objcopy: -Ielf32-wasm32 -Obinary
|
||||
#objdump: -bwasm -sD
|
||||
#error: : File format not recognized
|
||||
7
binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.s
Normal file
7
binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.s
Normal file
@@ -0,0 +1,7 @@
|
||||
.data
|
||||
.byte 0
|
||||
.ascii "ASM"
|
||||
.byte 1
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
6
binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.d
Normal file
6
binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.d
Normal file
@@ -0,0 +1,6 @@
|
||||
#PROG: objcopy
|
||||
#source: invalid-wasm-2.s
|
||||
#as:
|
||||
#objcopy: -Ielf32-wasm32 -Obinary
|
||||
#objdump: -bwasm -sD
|
||||
#exit: 1
|
||||
7
binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.s
Normal file
7
binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.s
Normal file
@@ -0,0 +1,7 @@
|
||||
.data
|
||||
.byte 0
|
||||
.ascii "asm"
|
||||
.byte 2
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
13
binutils/testsuite/binutils-all/wasm32/long-sections.d
Normal file
13
binutils/testsuite/binutils-all/wasm32/long-sections.d
Normal file
@@ -0,0 +1,13 @@
|
||||
#PROG: objcopy
|
||||
#source: long-sections.s
|
||||
#as:
|
||||
#objcopy: -Ielf32-wasm32 -Owasm
|
||||
#objdump: -bbinary -s
|
||||
|
||||
.*:.*file format binary
|
||||
|
||||
Contents of section .data:
|
||||
00000 0061736d 01000000 01800200 00000000 .asm............
|
||||
#...
|
||||
00100 00000000 00000000 0000000a 80800400 ................
|
||||
#pass
|
||||
9
binutils/testsuite/binutils-all/wasm32/long-sections.s
Normal file
9
binutils/testsuite/binutils-all/wasm32/long-sections.s
Normal file
@@ -0,0 +1,9 @@
|
||||
.section .wasm.type
|
||||
.rept 256
|
||||
.byte 0
|
||||
.endr
|
||||
|
||||
.section .wasm.code
|
||||
.rept 65536
|
||||
.byte 0
|
||||
.endr
|
||||
15
binutils/testsuite/binutils-all/wasm32/parse-wasm-2.d
Normal file
15
binutils/testsuite/binutils-all/wasm32/parse-wasm-2.d
Normal file
@@ -0,0 +1,15 @@
|
||||
#PROG: objcopy
|
||||
#source: parse-wasm-2.s
|
||||
#as:
|
||||
#objcopy: -Ielf32-wasm32 -Obinary
|
||||
#objdump: -bwasm -s
|
||||
|
||||
.*:.*file format wasm
|
||||
|
||||
Contents of section .wasm.type:
|
||||
80000000 01600001 7f .`...
|
||||
Contents of section .wasm.function:
|
||||
80000005 0100 ..
|
||||
Contents of section .wasm.code:
|
||||
80000007 01858080 80000041 2a0f0b .......A\*..
|
||||
#pass
|
||||
43
binutils/testsuite/binutils-all/wasm32/parse-wasm-2.s
Normal file
43
binutils/testsuite/binutils-all/wasm32/parse-wasm-2.s
Normal file
@@ -0,0 +1,43 @@
|
||||
.data
|
||||
.byte 0
|
||||
.ascii "asm"
|
||||
.byte 1
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 1
|
||||
.byte 0x85
|
||||
.byte 0x80
|
||||
.byte 0x80
|
||||
.byte 0x80
|
||||
.byte 0
|
||||
.byte 1
|
||||
.byte 0x60
|
||||
.byte 0
|
||||
.byte 1
|
||||
.byte 0x7f
|
||||
.byte 3
|
||||
.byte 0x82
|
||||
.byte 0x80
|
||||
.byte 0x80
|
||||
.byte 0x80
|
||||
.byte 0
|
||||
.byte 1
|
||||
.byte 0
|
||||
.byte 0x0a
|
||||
.byte 0x8b
|
||||
.byte 0x80
|
||||
.byte 0x80
|
||||
.byte 0x80
|
||||
.byte 0
|
||||
.byte 1
|
||||
.byte 0x85
|
||||
.byte 0x80
|
||||
.byte 0x80
|
||||
.byte 0x80
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0x41
|
||||
.byte 0x2a
|
||||
.byte 0x0f
|
||||
.byte 0x0b
|
||||
8
binutils/testsuite/binutils-all/wasm32/parse-wasm.d
Normal file
8
binutils/testsuite/binutils-all/wasm32/parse-wasm.d
Normal file
@@ -0,0 +1,8 @@
|
||||
#PROG: objcopy
|
||||
#source: parse-wasm.s
|
||||
#as:
|
||||
#objcopy: -Ielf32-wasm32 -Obinary
|
||||
#objdump: -bwasm -s
|
||||
|
||||
.*:.*file format wasm
|
||||
|
||||
7
binutils/testsuite/binutils-all/wasm32/parse-wasm.s
Normal file
7
binutils/testsuite/binutils-all/wasm32/parse-wasm.s
Normal file
@@ -0,0 +1,7 @@
|
||||
.data
|
||||
.byte 0
|
||||
.ascii "asm"
|
||||
.byte 1
|
||||
.byte 0
|
||||
.byte 0
|
||||
.byte 0
|
||||
10
binutils/testsuite/binutils-all/wasm32/prepared-section.d
Normal file
10
binutils/testsuite/binutils-all/wasm32/prepared-section.d
Normal file
@@ -0,0 +1,10 @@
|
||||
#PROG: objcopy
|
||||
#source: prepared-section.s
|
||||
#as:
|
||||
#objcopy: -Ielf32-wasm32 -Owasm
|
||||
#objdump: -bbinary -s
|
||||
|
||||
.*:.*file format binary
|
||||
|
||||
Contents of section .data:
|
||||
0000 0061736d 01000000 0006046e 616d6500 .asm.......name.
|
||||
@@ -0,0 +1,6 @@
|
||||
.section .prepared
|
||||
.byte 0
|
||||
.byte 0x6
|
||||
.byte 4
|
||||
.ascii "name"
|
||||
.byte 0
|
||||
30
binutils/testsuite/binutils-all/wasm32/wasm32.exp
Normal file
30
binutils/testsuite/binutils-all/wasm32/wasm32.exp
Normal file
@@ -0,0 +1,30 @@
|
||||
# Copyright (C) 2010-2017 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2017 Pip Cet <pipcet@gmail.com>
|
||||
|
||||
# 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.
|
||||
|
||||
if { ![istarget "wasm32-*-*"] } then {
|
||||
return
|
||||
}
|
||||
|
||||
run_dump_test "create-wasm"
|
||||
run_dump_test "custom-section"
|
||||
run_dump_test "long-sections"
|
||||
run_dump_test "parse-wasm"
|
||||
run_dump_test "parse-wasm-2"
|
||||
run_dump_test "prepared-section"
|
||||
|
||||
#run_dump_test "invalid-wasm-1"
|
||||
#run_dump_test "invalid-wasm-2"
|
||||
Reference in New Issue
Block a user