Skip to content

Commit b4e70a8

Browse files
authored
DynamicLinking: Specify new "dylink" section format (#170)
llvm change: https://reviews.llvm.org/D109595 binaryen change: WebAssembly/binaryen#4141 wabt change: WebAssembly/wabt#1707 emscripten change: emscripten-core/emscripten#15019
1 parent 42ee8c7 commit b4e70a8

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

DynamicLinking.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,48 @@ A WebAssembly dynamic library is a WebAssembly binary with a special custom
1212
section that indicates this is a dynamic library and contains additional
1313
information needed by the loader.
1414

15-
## The "dylink" Section
15+
## The "dylink.0" Section
1616

17-
The "dylink" section is defined as:
17+
The "dylink.0" is a custom section, the existence of which signals that the
18+
module conforms the dynaminc linking ABI described in this document. This
19+
section is expected to be the very first section in the module.
20+
21+
A "dylink.0" consists of a series of sub-sections using the same format as found
22+
in the ["names"][names_sec] section:
23+
24+
| Field | Type | Description |
25+
| ----------- | ------------- | ------------------------------------ |
26+
| subsections | `subsection*` | sequence of `subsection` |
27+
28+
Each `subsection` is encoded as:
29+
30+
| Field | Type | Description |
31+
| ------------ | ----------- | ------------------------------------ |
32+
| type | `uint8` | code identifying type of subsection |
33+
| payload_len | `varuint32` | size of this subsection in bytes |
34+
| payload_data | `bytes` | content of this subsection, of length `payload_len` |
35+
36+
The current list of valid `type` codes are:
37+
38+
- `1 / WASM_DYLINK_MEM_INFO` - Specifies the memory and table space requirements of the module
39+
40+
- `2 / WASM_DYLINK_NEEDED` - Specifies external modules that this one depends on.
41+
42+
For `WASM_DYLINK_MEM_INFO` the following fields are present in the
43+
subsection:
1844

1945
| Field | Type | Description |
2046
| ---------------------- | --------------- | ------------------------------ |
2147
| memorysize | `varuint32` | Size of the memory area the loader should reserve for the module, which will begin at `env.__memory_base` |
2248
| memoryalignment | `varuint32` | The required alignment of the memory area, in bytes, encoded as a power of 2. |
2349
| tablesize | `varuint32` | Size of the table area the loader should reserve for the module, which will begin at `env.__table_base` |
2450
| tablealignment | `varuint32` | The required alignment of the table area, in elements, encoded as a power of 2. |
51+
52+
For `WASM_DYLINK_NEEDED` the following fields are present in the
53+
subsection:
54+
55+
| Field | Type | Description |
56+
| ---------------------- | --------------- | ------------------------------ |
2557
| needed_dynlibs_count | `varuint32` | Number of needed shared libraries |
2658
| needed_dynlibs_entries | `dynlib_entry*` | Repeated dynamic library entries as described below |
2759

@@ -51,6 +83,8 @@ The "dylink" section should be the very first section in the module; this allows
5183
detection of whether a binary is a dynamic library without having to scan the
5284
entire contents.
5385

86+
[names_sec]: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#name-section
87+
5488
## Interface and usage
5589

5690
A WebAssembly dynamic library must obey certain conventions. In addition to

0 commit comments

Comments
 (0)