Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing relocations and segment flags to the documentation. #222

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions DynamicLinking.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ relocation types for accessing data and functions address relative to
(`-fPIC`) where absolute function addresses are not known at link time.
- `17 / R_WASM_MEMORY_ADDR_REL_SLEB64` - the 64-bit counterpart of
`R_WASM_MEMORY_ADDR_REL_SLEB`.
- `21 / R_WASM_MEMORY_ADDR_TLS_SLEB` (in LLVM 12.0) - an offset from the
`__tls_base` symbol encoded as a 5-byte [varint32]. Used for PIC case to reject
kateinoigakukun marked this conversation as resolved.
Show resolved Hide resolved
absolute relocation.
- `25 / R_WASM_MEMORY_ADDR_TLS_SLEB64` (in LLVM 13.0) - the 64-bit counterpart
of `R_WASM_MEMORY_ADDR_TLS_SLEB`.

All code that gets linked into a WebAssembly dynamic library must be compiled
as position independant. The corresponding absolute reloction types
Expand Down
18 changes: 15 additions & 3 deletions Linking.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,27 @@ of `R_WASM_MEMORY_ADDR_SLEB`. A 64-bit linear memory index encoded as a 10-byte
- `16 / R_WASM_MEMORY_ADDR_I64` (since LLVM 11.0) - the 64-bit counterpart of
`R_WASM_MEMORY_ADDR`. A 64-bit linear memory index encoded as a [uint64], e.g.
taking the 64-bit address of a C++ global in a static data initializer.
- `18 / R_WASM_TABLE_INDEX_SLEB64` (in LLVM `master`) - the 64-bit counterpart
- `18 / R_WASM_TABLE_INDEX_SLEB64` (in LLVM 12.0) - the 64-bit counterpart
of `R_WASM_TABLE_INDEX_SLEB`. A function table index encoded as a 10-byte
[varint64]. Used to refer to the immediate argument of a `i64.const`
instruction, e.g. taking the address of a function in Wasm64.
- `19 / R_WASM_TABLE_INDEX_I64` (in LLVM `master`) - the 64-bit counterpart of
- `19 / R_WASM_TABLE_INDEX_I64` (in LLVM 12.0) - the 64-bit counterpart of
`R_WASM_TABLE_INDEX_I32`. A function table index encoded as a [uint64], e.g.
taking the address of a function in a static data initializer.
- `20 / R_WASM_TABLE_NUMBER_LEB` (in LLVM `master`) - a table number encoded as
- `20 / R_WASM_TABLE_NUMBER_LEB` (in LLVM 12.0) - a table number encoded as
a 5-byte [varuint32]. Used for the table immediate argument in the table.*
instructions.
- `22 / R_WASM_FUNCTION_OFFSET_I64` (in LLVM 12.0) - the 64-bit counterpart
of `R_WASM_FUNCTION_OFFSET_I32`. A byte offset within code section for the
specific function encoded as a [uint64].
- `23 / R_WASM_MEMORY_ADDR_LOCREL_I32` (in LLVM 13.0) - a byte offset between
the relocating address and a linear memory index encoded as a [uint32]. Used
for pointer-relative addressing.
- `24 / R_WASM_TABLE_INDEX_REL_SLEB64` (in LLVM 13.0) - the 64-bit counterpart
of `R_WASM_TABLE_INDEX_REL_SLEB`. A function table index encoded as a 10-byte
[varint64].
- `26 / R_WASM_FUNCTION_INDEX_I32` (in LLVM 17.0) - a function index encoded as
a [uint32]. Used in custom sections for function annotations (`__attribute__((annotate(<name>)))`).

**Note**: Please note that the 64bit relocations are not yet stable and
therefore, subject to change.
Expand Down Expand Up @@ -233,6 +244,7 @@ where a `segment` is encoded as:
The current set of valid flag for segments are:
- `1 / WASM_SEGMENT_FLAG_STRINGS` - Signals that the segment contains only null terminated strings allowing the linker to perform merging.
- `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.
- `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.

For `WASM_INIT_FUNCS` the following fields are present in the
subsection:
Expand Down