aboutsummaryrefslogtreecommitdiff
path: root/binutils
diff options
context:
space:
mode:
Diffstat (limited to 'binutils')
-rw-r--r--binutils/ChangeLog29
-rw-r--r--binutils/NEWS2
-rw-r--r--binutils/readelf.c9
-rw-r--r--binutils/testsuite/binutils-all/nm.exp3
-rw-r--r--binutils/testsuite/binutils-all/wasm32/create-wasm.d10
-rw-r--r--binutils/testsuite/binutils-all/wasm32/create-wasm.s6
-rw-r--r--binutils/testsuite/binutils-all/wasm32/custom-section.d11
-rw-r--r--binutils/testsuite/binutils-all/wasm32/custom-section.s4
-rw-r--r--binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.d6
-rw-r--r--binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.s7
-rw-r--r--binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.d6
-rw-r--r--binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.s7
-rw-r--r--binutils/testsuite/binutils-all/wasm32/long-sections.d13
-rw-r--r--binutils/testsuite/binutils-all/wasm32/long-sections.s9
-rw-r--r--binutils/testsuite/binutils-all/wasm32/parse-wasm-2.d15
-rw-r--r--binutils/testsuite/binutils-all/wasm32/parse-wasm-2.s43
-rw-r--r--binutils/testsuite/binutils-all/wasm32/parse-wasm.d8
-rw-r--r--binutils/testsuite/binutils-all/wasm32/parse-wasm.s7
-rw-r--r--binutils/testsuite/binutils-all/wasm32/prepared-section.d10
-rw-r--r--binutils/testsuite/binutils-all/wasm32/prepared-section.s6
-rw-r--r--binutils/testsuite/binutils-all/wasm32/wasm32.exp30
-rw-r--r--binutils/testsuite/lib/binutils-common.exp4
22 files changed, 244 insertions, 1 deletions
diff --git a/binutils/ChangeLog b/binutils/ChangeLog
index 9559587..767e315 100644
--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,32 @@
+2017-03-30 Pip Cet <pipcet@gmail.com>
+
+ * 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.
+
2017-03-29 Alan Modra <amodra@gmail.com>
* doc/binutils.texi (objdump): Document PowerPC -M options.
diff --git a/binutils/NEWS b/binutils/NEWS
index c98908a..1b824fa 100644
--- a/binutils/NEWS
+++ b/binutils/NEWS
@@ -1,5 +1,7 @@
-*- text -*-
+* Add support for the wasm32 ELF conversion of the Web Assembly file format.
+
* Add --inlines option to objdump, which extends the --line-numbers option
so that inlined functions will display their nesting information.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 6ede239..31a519b 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -151,6 +151,7 @@
#include "elf/v850.h"
#include "elf/vax.h"
#include "elf/visium.h"
+#include "elf/wasm32.h"
#include "elf/x86-64.h"
#include "elf/xc16x.h"
#include "elf/xgate.h"
@@ -809,6 +810,7 @@ guess_is_rela (unsigned int e_machine)
case EM_XTENSA_OLD:
case EM_MICROBLAZE:
case EM_MICROBLAZE_OLD:
+ case EM_WEBASSEMBLY:
return TRUE;
case EM_68HC05:
@@ -1498,6 +1500,10 @@ dump_relocations (FILE * file,
rtype = elf_tilepro_reloc_type (type);
break;
+ case EM_WEBASSEMBLY:
+ rtype = elf_wasm32_reloc_type (type);
+ break;
+
case EM_XGATE:
rtype = elf_xgate_reloc_type (type);
break;
@@ -12091,6 +12097,8 @@ is_32bit_abs_reloc (unsigned int reloc_type)
return reloc_type == 1; /* R_VAX_32. */
case EM_VISIUM:
return reloc_type == 3; /* R_VISIUM_32. */
+ case EM_WEBASSEMBLY:
+ return reloc_type == 1; /* R_WASM32_32. */
case EM_X86_64:
case EM_L1OM:
case EM_K1OM:
@@ -12396,6 +12404,7 @@ is_none_reloc (unsigned int reloc_type)
case EM_TI_C6000:/* R_C6000_NONE. */
case EM_X86_64: /* R_X86_64_NONE. */
case EM_XC16X:
+ case EM_WEBASSEMBLY: /* R_WASM32_NONE. */
return reloc_type == 0;
case EM_AARCH64:
diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/binutils-all/nm.exp
index 13eafa6..fdcf194 100644
--- a/binutils/testsuite/binutils-all/nm.exp
+++ b/binutils/testsuite/binutils-all/nm.exp
@@ -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"
diff --git a/binutils/testsuite/binutils-all/wasm32/create-wasm.d b/binutils/testsuite/binutils-all/wasm32/create-wasm.d
new file mode 100644
index 0000000..3a1c18a
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/create-wasm.d
@@ -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............
diff --git a/binutils/testsuite/binutils-all/wasm32/create-wasm.s b/binutils/testsuite/binutils-all/wasm32/create-wasm.s
new file mode 100644
index 0000000..5c360cc
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/create-wasm.s
@@ -0,0 +1,6 @@
+ .section .wasm.function
+ .byte 0
+ .section .wasm.type
+ .byte 1
+ .byte 0
+ .byte 0
diff --git a/binutils/testsuite/binutils-all/wasm32/custom-section.d b/binutils/testsuite/binutils-all/wasm32/custom-section.d
new file mode 100644
index 0000000..3a39e77
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/custom-section.d
@@ -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 .. *$
diff --git a/binutils/testsuite/binutils-all/wasm32/custom-section.s b/binutils/testsuite/binutils-all/wasm32/custom-section.s
new file mode 100644
index 0000000..81fa671
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/custom-section.s
@@ -0,0 +1,4 @@
+ .section .wasm.name
+ .byte 2
+ .byte 1
+ .byte 0
diff --git a/binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.d b/binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.d
new file mode 100644
index 0000000..e916fad
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.d
@@ -0,0 +1,6 @@
+#PROG: objcopy
+#source: invalid-wasm-1.s
+#as:
+#objcopy: -Ielf32-wasm32 -Obinary
+#objdump: -bwasm -sD
+#error: : File format not recognized \ No newline at end of file
diff --git a/binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.s b/binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.s
new file mode 100644
index 0000000..50d6690
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/invalid-wasm-1.s
@@ -0,0 +1,7 @@
+ .data
+ .byte 0
+ .ascii "ASM"
+ .byte 1
+ .byte 0
+ .byte 0
+ .byte 0
diff --git a/binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.d b/binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.d
new file mode 100644
index 0000000..da28775
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.d
@@ -0,0 +1,6 @@
+#PROG: objcopy
+#source: invalid-wasm-2.s
+#as:
+#objcopy: -Ielf32-wasm32 -Obinary
+#objdump: -bwasm -sD
+#exit: 1 \ No newline at end of file
diff --git a/binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.s b/binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.s
new file mode 100644
index 0000000..4270e9d
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/invalid-wasm-2.s
@@ -0,0 +1,7 @@
+ .data
+ .byte 0
+ .ascii "asm"
+ .byte 2
+ .byte 0
+ .byte 0
+ .byte 0
diff --git a/binutils/testsuite/binutils-all/wasm32/long-sections.d b/binutils/testsuite/binutils-all/wasm32/long-sections.d
new file mode 100644
index 0000000..edf9058
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/long-sections.d
@@ -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
diff --git a/binutils/testsuite/binutils-all/wasm32/long-sections.s b/binutils/testsuite/binutils-all/wasm32/long-sections.s
new file mode 100644
index 0000000..a8642d2
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/long-sections.s
@@ -0,0 +1,9 @@
+ .section .wasm.type
+ .rept 256
+ .byte 0
+ .endr
+
+ .section .wasm.code
+ .rept 65536
+ .byte 0
+ .endr
diff --git a/binutils/testsuite/binutils-all/wasm32/parse-wasm-2.d b/binutils/testsuite/binutils-all/wasm32/parse-wasm-2.d
new file mode 100644
index 0000000..8b59c74
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/parse-wasm-2.d
@@ -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
diff --git a/binutils/testsuite/binutils-all/wasm32/parse-wasm-2.s b/binutils/testsuite/binutils-all/wasm32/parse-wasm-2.s
new file mode 100644
index 0000000..bc918b7
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/parse-wasm-2.s
@@ -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
diff --git a/binutils/testsuite/binutils-all/wasm32/parse-wasm.d b/binutils/testsuite/binutils-all/wasm32/parse-wasm.d
new file mode 100644
index 0000000..fd8bc70
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/parse-wasm.d
@@ -0,0 +1,8 @@
+#PROG: objcopy
+#source: parse-wasm.s
+#as:
+#objcopy: -Ielf32-wasm32 -Obinary
+#objdump: -bwasm -s
+
+.*:.*file format wasm
+
diff --git a/binutils/testsuite/binutils-all/wasm32/parse-wasm.s b/binutils/testsuite/binutils-all/wasm32/parse-wasm.s
new file mode 100644
index 0000000..d495ea1
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/parse-wasm.s
@@ -0,0 +1,7 @@
+ .data
+ .byte 0
+ .ascii "asm"
+ .byte 1
+ .byte 0
+ .byte 0
+ .byte 0
diff --git a/binutils/testsuite/binutils-all/wasm32/prepared-section.d b/binutils/testsuite/binutils-all/wasm32/prepared-section.d
new file mode 100644
index 0000000..c5bfafa
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/prepared-section.d
@@ -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.
diff --git a/binutils/testsuite/binutils-all/wasm32/prepared-section.s b/binutils/testsuite/binutils-all/wasm32/prepared-section.s
new file mode 100644
index 0000000..574f6e0
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/prepared-section.s
@@ -0,0 +1,6 @@
+ .section .prepared
+ .byte 0
+ .byte 0x6
+ .byte 4
+ .ascii "name"
+ .byte 0
diff --git a/binutils/testsuite/binutils-all/wasm32/wasm32.exp b/binutils/testsuite/binutils-all/wasm32/wasm32.exp
new file mode 100644
index 0000000..b95569a
--- /dev/null
+++ b/binutils/testsuite/binutils-all/wasm32/wasm32.exp
@@ -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"
diff --git a/binutils/testsuite/lib/binutils-common.exp b/binutils/testsuite/lib/binutils-common.exp
index 327db46..70b6773 100644
--- a/binutils/testsuite/lib/binutils-common.exp
+++ b/binutils/testsuite/lib/binutils-common.exp
@@ -41,6 +41,7 @@ proc is_elf_format {} {
&& ![istarget *-*-solaris2*]
&& ![istarget *-*-sysv4*]
&& ![istarget *-*-unixware*]
+ && ![istarget *-*-wasm32*]
&& ![istarget avr-*-*]
&& ![istarget bfin-*-uclinux]
&& ![istarget frv-*-uclinux*]
@@ -183,6 +184,9 @@ proc supports_gnu_unique {} {
if { [istarget "arm*-*-*eabi*"] } {
return 1
}
+ if { [istarget "wasm32*-*-*"] } {
+ return 1
+ }
if { ![istarget "*-*-elf*"] } {
return 0
}