Files
wasmtime/wasmtime-obj/src/data_segment.rs
Dan Gohman 8e1b44b29c Make more code work with no_std. (#407)
* Make more code work with no_std.

no_std support is still incomplete, but this patch takes care of the
bulk of the straightforward parts.
2019-10-08 16:53:32 -07:00

29 lines
771 B
Rust

use alloc::string::String;
use alloc::vec::Vec;
use faerie::{Artifact, Decl};
use wasmtime_environ::DataInitializer;
/// Declares data segment symbol
pub fn declare_data_segment(
obj: &mut Artifact,
_data_initaliazer: &DataInitializer,
index: usize,
) -> Result<(), String> {
let name = format!("_memory_{}", index);
obj.declare(name, Decl::data())
.map_err(|err| format!("{}", err))?;
Ok(())
}
/// Emit segment data and initialization location
pub fn emit_data_segment(
obj: &mut Artifact,
data_initaliazer: &DataInitializer,
index: usize,
) -> Result<(), String> {
let name = format!("_memory_{}", index);
obj.define(name, Vec::from(data_initaliazer.data))
.map_err(|err| format!("{}", err))?;
Ok(())
}