Skip to content
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

wasm2wat needed_dynlibs error #1429

Open
syrusakbary opened this issue May 16, 2020 · 6 comments
Open

wasm2wat needed_dynlibs error #1429

syrusakbary opened this issue May 16, 2020 · 6 comments
Assignees

Comments

@syrusakbary
Copy link

syrusakbary commented May 16, 2020

While working on an issue in Wasmer, we realized that wabt was unable to parse/validate a valid Wasm file, failing with a needed_dynlibs error (my local wabt was installed via homebrew).

$ wasm2wat lib/c-api/tests/assets/hello_wasm.wasm
0000018: error: unable to read u32 leb128: needed_dynlibs
$ wasm-validate lib/c-api/tests/assets/hello_wasm.wasm
0000018: error: unable to read u32 leb128: needed_dynlibs

The hello_wasm.wasm file seem to be valid according to other validators, so we have no insight of what might be causing the parsing/validating error.

For debugging: the wasm file was generated using rustc with wasm32-unknown-unknown target for this source:
https://github.com/wasmerio/wasmer/blob/master/lib/runtime-c-api/tests/assets/return_hello.rs

@binji
Copy link
Member

binji commented May 18, 2020

Looks like it is trying to read the dylink custom section, and erroring out because it's missing that field. @sbc100 looks like you added this, do you know what may be happening?

@sbc100
Copy link
Member

sbc100 commented May 18, 2020

Thanks, I'll take a look.

@sbc100 sbc100 self-assigned this May 18, 2020
@sbc100
Copy link
Member

sbc100 commented May 18, 2020

Hmm, what version of llvm was used to compile that file? It looks like that I added the extrea leb to that section back in https://reviews.llvm.org/D55613, which I think means it was in llvm 8 and above.

My guess is that other validators ignore this section completely, and I guess maybe(?) wasm-validate should too?

@sbc100
Copy link
Member

sbc100 commented May 18, 2020

Also, I don't think wasm32-unknown-unknown should be producing dynamic libraries should it? Does it even support the -shared flag?

@syrusakbary
Copy link
Author

syrusakbary commented May 19, 2020

Hmm, what version of llvm was used to compile that file?

Unfortunately we don't have the script that we used to generate the file, so we can't know for sure. It could be that was the rustc version we were using was using llvm-7?

@sbc100
Copy link
Member

sbc100 commented May 19, 2020

Yes I think wasm-ld from llvm 7 would produce such a dylink section, but even then only if linked as a shared library with -shared or -pie I believe.

Either way we should re-visit how we validate this custom section.

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

No branches or pull requests

3 participants