summaryrefslogtreecommitdiff
path: root/src/binary-writer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/binary-writer.cc')
-rw-r--r--src/binary-writer.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/binary-writer.cc b/src/binary-writer.cc
index 92a39ea3..19443a44 100644
--- a/src/binary-writer.cc
+++ b/src/binary-writer.cc
@@ -1670,6 +1670,23 @@ Result BinaryWriter::WriteModule() {
EndSection();
}
+ for (const Custom& custom : module_->customs) {
+ // These custom sections are already specially handled by BinaryWriter, so
+ // we don't want to double-write.
+ if ((custom.name == WABT_BINARY_SECTION_NAME &&
+ options_.write_debug_names) ||
+ (custom.name.rfind(WABT_BINARY_SECTION_RELOC) == 0 &&
+ options_.relocatable) ||
+ (custom.name == WABT_BINARY_SECTION_LINKING && options_.relocatable) ||
+ (custom.name.find(WABT_BINARY_SECTION_CODE_METADATA) == 0 &&
+ options_.features.code_metadata_enabled())) {
+ continue;
+ }
+ BeginCustomSection(custom.name.data());
+ stream_->WriteData(custom.data, "custom data");
+ EndSection();
+ }
+
if (options_.write_debug_names) {
std::vector<std::string> index_to_name;