Skip to content

port(wasm): Apply shared-memory TLS template pointers per thread - #2733

Merged
lapla-cogito merged 2 commits into
wild-linker:mainfrom
lapla-cogito:wasm_tls_template
Oct 16, 2026
Merged

lapla-cogito merged 2 commits into
wild-linker:mainfrom
lapla-cogito:wasm_tls_template

Conversation

@lapla-cogito

@lapla-cogito lapla-cogito commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

An R_WASM_MEMORY_ADDR_I32 in a shared-memory TLS template that targets a TLS symbol has no single address at link time. Leave that slot unchanged in the passive template and have __wasm_init_tls store __tls_base + displacement after the copy.

Part of #1431

reject_tls_template_reloc(index_map, &reloc)?;
// The passive template is shared. Per-thread TLS pointers are stored by `__wasm_init_tls`.
if in_tls_template && deferred_tls_template_pointer(index_map, &reloc)?.is_some() {
return Ok(());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note that this early return bypasses the "Wasm relocation slot out of range" check in apply_relocation. My inclination is that this probably isn't important, but I thought I'd mention it in case you decide that it does matter.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don't think it's important since that check guards the write into the template and this path does not write the slot.

@lapla-cogito
lapla-cogito enabled auto-merge (squash) October 16, 2026 03:45
@lapla-cogito
lapla-cogito merged commit 59e106c into wild-linker:main Oct 16, 2026
26 checks passed
@lapla-cogito
lapla-cogito deleted the wasm_tls_template branch October 16, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants