From e3375281d46fe39cc1f37a4cd02cc524d3c8fdc6 Mon Sep 17 00:00:00 2001 From: Luke Wagner Date: Sun, 13 Mar 2016 19:35:42 -0500 Subject: No validation errors after the End --- BinaryEncoding.md | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'BinaryEncoding.md') diff --git a/BinaryEncoding.md b/BinaryEncoding.md index cac7fef..d588585 100644 --- a/BinaryEncoding.md +++ b/BinaryEncoding.md @@ -89,10 +89,9 @@ for all sections. The encoding of all sections begins as follows: | id_len | `varuint32` | section identifier string length | | id_str | `bytes` | section identifier string of id_len bytes | -Each section other than the End section is optional and may appear at most once. -The End section must appear exactly once. If present, sections must occur in -this precise order (interleaved or followed by unknown sections, as noted -above): +Each section other than the End section is optional and may appear at most once +and only in the precise order defined below (out-of-order sections are a +validation error). * [Signatures](#signatures-section) section * [Import Table](#import-table-section) section @@ -106,12 +105,13 @@ above): * [End](#end-section) section * [Names](#names-section) section -Thus, the shortest valid module is 13 bytes (`magic number`, `version`, -`size` = 4, `id_len` = 3, `id_str` = "end"). +The End section must appear exactly once and is the last section that affects +execution, including whether the module validates. Any validation error after +the End section causes the containing section and all subsequent bytes to be +ignored. -Additionally, known sections (from the above list) may not appear out of order -and the end of the last present section must coincide with the last byte of the -module. +The shortest valid module is thus 13 bytes: `magic number`, `version`, +`size` = `4`, `id_len` = `3`, `id_str` = `end`. ### Signatures section @@ -264,12 +264,9 @@ affecting execution. ID: `names` -The names section does not change execution semantics and a validation error in -this section does not cause validation for the whole module to fail and is -instead treated as if the section was absent. The expectation is that, when a -binary WebAssembly module is viewed in a browser or other development -environment, the names in this section will be used as the names of functions -and locals in the [text format](TextFormat.md). +When a binary WebAssembly module is viewed in a browser or other development +environment, the names in this section, when present, are used as the names of +functions and locals in the [text format](TextFormat.md). | Field | Type | Description | | ----- | ----- | ----- | -- cgit v1.2.3