Skip to content

Commit dfc0d51

Browse files
authored
Add a module name to the name section (#1055)
It's additional name type (with code 0) alongside function and local names.
1 parent a8d95ac commit dfc0d51

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

BinaryEncoding.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,11 @@ be skipped over by an engine. The current list of valid `name_type` codes are:
449449

450450
| Name Type | Code | Description |
451451
| --------- | ---- | ----------- |
452+
| [Module](#module-name) | `0` | Assigns a name to the module |
452453
| [Function](#function-names) | `1` | Assigns names to functions |
453454
| [Local](#local-names) | `2` | Assigns names to locals in functions |
454455

456+
455457
When present, name subsections must appear in this order and at most once. The
456458
end of the last subsection must coincide with the last byte of the name
457459
section to be a well-formed name section.
@@ -498,6 +500,16 @@ where a `local_name` is encoded as:
498500
| index | `varuint32` | the index of the function whose locals are being named |
499501
| local_map | `name_map` | assignment of names to local indices |
500502

503+
#### Module name
504+
505+
The module name subsection assigns a name to the module itself. It simply
506+
consists of a single string:
507+
508+
| Field | Type | Description |
509+
| ----- | ---- | ----------- |
510+
| name_len | `varuint32` | length of `name_str` in bytes |
511+
| name_str | `bytes` | UTF-8 encoding of the name |
512+
501513
# Function Bodies
502514

503515
Function bodies consist of a sequence of local variable declarations followed by

0 commit comments

Comments
 (0)