Custom Sections¶
This appendix defines dedicated custom sections for WebAssembly’s binary format. Such sections do not contribute to, or otherwise affect, the WebAssembly semantics, and like any custom section they may be ignored by an implementation. However, they provide useful meta data that implementations can make use of to improve user experience or take compilation hints.
Currently, only one dedicated custom section is defined, the name section.
Name Section¶
The name section is a custom section whose name string is itself
The purpose of this section is to attach printable names to definitions in a module, which e.g. can be used by a debugger or when parts of the module are to be rendered in text form.
Subsections¶
The data of a name section consists of a sequence of subsections. Each subsection consists of a
a one-byte subsection id,
the
size of the contents, in bytes,the actual contents, whose structure is dependent on the subsection id.
The following subsection ids are used:
Id |
Subsection |
---|---|
0 |
|
1 |
|
2 |
Each subsection may occur at most once, and in order of increasing id.
Name Maps¶
A name map assigns names to indices in a given index space. It consists of a vector of index/name pairs in order of increasing index value. Each index must be unique, but the assigned names need not be.
An indirect name map assigns names to a two-dimensional index space, where secondary indices are grouped by primary indices. It consists of a vector of primary index/name map pairs in order of increasing index value, where each name map in turn maps secondary indices to names. Each primary index must be unique, and likewise each secondary index per individual name map.
Module Names¶
The module name subsection has the id 0. It simply consists of a single name that is assigned to the module itself.
Function Names¶
The function name subsection has the id 1. It consists of a name map assigning function names to function indices.
Local Names¶
The local name subsection has the id 2. It consists of an indirect name map assigning local names to local indices grouped by function indices.