mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-14 04:43:38 +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.
120 lines
4.2 KiB
Plaintext
120 lines
4.2 KiB
Plaintext
@c Copyright (C) 2017 Free Software Foundation, Inc.
|
|
@c This is part of the GAS manual.
|
|
@c For copying conditions, see the file as.texinfo.
|
|
@c man end
|
|
|
|
@ifset GENERIC
|
|
@page
|
|
@node WebAssembly-Dependent
|
|
@chapter WebAssembly Dependent Features
|
|
@end ifset
|
|
|
|
@ifclear GENERIC
|
|
@node Machine Dependencies
|
|
@chapter WebAssembly Dependent Features
|
|
@end ifclear
|
|
|
|
@cindex WebAssembly support
|
|
@menu
|
|
* WebAssembly-Notes:: Notes
|
|
* WebAssembly-Syntax:: Syntax
|
|
* WebAssembly-Floating-Point:: Floating Point
|
|
* WebAssembly-Opcodes:: Opcodes
|
|
* WebAssembly-module-layout:: Module Layout
|
|
@end menu
|
|
|
|
@node WebAssembly-Notes
|
|
@section Notes
|
|
@cindex WebAssembly notes
|
|
@cindex notes for WebAssembly
|
|
|
|
While WebAssembly provides its own module format for executables, this
|
|
documentation describes how to use @code{@value{AS}} to produce
|
|
intermediate ELF object format files.
|
|
|
|
@node WebAssembly-Syntax
|
|
@section Syntax
|
|
@cindex WebAssembly Syntax
|
|
The assembler syntax directly encodes sequences of opcodes as defined
|
|
in the WebAssembly binary encoding specification at
|
|
https://github.com/webassembly/spec/BinaryEncoding.md. Structured
|
|
sexp-style expressions are not supported as input.
|
|
|
|
@menu
|
|
* WebAssembly-Chars:: Special Characters
|
|
* WebAssembly-Relocs:: Relocations
|
|
* WebAssembly-Signatures:: Signatures
|
|
@end menu
|
|
|
|
@node WebAssembly-Chars
|
|
@subsection Special Characters
|
|
|
|
@cindex line comment character, WebAssembly
|
|
@cindex WebAssembly line comment character
|
|
@samp{#} and @samp{;} are the line comment characters. Note that if
|
|
@samp{#} is the first character on a line then it can also be a
|
|
logical line number directive (@pxref{Comments}) or a preprocessor
|
|
control command (@pxref{Preprocessing}).
|
|
|
|
@node WebAssembly-Relocs
|
|
@subsection Relocations
|
|
@cindex WebAssembly relocations
|
|
@cindex relocations, WebAssembly
|
|
|
|
Special relocations are available by using the @samp{@@@var{plt}},
|
|
@samp{@@@var{got}}, or @samp{@@@var{got}} suffixes after a constant
|
|
expression, which correspond to the R_ASMJS_LEB128_PLT,
|
|
R_ASMJS_LEB128_GOT, and R_ASMJS_LEB128_GOT_CODE relocations,
|
|
respectively.
|
|
|
|
The @samp{@@@var{plt}} suffix is followed by a symbol name in braces;
|
|
the symbol value is used to determine the function signature for which
|
|
a PLT stub is generated. Currently, the symbol @emph{name} is parsed
|
|
from its last @samp{F} character to determine the argument count of
|
|
the function, which is also necessary for generating a PLT stub.
|
|
|
|
@node WebAssembly-Signatures
|
|
@subsection Signatures
|
|
@cindex WebAssembly signatures
|
|
@cindex signatures, WebAssembly
|
|
|
|
Function signatures are specified with the @code{signature}
|
|
pseudo-opcode, followed by a simple function signature imitating a
|
|
C++-mangled function type: @code{F} followed by an optional @code{v},
|
|
then a sequence of @code{i}, @code{l}, @code{f}, and @code{d}
|
|
characters to mark i32, i64, f32, and f64 parameters, respectively;
|
|
followed by a final @code{E} to mark the end of the function
|
|
signature.
|
|
|
|
@node WebAssembly-Floating-Point
|
|
@section Floating Point
|
|
@cindex floating point, WebAssembly (@sc{ieee})
|
|
@cindex WebAssembly floating point (@sc{ieee})
|
|
WebAssembly uses little-endian @sc{ieee} floating-point numbers.
|
|
|
|
@node WebAssembly-Opcodes
|
|
@section Regular Opcodes
|
|
@cindex opcodes, WebAssembly
|
|
@cindex WebAssembly opcodes
|
|
Ordinary instructions are encoded with the WebAssembly mnemonics as
|
|
listed at:
|
|
@url{https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md}.
|
|
|
|
Opcodes are written directly in the order in which they are encoded,
|
|
without going through an intermediate sexp-style expression as in the
|
|
@code{was} format.
|
|
|
|
For ``typed'' opcodes (block, if, etc.), the type of the block is
|
|
specified in square brackets following the opcode: @code{if[i]},
|
|
@code{if[]}.
|
|
|
|
@node WebAssembly-module-layout
|
|
@section WebAssembly Module Layout
|
|
@cindex module layout, WebAssembly
|
|
@cindex WebAssembly module layout
|
|
@code{@value{AS}} will only produce ELF output, not a valid
|
|
WebAssembly module. It is possible to make @code{@value{AS}} produce
|
|
output in a single ELF section which becomes a valid WebAssembly
|
|
module, but a linker script to do so may be preferrable, as it doesn't
|
|
require running the entire module through the assembler at once.
|