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

"Couldn't read header of a name subsection" when loading wasm-file #403

Closed
lwagner94 opened this issue Nov 30, 2021 · 1 comment
Closed

Comments

@lwagner94
Copy link
Contributor

Hey there,

I'm trying to load the attached simple_add_c.zip (zipped, because github won't allow me to attach wasm-files) .wasm file, but I'm getting the following error:
Error: Couldn't read header of a name subsection

This is how I attempt to load the file:

    let wasm = std::fs::read(&args[1])?;
    let obj_file = object::File::parse(wasm.as_slice())?;

Is this a bug or am I doing something wrong here?

wasm-objdump gives me the following output:

...
imple_add_c.wasm:	file format wasm 0x1

Contents of section Type:
000000a: 0460 017f 0060 0000 6002 7f7f 017f 6000  .`...`..`.....`.
000001a: 017f                                     ..

Contents of section Import:
000001e: 0116 7761 7369 5f73 6e61 7073 686f 745f  ..wasi_snapshot_
000002e: 7072 6576 6965 7731 0970 726f 635f 6578  preview1.proc_ex
000003e: 6974 0000                                it..

Contents of section Function:
0000044: 0901 0203 0001 0100 0102                 ..........

Contents of section Table:
0000050: 0170 0101 01                             .p...

Contents of section Memory:
0000057: 0100 02                                  ...

Contents of section Global:
000005c: 017f 0141 8088 040b                      ...A....

Contents of section Export:
0000066: 0306 6d65 6d6f 7279 0200 065f 7374 6172  ..memory..._star
0000076: 7400 0803 6164 6400 09                   t...add..

Contents of section Code:
0000081: 091b 0101 7f02 4010 8380 8080 0022 0045  ......@......".E
0000091: 0d00 2000 1087 8080 8000 000b 0b07 0020  .. ............ 
00000a1: 0120 006a 0b04 0041 030b 0b00 2000 1080  . .j...A.... ...
00000b1: 8080 8000 000b 0200 0b0e 0010 8580 8080  ................
00000c1: 0010 8580 8080 000b 1700 1085 8080 8000  ................
00000d1: 1085 8080 8000 2000 1084 8080 8000 000b  ...... .........
00000e1: 0600 1001 1006 0b0a 0020 0020 0110 0210  ......... . ....
00000f1: 060b                                     ..

Contents of section Custom:
00000f6: 046e 616d 6501 8301 0a00 105f 5f77 6173  .name......__was
0000106: 695f 7072 6f63 5f65 7869 7401 065f 7374  i_proc_exit.._st
0000116: 6172 7402 0361 6464 030f 5f5f 6f72 6967  art..add..__orig
0000126: 696e 616c 5f6d 6169 6e04 055f 4578 6974  inal_main.._Exit
0000136: 0505 6475 6d6d 7906 115f 5f77 6173 6d5f  ..dummy..__wasm_
0000146: 6361 6c6c 5f64 746f 7273 0704 6578 6974  call_dtors..exit
0000156: 0815 5f73 7461 7274 2e63 6f6d 6d61 6e64  .._start.command
0000166: 5f65 7870 6f72 7409 1261 6464 2e63 6f6d  _export..add.com
0000176: 6d61 6e64 5f65 7870 6f72 7407 1201 000f  mand_export.....
0000186: 5f5f 7374 6163 6b5f 706f 696e 7465 72    __stack_pointer

Contents of section Custom:
0000197: 0970 726f 6475 6365 7273 010c 7072 6f63  .producers..proc
00001a7: 6573 7365 642d 6279 0105 636c 616e 6756  essed-by..clangV
00001b7: 3131 2e30 2e30 2028 6874 7470 733a 2f2f  11.0.0 (https://
00001c7: 6769 7468 7562 2e63 6f6d 2f6c 6c76 6d2f  github.com/llvm/
00001d7: 6c6c 766d 2d70 726f 6a65 6374 2031 3736  llvm-project 176
00001e7: 3234 3962 6436 3733 3261 3830 3434 6434  249bd6732a8044d4
00001f7: 3537 3039 3265 6439 3332 3736 3837 3234  57092ed932768724
0000207: 6136 6630 3629 
@philipc
Copy link
Contributor

philipc commented Nov 30, 2021

Probably the wasm format has changed, and the wasmparser dependency needs updating. The wasm support in this crate is unmaintained, so PRs to update it are welcome.

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

2 participants