From 248e06146a3c73b457e539da3cc858961ac94a46 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Fri, 20 Mar 2020 11:27:23 -0700 Subject: [PATCH 1/2] Support multiple custom sections with the same name --- lib/runtime-core/src/module.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/runtime-core/src/module.rs b/lib/runtime-core/src/module.rs index e7af6a7daec..5814d9ff87e 100644 --- a/lib/runtime-core/src/module.rs +++ b/lib/runtime-core/src/module.rs @@ -78,7 +78,7 @@ pub struct ModuleInfo { pub em_symbol_map: Option>, /// Custom sections. - pub custom_sections: HashMap>, + pub custom_sections: HashMap>>, /// Flag controlling whether or not debug information for use in a debugger /// will be generated. @@ -102,7 +102,8 @@ impl ModuleInfo { let bytes = reader.read_bytes(len)?; let data = bytes.to_vec(); let name = name.to_string(); - self.custom_sections.insert(name, data); + let entry: &mut Vec> = self.custom_sections.entry(name).or_default(); + entry.push(data); } } Ok(()) From df1afa2cdc8531a6d69f3b0ed22d2115ec4c3e4e Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Fri, 20 Mar 2020 17:14:30 -0700 Subject: [PATCH 2/2] Add custom section update to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8209933db42..581789f4f53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## **[Unreleased]** +- [#1320](https://github.com/wasmerio/wasmer/pull/1320) Change `custom_sections` field in `ModuleInfo` to be more standards compliant by allowing multiple custom sections with the same name. To get the old behavior with the new API, you can add `.last().unwrap()` to accesses. For example, `module_info.custom_sections["custom_section_name"].last().unwrap()`. - [#1303](https://github.com/wasmerio/wasmer/pull/1303) NaN canonicalization for singlepass backend. - [#1305](https://github.com/wasmerio/wasmer/pull/1305) Handle panics from DynamicFunc. - [#1301](https://github.com/wasmerio/wasmer/pull/1301) Update supported stable Rust version to 1.41.1.