Skip to content

Commit d31de62

Browse files
authored
Rename relocations from R_WEBASSEMBLY_ to R_WASM_ (#95)
This is less typing and IMHO more readable, and it also fits with our naming around the binary format which tends to use the short name.
1 parent 9a278aa commit d31de62

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

Linking.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -60,47 +60,47 @@ A `relocation_entry` begins with:
6060
| -------- | ------------------- | ------------------------------ |
6161
| type | `uint8` | the relocation type |
6262
| 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) |
6464

6565
A relocation type can be one of the following:
6666

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
6868
[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
7070
5-byte [varint32]. Used to refer to the immediate argument of a `i32.const`
7171
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
7373
[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
7575
[varuint32]. Used for the immediate argument of a `load` or `store`
7676
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
7878
[varint32]. Used for the immediate argument of a `i32.const` instruction,
7979
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
8181
[uint32], e.g. taking the address of a C++ global in a static data
8282
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
8484
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
8686
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
8888
for the specic function encoded as a [uint32].
8989
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
9191
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
9393
[varuint32]. Used for the immediate argument of a `throw` and `if_except`
9494
instruction.
9595

9696
[varuint32]: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#varuintn
9797
[varint32]: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#varintn
9898
[uint32]: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#uintn
9999

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:
104104

105105
| Field | Type | Description |
106106
| ------ | ---------------- | ----------------------------------- |
@@ -331,11 +331,11 @@ stored in the code section:
331331
2. Immediate argument of the `i32.const` instruction (taking the address of a
332332
function).
333333

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.
339339

340340
The same technique applies for all function calls whether the function is
341341
imported or defined locally.
@@ -360,9 +360,9 @@ section.
360360

361361
The output data section is formed, essentially, by concatenating the data
362362
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.
366366

367367
Segments are linked as a whole, and a segment is either entirely included or
368368
excluded from the link.
@@ -381,11 +381,11 @@ Processing Relocations
381381

382382
The final code and data sections are written out with relocations applied.
383383

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
385385
shall contain a newly-synthesised type section which contains entries for all
386386
functions and type relocations in the output.
387387

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
389389
cannot fail. The output Wasm file shall contain a newly-synthesised table,
390390
which contains an entry for all defined or imported symbols referenced by table
391391
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
394394
import nor a definition (namely, weakly-undefined function symbols), the value
395395
`0` is written out as the value of the relocation.
396396

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
398398
which case linking fails. This occurs if there is a weakly-undefined function
399399
symbol, in which case there is no legal value that can be written as the target
400400
of any `call` instruction. The frontend must generate calls to undefined weak
401401
symbols via a `call_indirect` instruction.
402402

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
404404
case linking fails. This occurs if there is a weakly-undefined global symbol,
405405
in which case there is no legal value that can be written as the target of any
406406
`get_global` or `set_global` instruction. (This means the frontend must not
407407
generate weak globals which may not be defined; a definition or import must
408408
exist for all global symbols in the linked output.)
409409

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
412412
is the offset within the linear memory of the symbol within the output segment,
413413
plus the symbol's addend. If the symbol is undefined (whether weak or strong),
414414
the value of the relocation shall be `0`.
415415

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
417417
adjusted to reflect new offsets in the code section.
418418

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
420420
adjusted to reflect new offsets in the combined sections.
421421

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
423423
case linking fails. This occurs if there is a weakly-undefined event symbol, in
424424
which case there is no legal value that can be written as the target of any
425425
`throw` and `if_except` instruction. (This means the frontend must not generate

0 commit comments

Comments
 (0)