Home | History | Annotate | Line # | Download | only in doc
c-wasm32.texi revision 1.1
      1  1.1  christos @c Copyright (C) 2017-2018 Free Software Foundation, Inc.
      2  1.1  christos @c This is part of the GAS manual.
      3  1.1  christos @c For copying conditions, see the file as.texinfo.
      4  1.1  christos @c man end
      5  1.1  christos 
      6  1.1  christos @ifset GENERIC
      7  1.1  christos @page
      8  1.1  christos @node WebAssembly-Dependent
      9  1.1  christos @chapter WebAssembly Dependent Features
     10  1.1  christos @end ifset
     11  1.1  christos 
     12  1.1  christos @ifclear GENERIC
     13  1.1  christos @node Machine Dependencies
     14  1.1  christos @chapter WebAssembly Dependent Features
     15  1.1  christos @end ifclear
     16  1.1  christos 
     17  1.1  christos @cindex WebAssembly support
     18  1.1  christos @menu
     19  1.1  christos * WebAssembly-Notes::                Notes
     20  1.1  christos * WebAssembly-Syntax::               Syntax
     21  1.1  christos * WebAssembly-Floating-Point::       Floating Point
     22  1.1  christos * WebAssembly-Opcodes::              Opcodes
     23  1.1  christos * WebAssembly-module-layout::        Module Layout
     24  1.1  christos @end menu
     25  1.1  christos 
     26  1.1  christos @node WebAssembly-Notes
     27  1.1  christos @section Notes
     28  1.1  christos @cindex WebAssembly notes
     29  1.1  christos @cindex notes for WebAssembly
     30  1.1  christos 
     31  1.1  christos While WebAssembly provides its own module format for executables, this
     32  1.1  christos documentation describes how to use @code{@value{AS}} to produce
     33  1.1  christos intermediate ELF object format files.
     34  1.1  christos 
     35  1.1  christos @node WebAssembly-Syntax
     36  1.1  christos @section Syntax
     37  1.1  christos @cindex WebAssembly Syntax
     38  1.1  christos The assembler syntax directly encodes sequences of opcodes as defined
     39  1.1  christos in the WebAssembly binary encoding specification at
     40  1.1  christos https://github.com/webassembly/spec/BinaryEncoding.md.  Structured
     41  1.1  christos sexp-style expressions are not supported as input.
     42  1.1  christos 
     43  1.1  christos @menu
     44  1.1  christos * WebAssembly-Chars::                Special Characters
     45  1.1  christos * WebAssembly-Relocs::               Relocations
     46  1.1  christos * WebAssembly-Signatures::           Signatures
     47  1.1  christos @end menu
     48  1.1  christos 
     49  1.1  christos @node WebAssembly-Chars
     50  1.1  christos @subsection Special Characters
     51  1.1  christos 
     52  1.1  christos @cindex line comment character, WebAssembly
     53  1.1  christos @cindex WebAssembly line comment character
     54  1.1  christos @samp{#} and @samp{;} are the line comment characters.  Note that if
     55  1.1  christos @samp{#} is the first character on a line then it can also be a
     56  1.1  christos logical line number directive (@pxref{Comments}) or a preprocessor
     57  1.1  christos control command (@pxref{Preprocessing}).
     58  1.1  christos 
     59  1.1  christos @node WebAssembly-Relocs
     60  1.1  christos @subsection Relocations
     61  1.1  christos @cindex WebAssembly relocations
     62  1.1  christos @cindex relocations, WebAssembly
     63  1.1  christos 
     64  1.1  christos Special relocations are available by using the @samp{@@@var{plt}},
     65  1.1  christos @samp{@@@var{got}}, or @samp{@@@var{got}} suffixes after a constant
     66  1.1  christos expression, which correspond to the R_ASMJS_LEB128_PLT,
     67  1.1  christos R_ASMJS_LEB128_GOT, and R_ASMJS_LEB128_GOT_CODE relocations,
     68  1.1  christos respectively.
     69  1.1  christos 
     70  1.1  christos The @samp{@@@var{plt}} suffix is followed by a symbol name in braces;
     71  1.1  christos the symbol value is used to determine the function signature for which
     72  1.1  christos a PLT stub is generated. Currently, the symbol @emph{name} is parsed
     73  1.1  christos from its last @samp{F} character to determine the argument count of
     74  1.1  christos the function, which is also necessary for generating a PLT stub.
     75  1.1  christos 
     76  1.1  christos @node WebAssembly-Signatures
     77  1.1  christos @subsection Signatures
     78  1.1  christos @cindex WebAssembly signatures
     79  1.1  christos @cindex signatures, WebAssembly
     80  1.1  christos 
     81  1.1  christos Function signatures are specified with the @code{signature}
     82  1.1  christos pseudo-opcode, followed by a simple function signature imitating a
     83  1.1  christos C++-mangled function type: @code{F} followed by an optional @code{v},
     84  1.1  christos then a sequence of @code{i}, @code{l}, @code{f}, and @code{d}
     85  1.1  christos characters to mark i32, i64, f32, and f64 parameters, respectively;
     86  1.1  christos followed by a final @code{E} to mark the end of the function
     87  1.1  christos signature.
     88  1.1  christos 
     89  1.1  christos @node WebAssembly-Floating-Point
     90  1.1  christos @section Floating Point
     91  1.1  christos @cindex floating point, WebAssembly (@sc{ieee})
     92  1.1  christos @cindex WebAssembly floating point (@sc{ieee})
     93  1.1  christos WebAssembly uses little-endian @sc{ieee} floating-point numbers.
     94  1.1  christos 
     95  1.1  christos @node WebAssembly-Opcodes
     96  1.1  christos @section Regular Opcodes
     97  1.1  christos @cindex opcodes, WebAssembly
     98  1.1  christos @cindex WebAssembly opcodes
     99  1.1  christos Ordinary instructions are encoded with the WebAssembly mnemonics as
    100  1.1  christos listed at:
    101  1.1  christos @url{https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md}.
    102  1.1  christos 
    103  1.1  christos Opcodes are written directly in the order in which they are encoded,
    104  1.1  christos without going through an intermediate sexp-style expression as in the
    105  1.1  christos @code{was} format.
    106  1.1  christos 
    107  1.1  christos For ``typed'' opcodes (block, if, etc.), the type of the block is
    108  1.1  christos specified in square brackets following the opcode: @code{if[i]},
    109  1.1  christos @code{if[]}.
    110  1.1  christos 
    111  1.1  christos @node WebAssembly-module-layout
    112  1.1  christos @section WebAssembly Module Layout
    113  1.1  christos @cindex module layout, WebAssembly
    114  1.1  christos @cindex WebAssembly module layout
    115  1.1  christos @code{@value{AS}} will only produce ELF output, not a valid
    116  1.1  christos WebAssembly module. It is possible to make @code{@value{AS}} produce
    117  1.1  christos output in a single ELF section which becomes a valid WebAssembly
    118  1.1  christos module, but a linker script to do so may be preferrable, as it doesn't
    119  1.1  christos require running the entire module through the assembler at once.
    120