-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[WebAssembly] non-pie dynamic-linking executable seems broken (LLVM 19 regression) #107387
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-lld-wasm Author: YAMAMOTO Takashi (yamt)
build the following test code as a non-pie dynamically-linked executable.
llvm 19 produces non-working binary.
llvm 18 worked fine.
you can find the full test code and compiler/linker options in https://github.com/yamt/garbage/tree/master/c/shlib_2
void f(void);
void (*f_p)(void) = f;
void
_start(void)
{
f_p();
} spacetanuki% toywasm --dyld main
Error: [trap] uninitialized element (8): call_indirect (null funcref) 0
current pc 0000fd
frame[ 0] funcpc 0000e2 (main:_start)
2024-09-05 20:43:42 (1725536622.157386000): [10fb06600] instance_execute_func failed with -1
2024-09-05 20:43:42 (1725536622.157883000): [10fb06600] invoke failed with -1
spacetanuki% note that llvm 19's __wasm_apply_data_relocs is empty. llvm 19.1.0-rc4
llvm 18.1.2
|
I wasn't aware that non-PIE dynamic executables were something that was working. I had hoped to get it working since emscripten could benefit from this I think, but its not something that emscripten currently uses, which is the biggest user of dynamic linking today (IIUC). So I guess I'm not surprised that this use case broke, but we should certainly fix it, and improve the tests in this area. |
… phase Instead of always generating __wasm_apply_data_relocs when relevant options like -pie and -shared are specified, generate it only when the relevant relocations are actually necessary. Note: omitting empty __wasm_apply_data_relocs is not a problem because the export is optional in the spec (DynamicLinking.md) and all runtime linker implementations I'm aware of implement it that way. (emscripten, toywasm, wasm-tools) Motivations: * This possibly reduces the module size * This is also a preparation to fix llvm#107387, for which it isn't obvious if we need these relocations at the time of createSyntheticSymbols. (unless we introduce a new explicit option like --non-pie-dynamic-link.)
…ction Instead of always generating __wasm_apply_data_relocs when relevant options like -pie and -shared are specified, generate it only when the relevant relocations are actually necessary. Note: omitting empty __wasm_apply_data_relocs is not a problem because the export is optional in the spec (DynamicLinking.md) and all runtime linker implementations I'm aware of implement it that way. (emscripten, toywasm, wasm-tools) Motivations: * This possibly reduces the module size * This is also a preparation to fix llvm#107387, for which it isn't obvious if we need these relocations at the time of createSyntheticSymbols. (unless we introduce a new explicit option like --non-pie-dynamic-link.)
this has not been fixed yet. can you reopen? |
The commit 22b7b84 made the symbols provided by shared libraries "defined", and thus effectively made it impossible to generate non-pie dynamically linked executables using --unresolved-symbols=import-dynamic. This commit, based on llvm#109249, fixes it by checking sym->isShared() explictly. (as a bonus, you don't need to rely on --unresolved-symbols=import-dynamic anymore.) Fixes llvm#107387
…tion (#109249) Instead of always generating __wasm_apply_data_relocs when relevant options like -pie and -shared are specified, generate it only when the relevant relocations are actually necessary. Note: omitting empty __wasm_apply_data_relocs is not a problem because the export is optional in the spec (DynamicLinking.md) and all runtime linker implementations I'm aware of implement it that way. (emscripten, toywasm, wasm-tools) Motivations: * This possibly reduces the module size * This is also a preparation to fix llvm/llvm-project#107387, for which it isn't obvious if we need these relocations at the time of createSyntheticSymbols. (unless we introduce a new explicit option like --non-pie-dynamic-link.)
…tion (llvm#109249) Instead of always generating __wasm_apply_data_relocs when relevant options like -pie and -shared are specified, generate it only when the relevant relocations are actually necessary. Note: omitting empty __wasm_apply_data_relocs is not a problem because the export is optional in the spec (DynamicLinking.md) and all runtime linker implementations I'm aware of implement it that way. (emscripten, toywasm, wasm-tools) Motivations: * This possibly reduces the module size * This is also a preparation to fix llvm#107387, for which it isn't obvious if we need these relocations at the time of createSyntheticSymbols. (unless we introduce a new explicit option like --non-pie-dynamic-link.)
The commit 22b7b84 made the symbols provided by shared libraries "defined", and thus effectively made it impossible to generate non-pie dynamically linked executables using --unresolved-symbols=import-dynamic. This commit, based on #109249, fixes it by checking sym->isShared() explictly. (as a bonus, you don't need to rely on --unresolved-symbols=import-dynamic anymore.) Fixes #107387
…(#108146) The commit 22b7b84 made the symbols provided by shared libraries "defined", and thus effectively made it impossible to generate non-pie dynamically linked executables using --unresolved-symbols=import-dynamic. This commit, based on llvm/llvm-project#109249, fixes it by checking sym->isShared() explictly. (as a bonus, you don't need to rely on --unresolved-symbols=import-dynamic anymore.) Fixes llvm/llvm-project#107387
build the following test code as a non-pie dynamically-linked executable.
llvm 19 produces non-working binary.
llvm 18 worked fine.
you can find the full test code and compiler/linker options in https://github.com/yamt/garbage/tree/master/c/shlib_2
note that llvm 19's __wasm_apply_data_relocs is empty.
llvm 19.1.0-rc4
llvm 18.1.2
The text was updated successfully, but these errors were encountered: