Support multiple custom sections with the same name

This commit is contained in:
Mark McCaskey
2020-03-20 11:27:23 -07:00
parent 04754aa223
commit 248e06146a

View File

@ -78,7 +78,7 @@ pub struct ModuleInfo {
pub em_symbol_map: Option<HashMap<u32, String>>,
/// Custom sections.
pub custom_sections: HashMap<String, Vec<u8>>,
pub custom_sections: HashMap<String, Vec<Vec<u8>>>,
/// 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<Vec<u8>> = self.custom_sections.entry(name).or_default();
entry.push(data);
}
}
Ok(())