From 67d9fd3f073401a59d3a97b3db82178f25c3ca75 Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Sun, 25 May 2025 00:24:11 +0100 Subject: [PATCH] Added support for `DataCount` section in module loading --- WebAssembly/Module.cs | 6 ++++++ WebAssembly/Section.cs | 12 +++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/WebAssembly/Module.cs b/WebAssembly/Module.cs index 7e679936..6d5509da 100644 --- a/WebAssembly/Module.cs +++ b/WebAssembly/Module.cs @@ -348,6 +348,12 @@ public static Module ReadFromBinary(Stream input) } break; + case Section.DataCount: //Optional section, indicates the expected length of the data segment vector + { + reader.ReadUInt32(); + } + break; + default: throw new ModuleLoadException($"Unrecognized section type {id}.", preSectionOffset); } diff --git a/WebAssembly/Section.cs b/WebAssembly/Section.cs index f34f877a..47ecd01c 100644 --- a/WebAssembly/Section.cs +++ b/WebAssembly/Section.cs @@ -1,4 +1,6 @@ -namespace WebAssembly; +using System; + +namespace WebAssembly; /// /// The standard section identifiers. @@ -52,10 +54,14 @@ public enum Section : byte /// /// Data segments. /// - Data + Data, + /// + /// Optional segment which indicates the number of sata segments + /// + DataCount, } static class SectionExtensions { - public static bool IsValid(this Section section) => section <= Section.Data; + public static bool IsValid(this Section section) => section <= Section.DataCount; }