summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKarlSchimpf <karlschimpf@gmail.com>2017-07-05 11:57:18 -0700
committerGitHub <noreply@github.com>2017-07-05 11:57:18 -0700
commit2cb1e81a3e53f3481fdb789fe09df59042391e67 (patch)
tree18717cc06d67802cdf4b5ec1542bc01acdc9a195 /src
parent0551c78694ec7ffd5276d6dfce73e3ff3f7fc59d (diff)
downloadwabt-2cb1e81a3e53f3481fdb789fe09df59042391e67.tar.gz
wabt-2cb1e81a3e53f3481fdb789fe09df59042391e67.tar.bz2
wabt-2cb1e81a3e53f3481fdb789fe09df59042391e67.zip
Move exception section to just before code section. (#552)
Diffstat (limited to 'src')
-rw-r--r--src/binary-writer.cc21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/binary-writer.cc b/src/binary-writer.cc
index eb95af36..b0aa9bbf 100644
--- a/src/binary-writer.cc
+++ b/src/binary-writer.cc
@@ -916,6 +916,17 @@ Result BinaryWriter::WriteModule(const Module* module) {
EndSection();
}
+ assert(module->excepts.size() >= module->num_except_imports);
+ Index num_exceptions = module->excepts.size() - module->num_except_imports;
+ if (num_exceptions) {
+ BeginCustomSection("exception", LEB_SECTION_SIZE_GUESS);
+ write_u32_leb128(&stream_, num_exceptions, "exception count");
+ for (Index i = module->num_except_imports; i < num_exceptions; ++i) {
+ WriteExceptType(&module->excepts[i]->sig);
+ }
+ EndSection();
+ }
+
if (num_funcs) {
BeginKnownSection(BinarySection::Code, LEB_SECTION_SIZE_GUESS);
write_u32_leb128(&stream_, num_funcs, "num functions");
@@ -1021,16 +1032,6 @@ Result BinaryWriter::WriteModule(const Module* module) {
}
}
- assert(module->excepts.size() >= module->num_except_imports);
- Index num_exceptions = module->excepts.size() - module->num_except_imports;
- if (num_exceptions) {
- BeginCustomSection("exception", LEB_SECTION_SIZE_GUESS);
- write_u32_leb128(&stream_, num_exceptions, "exception count");
- for (Index i = module->num_except_imports; i < num_exceptions; ++i) {
- WriteExceptType(&module->excepts[i]->sig);
- }
- EndSection();
- }
return stream_.result();
}