Skip to content

Error: Unused bytes in the custom name section #2

Description

@leon-thomm

Compiling the following Rust code

#[no_mangle]
pub extern "C" fn start() {}

to WASM and running with rWasm fails in parser.rs with

Error: 
   0: Unused bytes in the custom name section
  • rustc: 1.71.0, target wasm32-unknown-unknown
  • rWasm: main branch

The generated WASM in WAT:

(module
  (type (;0;) (func))
  (func $start (type 0))
  (table (;0;) 1 1 funcref)
  (memory (;0;) 16)
  (global $__stack_pointer (mut i32) (i32.const 1048576))
  (global (;1;) i32 (i32.const 1048576))
  (global (;2;) i32 (i32.const 1048576))
  (export "memory" (memory 0))
  (export "start" (func $start))
  (export "__data_end" (global 1))
  (export "__heap_base" (global 2)))

wabt-objdump of the WASM binary:

custom.wasm:	file format wasm 0x1

Contents of section Type:
000000a: 0160 0000                                .`..

Contents of section Function:
0000010: 0100                                     ..

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

Contents of section Memory:
000001b: 0100 10                                  ...

Contents of section Global:
0000020: 037f 0141 8080 c000 0b7f 0041 8080 c000  ...A.......A....
0000030: 0b7f 0041 8080 c000 0b                   ...A.....

Contents of section Export:
000003b: 0406 6d65 6d6f 7279 0200 0573 7461 7274  ..memory...start
000004b: 0000 0a5f 5f64 6174 615f 656e 6403 010b  ...__data_end...
000005b: 5f5f 6865 6170 5f62 6173 6503 02         __heap_base..

Contents of section Code:
000006a: 0102 000b                                ....

Contents of section Custom:
0000070: 046e 616d 6501 0801 0005 7374 6172 7407  .name.....start.
0000080: 1201 000f 5f5f 7374 6163 6b5f 706f 696e  ....__stack_poin
0000090: 7465 72                                  ter

Contents of section Custom:
0000095: 0970 726f 6475 6365 7273 0208 6c61 6e67  .producers..lang
00000a5: 7561 6765 0104 5275 7374 000c 7072 6f63  uage..Rust..proc
00000b5: 6573 7365 642d 6279 0105 7275 7374 631d  essed-by..rustc.
00000c5: 312e 3731 2e30 2028 3865 6465 3361 6165  1.71.0 (8ede3aae
00000d5: 3220 3230 3233 2d30 372d 3132 29         2 2023-07-12)

Contents of section Custom:
00000e4: 0f74 6172 6765 745f 6665 6174 7572 6573  .target_features
00000f4: 022b 0f6d 7574 6162 6c65 2d67 6c6f 6261  .+.mutable-globa
0000104: 6c73 2b08 7369 676e 2d65 7874            ls+.sign-ext

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions