diff --git a/utils/jsffi/dyld.mjs b/utils/jsffi/dyld.mjs index 3c1c2106557af837d978f495343e2fe1e7acf8e3..c6cfedbece4f60075ebf4cb66929e1c2ed68ce29 100755 --- a/utils/jsffi/dyld.mjs +++ b/utils/jsffi/dyld.mjs @@ -796,12 +796,17 @@ class DyLD { const init = () => { // See - // https://github.com/llvm/llvm-project/blob/llvmorg-19.1.1/lld/wasm/Writer.cpp#L1430, - // there's also __wasm_init_memory (not relevant yet, we don't + // https://gitlab.haskell.org/haskell-wasm/llvm-project/-/blob/release/20.x/lld/wasm/Writer.cpp#L1450, + // __wasm_apply_data_relocs is now optional so only call it if + // it exists (we know for sure it exists for libc.so though). + // There's also __wasm_init_memory (not relevant yet, we don't // use passive segments) & __wasm_apply_global_relocs but // those are included in the start function and should have - // been called upon instantiation. - instance.exports.__wasm_apply_data_relocs(); + // been called upon instantiation, see + // Writer::createStartFunction(). + if (instance.exports.__wasm_apply_data_relocs) { + instance.exports.__wasm_apply_data_relocs(); + } instance.exports._initialize(); };