Skip to content
Open
Changes from all commits
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
12 changes: 10 additions & 2 deletions lld/wasm/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1366,6 +1366,14 @@ void Writer::createInitMemoryFunction() {
writeUleb128(os, s->index, "segment index immediate");
writeU8(os, 0, "memory index immediate");
}

// After initializing the TLS segment, we also need to apply TLS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "After initializing the TLS segment and setting __tls_base we can call __wasm_apply_global_tls_relocs"

// relocations in the same way __wasm_init_tls does.
if (s->isTLS() && ctx.sym.applyGlobalTLSRelocs) {
writeU8(os, WASM_OPCODE_CALL, "CALL");
writeUleb128(os, ctx.sym.applyGlobalTLSRelocs->getFunctionIndex(),
"function index");
}
}
}

Expand Down Expand Up @@ -1518,8 +1526,8 @@ void Writer::createApplyGlobalRelocationsFunction() {
}

// Similar to createApplyGlobalRelocationsFunction but for
// TLS symbols. This cannot be run during the start function
// but must be delayed until __wasm_init_tls is called.
// TLS symbols. Can only be called after __tls_base is
// initialized.
void Writer::createApplyGlobalTLSRelocationsFunction() {
// First write the body's contents to a string.
std::string bodyContent;
Expand Down