Skip to content
Snippets Groups Projects
Commit 62a689f3 authored by Cheng Shao's avatar Cheng Shao
Browse files

wasm: fix dyld for shared libraries created by llvm 20.x

This patch fixes wasm dyld script for shared libraries created by llvm
20.x. The __wasm_apply_data_relocs function is now optional and may be
omitted for shared libraries without any runtime relocatable data
segments, so only call __wasm_apply_data_relocs when it's present.

(cherry picked from commit cb60da24)
(cherry picked from commit 6bd4fd72)
parent 7902bbcb
No related branches found
No related tags found
No related merge requests found
...@@ -794,12 +794,17 @@ class DyLD { ...@@ -794,12 +794,17 @@ class DyLD {
const init = () => { const init = () => {
// See // See
// https://github.com/llvm/llvm-project/blob/llvmorg-19.1.1/lld/wasm/Writer.cpp#L1430, // https://gitlab.haskell.org/haskell-wasm/llvm-project/-/blob/release/20.x/lld/wasm/Writer.cpp#L1450,
// there's also __wasm_init_memory (not relevant yet, we don't // __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 // use passive segments) & __wasm_apply_global_relocs but
// those are included in the start function and should have // those are included in the start function and should have
// been called upon instantiation. // been called upon instantiation, see
instance.exports.__wasm_apply_data_relocs(); // Writer::createStartFunction().
if (instance.exports.__wasm_apply_data_relocs) {
instance.exports.__wasm_apply_data_relocs();
}
instance.exports._initialize(); instance.exports._initialize();
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment