Skip to content

Commit 67d9fd3

Browse files
committed
Added support for DataCount section in module loading
1 parent d434bf0 commit 67d9fd3

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

WebAssembly/Module.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,12 @@ public static Module ReadFromBinary(Stream input)
348348
}
349349
break;
350350

351+
case Section.DataCount: //Optional section, indicates the expected length of the data segment vector
352+
{
353+
reader.ReadUInt32();
354+
}
355+
break;
356+
351357
default:
352358
throw new ModuleLoadException($"Unrecognized section type {id}.", preSectionOffset);
353359
}

WebAssembly/Section.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace WebAssembly;
1+
using System;
2+
3+
namespace WebAssembly;
24

35
/// <summary>
46
/// The standard section identifiers.
@@ -52,10 +54,14 @@ public enum Section : byte
5254
/// <summary>
5355
/// Data segments.
5456
/// </summary>
55-
Data
57+
Data,
58+
/// <summary>
59+
/// Optional segment which indicates the number of sata segments
60+
/// </summary>
61+
DataCount,
5662
}
5763

5864
static class SectionExtensions
5965
{
60-
public static bool IsValid(this Section section) => section <= Section.Data;
66+
public static bool IsValid(this Section section) => section <= Section.DataCount;
6167
}

0 commit comments

Comments
 (0)