@@ -60,47 +60,47 @@ A `relocation_entry` begins with:
60
60
| -------- | ------------------- | ------------------------------ |
61
61
| type | ` uint8 ` | the relocation type |
62
62
| offset | ` varuint32 ` | offset of the value to rewrite |
63
- | index | ` varuint32 ` | the index of the symbol used (or, for ` R_WEBASSEMBLY_TYPE_INDEX_LEB ` relocations, the index of the type) |
63
+ | index | ` varuint32 ` | the index of the symbol used (or, for ` R_WASM_TYPE_INDEX_LEB ` relocations, the index of the type) |
64
64
65
65
A relocation type can be one of the following:
66
66
67
- - ` 0 / R_WEBASSEMBLY_FUNCTION_INDEX_LEB ` - a function index encoded as a 5-byte
67
+ - ` 0 / R_WASM_FUNCTION_INDEX_LEB ` - a function index encoded as a 5-byte
68
68
[ varuint32] . Used for the immediate argument of a ` call ` instruction.
69
- - ` 1 / R_WEBASSEMBLY_TABLE_INDEX_SLEB ` - a function table index encoded as a
69
+ - ` 1 / R_WASM_TABLE_INDEX_SLEB ` - a function table index encoded as a
70
70
5-byte [ varint32] . Used to refer to the immediate argument of a ` i32.const `
71
71
instruction, e.g. taking the address of a function.
72
- - ` 2 / R_WEBASSEMBLY_TABLE_INDEX_I32 ` - a function table index encoded as a
72
+ - ` 2 / R_WASM_TABLE_INDEX_I32 ` - a function table index encoded as a
73
73
[ uint32] , e.g. taking the address of a function in a static data initializer.
74
- - ` 3 / R_WEBASSEMBLY_MEMORY_ADDR_LEB ` - a linear memory index encoded as a 5-byte
74
+ - ` 3 / R_WASM_MEMORY_ADDR_LEB ` - a linear memory index encoded as a 5-byte
75
75
[ varuint32] . Used for the immediate argument of a ` load ` or ` store `
76
76
instruction, e.g. directly loading from or storing to a C++ global.
77
- - ` 4 / R_WEBASSEMBLY_MEMORY_ADDR_SLEB ` - a linear memory index encoded as a 5-byte
77
+ - ` 4 / R_WASM_MEMORY_ADDR_SLEB ` - a linear memory index encoded as a 5-byte
78
78
[ varint32] . Used for the immediate argument of a ` i32.const ` instruction,
79
79
e.g. taking the address of a C++ global.
80
- - ` 5 / R_WEBASSEMBLY_MEMORY_ADDR_I32 ` - a linear memory index encoded as a
80
+ - ` 5 / R_WASM_MEMORY_ADDR_I32 ` - a linear memory index encoded as a
81
81
[ uint32] , e.g. taking the address of a C++ global in a static data
82
82
initializer.
83
- - ` 6 / R_WEBASSEMBLY_TYPE_INDEX_LEB ` - a type table index encoded as a
83
+ - ` 6 / R_WASM_TYPE_INDEX_LEB ` - a type table index encoded as a
84
84
5-byte [ varuint32] , e.g. the type immediate in a ` call_indirect ` .
85
- - ` 7 / R_WEBASSEMBLY_GLOBAL_INDEX_LEB ` - a global index encoded as a
85
+ - ` 7 / R_WASM_GLOBAL_INDEX_LEB ` - a global index encoded as a
86
86
5-byte [ varuint32] , e.g. the index immediate in a ` get_global ` .
87
- - ` 8 / R_WEBASSEMBLY_FUNCTION_OFFSET_I32 ` - a byte offset within code section
87
+ - ` 8 / R_WASM_FUNCTION_OFFSET_I32 ` - a byte offset within code section
88
88
for the specic function encoded as a [ uint32] .
89
89
The offsets start at the actual function code excluding its size field.
90
- - ` 9 / R_WEBASSEMBLY_SECTION_OFFSET_I32 ` - an byte offset from start of the
90
+ - ` 9 / R_WASM_SECTION_OFFSET_I32 ` - an byte offset from start of the
91
91
specified section encoded as a [ uint32] .
92
- - ` 10 / R_WEBASSEMBLY_EVENT_INDEX_LEB ` - an event index encoded as a 5-byte
92
+ - ` 10 / R_WASM_EVENT_INDEX_LEB ` - an event index encoded as a 5-byte
93
93
[ varuint32] . Used for the immediate argument of a ` throw ` and ` if_except `
94
94
instruction.
95
95
96
96
[ varuint32 ] : https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#varuintn
97
97
[ varint32 ] : https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#varintn
98
98
[ uint32 ] : https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#uintn
99
99
100
- For ` R_WEBASSEMBLY_MEMORY_ADDR_LEB ` , ` R_WEBASSEMBLY_MEMORY_ADDR_SLEB ` ,
101
- ` R_WEBASSEMBLY_MEMORY_ADDR_I32 ` , ` R_WEBASSEMBLY_FUNCTION_OFFSET_I32 ` ,
102
- and ` R_WEBASSEMBLY_SECTION_OFFSET_I32 ` relocations the following field is
103
- additionally present:
100
+ For ` R_WASM_MEMORY_ADDR_LEB ` , ` R_WEBASSEMBLY_MEMORY_ADDR_SLEB ` ,
101
+ ` R_WASM_MEMORY_ADDR_I32 ` , ` R_WEBASSEMBLY_FUNCTION_OFFSET_I32 ` , and
102
+ ` R_WASM_SECTION_OFFSET_I32 ` relocations the following field is additionally
103
+ present:
104
104
105
105
| Field | Type | Description |
106
106
| ------ | ---------------- | ----------------------------------- |
@@ -331,11 +331,11 @@ stored in the code section:
331
331
2 . Immediate argument of the ` i32.const ` instruction (taking the address of a
332
332
function).
333
333
334
- The immediate argument of all such instructions are stored as padded LEB128
335
- such that they can be rewritten without altering the size of the code section.
336
- For each such instruction a ` R_WEBASSEMBLY_FUNCTION_INDEX_LEB ` or
337
- ` R_WEBASSEMBLY_TABLE_INDEX_SLEB ` ` reloc ` entry is generated pointing to the
338
- offset of the immediate within the code section.
334
+ The immediate argument of all such instructions are stored as padded LEB128 such
335
+ that they can be rewritten without altering the size of the code section. For
336
+ each such instruction a ` R_WASM_FUNCTION_INDEX_LEB ` or ` R_WASM_TABLE_INDEX_SLEB `
337
+ ` reloc ` entry is generated pointing to the offset of the immediate within the
338
+ code section.
339
339
340
340
The same technique applies for all function calls whether the function is
341
341
imported or defined locally.
@@ -360,9 +360,9 @@ section.
360
360
361
361
The output data section is formed, essentially, by concatenating the data
362
362
sections of the input files. Since the final location in linear memory of any
363
- given symbol is not known until link time, all references to data addresses
364
- with the code and data sections generate ` R_WEBASSEMBLY_MEMORY_ADDR_* `
365
- relocation entries, which reference a data symbol.
363
+ given symbol is not known until link time, all references to data addresses with
364
+ the code and data sections generate ` R_WASM_MEMORY_ADDR_* ` relocation entries,
365
+ which reference a data symbol.
366
366
367
367
Segments are linked as a whole, and a segment is either entirely included or
368
368
excluded from the link.
@@ -381,11 +381,11 @@ Processing Relocations
381
381
382
382
The final code and data sections are written out with relocations applied.
383
383
384
- ` R_WEBASSEMBLY_TYPE_INDEX_LEB ` relocations cannot fail. The output Wasm file
384
+ ` R_WASM_TYPE_INDEX_LEB ` relocations cannot fail. The output Wasm file
385
385
shall contain a newly-synthesised type section which contains entries for all
386
386
functions and type relocations in the output.
387
387
388
- ` R_WEBASSEMBLY_TABLE_INDEX_SLEB ` and ` R_WEBASSEMBLY_TABLE_INDEX_I32 ` relocations
388
+ ` R_WASM_TABLE_INDEX_SLEB ` and ` R_WEBASSEMBLY_TABLE_INDEX_I32 ` relocations
389
389
cannot fail. The output Wasm file shall contain a newly-synthesised table,
390
390
which contains an entry for all defined or imported symbols referenced by table
391
391
relocations. The output table elements shall begin at a non-zero offset within
@@ -394,32 +394,32 @@ Finally, when processing table relocations for symbols which have neither an
394
394
import nor a definition (namely, weakly-undefined function symbols), the value
395
395
` 0 ` is written out as the value of the relocation.
396
396
397
- ` R_WEBASSEMBLY_FUNCTION_INDEX_LEB ` relocations may fail to be processed, in
397
+ ` R_WASM_FUNCTION_INDEX_LEB ` relocations may fail to be processed, in
398
398
which case linking fails. This occurs if there is a weakly-undefined function
399
399
symbol, in which case there is no legal value that can be written as the target
400
400
of any ` call ` instruction. The frontend must generate calls to undefined weak
401
401
symbols via a ` call_indirect ` instruction.
402
402
403
- ` R_WEBASSEMBLY_GLOBAL_INDEX_LEB ` relocations may fail to be processed, in which
403
+ ` R_WASM_GLOBAL_INDEX_LEB ` relocations may fail to be processed, in which
404
404
case linking fails. This occurs if there is a weakly-undefined global symbol,
405
405
in which case there is no legal value that can be written as the target of any
406
406
` get_global ` or ` set_global ` instruction. (This means the frontend must not
407
407
generate weak globals which may not be defined; a definition or import must
408
408
exist for all global symbols in the linked output.)
409
409
410
- ` R_WEBASSEMBLY_MEMORY_ADDR_LEB ` , ` R_WEBASSEMBLY_MEMORY_ADDR_SLEB ` and
411
- ` R_WEBASSEMBLY_MEMORY_ADDR_I32 ` relocations cannot fail. The relocation's value
410
+ ` R_WASM_MEMORY_ADDR_LEB ` , ` R_WEBASSEMBLY_MEMORY_ADDR_SLEB ` and
411
+ ` R_WASM_MEMORY_ADDR_I32 ` relocations cannot fail. The relocation's value
412
412
is the offset within the linear memory of the symbol within the output segment,
413
413
plus the symbol's addend. If the symbol is undefined (whether weak or strong),
414
414
the value of the relocation shall be ` 0 ` .
415
415
416
- ` R_WEBASSEMBLY_FUNCTION_OFFSET_I32 ` relocations cannot fail. The values shall be
416
+ ` R_WASM_FUNCTION_OFFSET_I32 ` relocations cannot fail. The values shall be
417
417
adjusted to reflect new offsets in the code section.
418
418
419
- ` R_WEBASSEMBLY_SECTION_OFFSET_I32 ` relocation cannot fail. The values shall be
419
+ ` R_WASM_SECTION_OFFSET_I32 ` relocation cannot fail. The values shall be
420
420
adjusted to reflect new offsets in the combined sections.
421
421
422
- ` R_WEBASSEMBLY_EVENT_INDEX_LEB ` relocations may fail to be processed, in which
422
+ ` R_WASM_EVENT_INDEX_LEB ` relocations may fail to be processed, in which
423
423
case linking fails. This occurs if there is a weakly-undefined event symbol, in
424
424
which case there is no legal value that can be written as the target of any
425
425
` throw ` and ` if_except ` instruction. (This means the frontend must not generate
0 commit comments