[lld] [WebAssembly] Generate a call to __wasm_apply_global_tls_relocs in __wasm_init_memory (PR #149832)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 8 11:23:02 PDT 2025


sbc100 wrote:

> If this is the case, then `__wasm_init_memory` shouldn't initialize the TLS section. As it stands, `__wasm_init_memory` initalizes TLS, so a call to `__wasm_init_tls` would lead to initializing TLS twice. 

What exactly is happening twice if you call `__wasm_init_tls` on the main thread today?   Do you mean the `memory.init` call?  Or some kind of relocation application?

> As I mentioned earlier, neither wasix-libc nor (afaik, but I'm pretty certain) wasi-libc call `__wasm_init_tls` on the main thread.

Does this mean that any program that contains TLS relocations (non-empty `__wasm_apply_tls_relocs` function)  would not work?   Since the main thread TLS data segement would not have these relocations applied?


https://github.com/llvm/llvm-project/pull/149832


More information about the llvm-commits mailing list