diff --git a/lib/compiler/src/lib.rs b/lib/compiler/src/lib.rs index 7b5ed1c13..432df3633 100644 --- a/lib/compiler/src/lib.rs +++ b/lib/compiler/src/lib.rs @@ -64,7 +64,7 @@ pub use crate::function::{ }; pub use crate::jump_table::{JumpTable, JumpTableOffsets}; pub use crate::relocation::{Relocation, RelocationKind, RelocationTarget, Relocations}; -pub use crate::section::{CustomSection, CustomSectionProtection, SectionIndex}; +pub use crate::section::{CustomSection, CustomSectionProtection, SectionBody, SectionIndex}; pub use crate::sourceloc::SourceLoc; pub use crate::translator::{ to_wasm_error, translate_module, FunctionBodyData, ModuleEnvironment, ModuleTranslation, diff --git a/lib/compiler/src/section.rs b/lib/compiler/src/section.rs index 0908f1b90..9794e6123 100644 --- a/lib/compiler/src/section.rs +++ b/lib/compiler/src/section.rs @@ -41,6 +41,9 @@ pub struct CustomSection { /// > (the start of the memory pointer). /// > We might need to create another field for alignment in case it's /// > needed in the future. - #[serde(with = "serde_bytes")] - pub bytes: Vec, + pub bytes: SectionBody, } + +/// The bytes in the section. +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +pub struct SectionBody(#[serde(with = "serde_bytes")] Vec); diff --git a/lib/jit/src/module.rs b/lib/jit/src/module.rs index 655980303..a1156577e 100644 --- a/lib/jit/src/module.rs +++ b/lib/jit/src/module.rs @@ -89,6 +89,7 @@ impl CompiledModule { function_relocations: compilation.get_relocations(), function_jt_offsets: compilation.get_jt_offsets(), function_frame_info: frame_infos, + custom_sections: PrimaryMap::new(), }; let serializable = SerializableModule { compilation: serializable_compilation, diff --git a/lib/jit/src/serialize.rs b/lib/jit/src/serialize.rs index 835775c47..c07bbe1ae 100644 --- a/lib/jit/src/serialize.rs +++ b/lib/jit/src/serialize.rs @@ -3,7 +3,10 @@ use serde::ser::Serializer; use serde::{Deserialize, Serialize}; use std::fmt; use std::sync::Arc; -use wasmer_compiler::{CompiledFunctionFrameInfo, FunctionBody, JumpTableOffsets, Relocation}; +use wasmer_compiler::{ + CompiledFunctionFrameInfo, FunctionBody, JumpTableOffsets, Relocation, SectionBody, + SectionIndex, +}; use wasmer_runtime::Module; use wasm_common::entity::PrimaryMap; @@ -20,6 +23,7 @@ pub struct SerializableCompilation { // to allow lazy frame_info deserialization, we convert it to it's lazy binary // format upon serialization. pub function_frame_info: PrimaryMap, + pub custom_sections: PrimaryMap, } /// Serializable struct that is able to serialize from and to