From be9e3e88e49ff7daee0b5e10c2b6f906fd8a3eac Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Sat, 4 Nov 2017 15:28:19 -0700 Subject: [PATCH] Emit wasm data initializers as faerie data segments. This is a temporary measure while other parts of the system are being developed, and will need to be replaced by a proper solution. --- src/wasm2obj.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/wasm2obj.rs b/src/wasm2obj.rs index be016413b4..d629140f81 100644 --- a/src/wasm2obj.rs +++ b/src/wasm2obj.rs @@ -97,6 +97,12 @@ fn handle_module(path: PathBuf, output: &str) -> Result<(), String> { let mut obj = Artifact::new(faerie_target(&*isa)?, Some(String::from(output))); + // FIXME: We need to initialize memory in a way that supports alternate + // memory spaces, imported base addresses, and offsets. + for &(_mem_index, _base, _offset, data) in &environ.lazy.data_initializers { + obj.add_data("memory", Vec::from(data)); + } + let translation = environ.finish_translation(); let (compilation, relocations) = translation.compile(&*isa)?; @@ -110,14 +116,6 @@ fn handle_module(path: PathBuf, output: &str) -> Result<(), String> { return Err(String::from("FIXME: implement tables")); } - if !compilation.module.memories.is_empty() { - if compilation.module.memories.len() > 1 { - return Err(String::from("multiple memories not supported yet")); - } - //obj.add_data("memory", initializer); - return Err(String::from("FIXME: implement data initializers")); - } - // FIXME: Make the format a parameter. let file = ::std::fs::File::create(Path::new(output)).map_err(|x| { format(format_args!("{}", x))