Skip to content

Commit 42ee8c7

Browse files
authored
Move dynamic linking docs to DynamicLinking.md. (#169)
1 parent 020c896 commit 42ee8c7

File tree

2 files changed

+15
-18
lines changed

2 files changed

+15
-18
lines changed

DynamicLinking.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ relocation types for accessing data and functions address relative to
8787
- `12 / R_WASM_TABLE_INDEX_REL_SLEB` - a function address (table index)
8888
relative to the `__table_base` wasm global. Used in position indepenent code
8989
(`-fPIC`) where absolute function addresses are not known at link time.
90+
- `17 / R_WASM_MEMORY_ADDR_REL_SLEB64` - the 64-bit counterpart of
91+
`R_WASM_MEMORY_ADDR_REL_SLEB`.
9092

9193
All code that gets linked into a WebAssembly dynamic library must be compiled
9294
as position independant. The corresponding absolute reloction types

Linking.md

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ of `R_WASM_MEMORY_ADDR_SLEB`. A 64-bit linear memory index encoded as a 10-byte
127127
- `16 / R_WASM_MEMORY_ADDR_I64` (since LLVM 11.0) - the 64-bit counterpart of
128128
`R_WASM_MEMORY_ADDR`. A 64-bit linear memory index encoded as a [uint64], e.g.
129129
taking the 64-bit address of a C++ global in a static data initializer.
130-
- `17 / R_WASM_MEMORY_ADDR_REL_SLEB64` (since LLVM 11.0) - the 64-bit
131-
counterpart of `R_WASM_MEMORY_ADDR_REL_SLEB`.
132130
- `18 / R_WASM_TABLE_INDEX_SLEB64` (in LLVM `master`) - the 64-bit counterpart
133131
of `R_WASM_TABLE_INDEX_SLEB`. A function table index encoded as a 10-byte
134132
[varint64]. Used to refer to the immediate argument of a `i64.const`
@@ -150,8 +148,7 @@ therefore, subject to change.
150148
[uint32]: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#uintn
151149
[uint64]: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md#uintn
152150

153-
For `R_WASM_MEMORY_ADDR_LEB`, `R_WASM_MEMORY_ADDR_SLEB`,
154-
`R_WASM_MEMORY_ADDR_I32`, `R_WASM_FUNCTION_OFFSET_I32`, and
151+
For `R_WASM_MEMORY_ADDR_*`, `R_WASM_FUNCTION_OFFSET_I32`, and
155152
`R_WASM_SECTION_OFFSET_I32` relocations (and their 64-bit counterparts) the
156153
following field is additionally present:
157154

@@ -522,15 +519,14 @@ The final code and data sections are written out with relocations applied.
522519
`R_WASM_TYPE_INDEX_LEB` relocations cannot fail. The output Wasm file
523520
shall contain a newly-synthesised type section which contains entries for all
524521
functions and type relocations in the output.
525-
526-
`R_WASM_TABLE_INDEX_SLEB`, `R_WASM_TABLE_INDEX_I32` relocations and their 64-bit counterparts (`R_WASM_TABLE_INDEX_SLEB64` and `R_WASM_TABLE_INDEX_I64`)
527-
cannot fail. The output Wasm file shall contain a newly-synthesised table,
528-
which contains an entry for all defined or imported symbols referenced by table
529-
relocations. The output table elements shall begin at a non-zero offset within
530-
the table, so that a `call_indirect 0` instruction is guaranteed to fail.
531-
Finally, when processing table relocations for symbols which have neither an
532-
import nor a definition (namely, weakly-undefined function symbols), the value
533-
`0` is written out as the value of the relocation.
522+
`R_WASM_TABLE_INDEX_*` relocations cannot fail. The output Wasm file shall
523+
contain a newly-synthesised table, which contains an entry for all defined or
524+
imported symbols referenced by table relocations. The output table elements
525+
shall begin at a non-zero offset within the table, so that a `call_indirect 0`
526+
instruction is guaranteed to fail. Finally, when processing table relocations
527+
for symbols which have neither an import nor a definition (namely,
528+
weakly-undefined function symbols), the value `0` is written out as the value
529+
of the relocation.
534530

535531
`R_WASM_FUNCTION_INDEX_LEB` relocations may fail to be processed, in
536532
which case linking fails. This occurs if there is a weakly-undefined function
@@ -545,11 +541,10 @@ in which case there is no legal value that can be written as the target of any
545541
generate weak globals which may not be defined; a definition or import must
546542
exist for all global symbols in the linked output.)
547543

548-
`R_WASM_MEMORY_ADDR_LEB`, `R_WASM_MEMORY_ADDR_SLEB` and
549-
`R_WASM_MEMORY_ADDR_I32` relocations (and their 64-bit counterpairs `R_WASM_MEMORY_ADDR_LEB64`, `R_WASM_MEMORY_ADDR_SLEB64`, and `R_WASM_MEMORY_ADDR_I64`) cannot fail. The relocation's value
550-
is the offset within the linear memory of the symbol within the output segment,
551-
plus the symbol's addend. If the symbol is undefined (whether weak or strong),
552-
the value of the relocation shall be `0`.
544+
`R_WASM_MEMORY_*` relocations cannot fail. The relocation's value is the offset
545+
within the linear memory of the symbol within the output segment, plus the
546+
symbol's addend. If the symbol is undefined (whether weak or strong), the value
547+
of the relocation shall be `0`.
553548

554549
`R_WASM_FUNCTION_OFFSET_I32` relocations cannot fail. The values shall be
555550
adjusted to reflect new offsets in the code section.

0 commit comments

Comments
 (0)