Stream: wasm

Topic: Custom sections in binary format


view this post on Zulip Mariano Guerra (Aug 18 2023 at 14:16):

hi! not sure if this is the right place to ask about the standard, let me know if I should ask somewhere else.

in https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#custom-section%E2%91%A0 it says:

Custom sections have the id 0. They are intended to be used for debugging information or third-party extensions, and are ignored by the WebAssembly semantics. Their contents consist of a name further identifying the custom section, followed by an uninterpreted sequence of bytes for custom use.

Then the structure of the section's format:

custom ::= name  byte*

this means the parsers have to know about the custom sections to know how many bytes to skip in byte*?

this means only known and specified custom sections can be added?

view this post on Zulip Joel Dice (Aug 18 2023 at 14:25):

From https://webassembly.github.io/spec/core/binary/modules.html#sections:

Each section consists of
- a one-byte section id,
- the size of the contents, in bytes,
- the actual contents, whose structure is dependent on the section id.

view this post on Zulip Lann Martin (Aug 18 2023 at 14:26):

^ i.e. you can always skip any section for basic parsing purposes, without knowing anything about its contents

view this post on Zulip Joel Dice (Aug 18 2023 at 14:27):

or you could print the name of any unrecognized custom section for diagnostic purposes and still skip over the bytes based on the overall section size

view this post on Zulip Mariano Guerra (Aug 18 2023 at 14:29):

:man_facepalming: forgot that the length of the section is specified for all sections


Last updated: Nov 22 2024 at 16:03 UTC