summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/binary-reader.cc9
-rw-r--r--src/binary-writer.cc22
-rw-r--r--src/binary.h4
3 files changed, 19 insertions, 16 deletions
diff --git a/src/binary-reader.cc b/src/binary-reader.cc
index c3f70e12..6d309172 100644
--- a/src/binary-reader.cc
+++ b/src/binary-reader.cc
@@ -1722,9 +1722,6 @@ Result BinaryReader::ReadCustomSection(Offset section_size) {
CHECK_RESULT(ReadRelocSection(section_size));
} else if (section_name == WABT_BINARY_SECTION_LINKING) {
CHECK_RESULT(ReadLinkingSection(section_size));
- } else if (options_.features.exceptions_enabled() &&
- section_name == WABT_BINARY_SECTION_EXCEPTION) {
- CHECK_RESULT(ReadExceptionSection(section_size));
} else {
// This is an unknown custom section, skip it.
state_.offset = read_end_;
@@ -2196,6 +2193,12 @@ Result BinaryReader::ReadSections() {
section_result = ReadDataSection(section_size);
result |= section_result;
break;
+ case BinarySection::Event:
+ ERROR_UNLESS(options_.features.exceptions_enabled(),
+ "invalid section code: %u", section);
+ section_result = ReadExceptionSection(section_size);
+ result |= section_result;
+ break;
case BinarySection::DataCount:
ERROR_UNLESS(options_.features.bulk_memory_enabled(),
"invalid section code: %u", section);
diff --git a/src/binary-writer.cc b/src/binary-writer.cc
index 62e77bac..00f491b8 100644
--- a/src/binary-writer.cc
+++ b/src/binary-writer.cc
@@ -900,6 +900,17 @@ Result BinaryWriter::WriteModule() {
EndSection();
}
+ assert(module_->excepts.size() >= module_->num_except_imports);
+ Index num_exceptions = module_->excepts.size() - module_->num_except_imports;
+ if (num_exceptions) {
+ BeginKnownSection(BinarySection::Event);
+ WriteU32Leb128(stream_, num_exceptions, "exception count");
+ for (Index i = module_->num_except_imports; i < num_exceptions; ++i) {
+ WriteExceptType(&module_->excepts[i]->sig);
+ }
+ EndSection();
+ }
+
if (module_->exports.size()) {
BeginKnownSection(BinarySection::Export);
WriteU32Leb128(stream_, module_->exports.size(), "num exports");
@@ -970,17 +981,6 @@ Result BinaryWriter::WriteModule() {
EndSection();
}
- assert(module_->excepts.size() >= module_->num_except_imports);
- Index num_exceptions = module_->excepts.size() - module_->num_except_imports;
- if (num_exceptions) {
- BeginCustomSection("exception");
- WriteU32Leb128(stream_, num_exceptions, "exception count");
- for (Index i = module_->num_except_imports; i < num_exceptions; ++i) {
- WriteExceptType(&module_->excepts[i]->sig);
- }
- EndSection();
- }
-
if (options_.features.bulk_memory_enabled()) {
BeginKnownSection(BinarySection::DataCount);
WriteU32Leb128(stream_, module_->data_segments.size(), "data count");
diff --git a/src/binary.h b/src/binary.h
index 747c28e2..7302a8ad 100644
--- a/src/binary.h
+++ b/src/binary.h
@@ -27,7 +27,6 @@
#define WABT_BINARY_SECTION_NAME "name"
#define WABT_BINARY_SECTION_RELOC "reloc"
#define WABT_BINARY_SECTION_LINKING "linking"
-#define WABT_BINARY_SECTION_EXCEPTION "exception"
#define WABT_BINARY_SECTION_DYLINK "dylink"
#define WABT_FOREACH_BINARY_SECTION(V) \
@@ -38,6 +37,7 @@
V(Table, table, 4) \
V(Memory, memory, 5) \
V(Global, global, 6) \
+ V(Event, event, 13) \
V(Export, export, 7) \
V(Start, start, 8) \
V(Elem, elem, 9) \
@@ -55,7 +55,7 @@ enum class BinarySection {
Invalid = ~0,
First = Custom,
- Last = DataCount,
+ Last = Event,
};
/* clang-format on */
static const int kBinarySectionCount = WABT_ENUM_COUNT(BinarySection);