Skip to content

Commit 6c3c0b2

Browse files
Add missing relocations and segment flags to the documentation. (#222)
1 parent 4dd47d2 commit 6c3c0b2

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

DynamicLinking.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ relocation types for accessing data and functions address relative to
161161
(`-fPIC`) where absolute function addresses are not known at link time.
162162
- `17 / R_WASM_MEMORY_ADDR_REL_SLEB64` - the 64-bit counterpart of
163163
`R_WASM_MEMORY_ADDR_REL_SLEB`.
164+
- `21 / R_WASM_MEMORY_ADDR_TLS_SLEB` (in LLVM 12.0) - an offset from the
165+
`__tls_base` symbol encoded as a 5-byte [varint32]. Used for PIC case to avoid
166+
absolute relocation.
167+
- `25 / R_WASM_MEMORY_ADDR_TLS_SLEB64` (in LLVM 13.0) - the 64-bit counterpart
168+
of `R_WASM_MEMORY_ADDR_TLS_SLEB`.
164169

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

Linking.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,27 @@ 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-
- `18 / R_WASM_TABLE_INDEX_SLEB64` (in LLVM `master`) - the 64-bit counterpart
130+
- `18 / R_WASM_TABLE_INDEX_SLEB64` (in LLVM 12.0) - the 64-bit counterpart
131131
of `R_WASM_TABLE_INDEX_SLEB`. A function table index encoded as a 10-byte
132132
[varint64]. Used to refer to the immediate argument of a `i64.const`
133133
instruction, e.g. taking the address of a function in Wasm64.
134-
- `19 / R_WASM_TABLE_INDEX_I64` (in LLVM `master`) - the 64-bit counterpart of
134+
- `19 / R_WASM_TABLE_INDEX_I64` (in LLVM 12.0) - the 64-bit counterpart of
135135
`R_WASM_TABLE_INDEX_I32`. A function table index encoded as a [uint64], e.g.
136136
taking the address of a function in a static data initializer.
137-
- `20 / R_WASM_TABLE_NUMBER_LEB` (in LLVM `master`) - a table number encoded as
137+
- `20 / R_WASM_TABLE_NUMBER_LEB` (in LLVM 12.0) - a table number encoded as
138138
a 5-byte [varuint32]. Used for the table immediate argument in the table.*
139139
instructions.
140+
- `22 / R_WASM_FUNCTION_OFFSET_I64` (in LLVM 12.0) - the 64-bit counterpart
141+
of `R_WASM_FUNCTION_OFFSET_I32`. A byte offset within code section for the
142+
specific function encoded as a [uint64].
143+
- `23 / R_WASM_MEMORY_ADDR_LOCREL_I32` (in LLVM 13.0) - a byte offset between
144+
the relocating address and a linear memory index encoded as a [uint32]. Used
145+
for pointer-relative addressing.
146+
- `24 / R_WASM_TABLE_INDEX_REL_SLEB64` (in LLVM 13.0) - the 64-bit counterpart
147+
of `R_WASM_TABLE_INDEX_REL_SLEB`. A function table index encoded as a 10-byte
148+
[varint64].
149+
- `26 / R_WASM_FUNCTION_INDEX_I32` (in LLVM 17.0) - a function index encoded as
150+
a [uint32]. Used in custom sections for function annotations (`__attribute__((annotate(<name>)))`).
140151

141152
**Note**: Please note that the 64bit relocations are not yet stable and
142153
therefore, subject to change.
@@ -233,6 +244,7 @@ where a `segment` is encoded as:
233244
The current set of valid flag for segments are:
234245
- `1 / WASM_SEGMENT_FLAG_STRINGS` - Signals that the segment contains only null terminated strings allowing the linker to perform merging.
235246
- `2 / WASM_SEGMENT_FLAG_TLS` - The segment contains thread-local data. This means that a unique copy of this segment will be created for each thread.
247+
- `4 / WASM_SEG_FLAG_RETAIN` - If the object file is included in the final link, the segment should be retained in the final output regardless of whether it is used by the program.
236248

237249
For `WASM_INIT_FUNCS` the following fields are present in the
238250
subsection:

0 commit comments

Comments
 (0)