Skip to content

Commit

Permalink
Only allow instantiating from a deserialized file for staticlib engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Nov 23, 2021
1 parent cb88b6d commit 4f65a56
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/engine-staticlib/src/artifact.rs
Expand Up @@ -46,6 +46,7 @@ pub struct StaticlibArtifact {
/// Length of the serialized metadata
metadata_length: usize,
symbol_registry: ModuleMetadataSymbolRegistry,
is_compiled: bool,
}

#[allow(dead_code)]
Expand Down Expand Up @@ -295,6 +296,7 @@ impl StaticlibArtifact {
func_data_registry: engine_inner.func_data().clone(),
metadata_length,
symbol_registry,
is_compiled: true,
})
}

Expand Down Expand Up @@ -415,6 +417,7 @@ impl StaticlibArtifact {
func_data_registry,
metadata_length: 0,
symbol_registry,
is_compiled: false,
})
}

Expand Down Expand Up @@ -483,6 +486,12 @@ impl Artifact for StaticlibArtifact {
}

fn preinstantiate(&self) -> Result<(), InstantiationError> {
if self.is_compiled {
panic!(
"a module built with the staticlib engine must be linked \
into the current executable"
);
}
Ok(())
}

Expand Down

0 comments on commit 4f65a56

Please sign in to comment.