@@ -12,16 +12,48 @@ A WebAssembly dynamic library is a WebAssembly binary with a special custom
12
12
section that indicates this is a dynamic library and contains additional
13
13
information needed by the loader.
14
14
15
- ## The "dylink" Section
15
+ ## The "dylink.0 " Section
16
16
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:
18
44
19
45
| Field | Type | Description |
20
46
| ---------------------- | --------------- | ------------------------------ |
21
47
| memorysize | ` varuint32 ` | Size of the memory area the loader should reserve for the module, which will begin at ` env.__memory_base ` |
22
48
| memoryalignment | ` varuint32 ` | The required alignment of the memory area, in bytes, encoded as a power of 2. |
23
49
| tablesize | ` varuint32 ` | Size of the table area the loader should reserve for the module, which will begin at ` env.__table_base ` |
24
50
| 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
+ | ---------------------- | --------------- | ------------------------------ |
25
57
| needed_dynlibs_count | ` varuint32 ` | Number of needed shared libraries |
26
58
| needed_dynlibs_entries | ` dynlib_entry* ` | Repeated dynamic library entries as described below |
27
59
@@ -51,6 +83,8 @@ The "dylink" section should be the very first section in the module; this allows
51
83
detection of whether a binary is a dynamic library without having to scan the
52
84
entire contents.
53
85
86
+ [ names_sec ] : https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#name-section
87
+
54
88
## Interface and usage
55
89
56
90
A WebAssembly dynamic library must obey certain conventions. In addition to
0 commit comments