add a way to provide imported functions during relocation

They are provided as a closure taking the module (&str) and function name (&str) as arguments,
returning an address (Option<isize>)
This commit is contained in:
Geoffroy Couprie
2018-11-15 16:41:10 +01:00
committed by Dan Gohman
parent d72ebe53d4
commit 7fca0792dd
2 changed files with 30 additions and 12 deletions

View File

@@ -145,8 +145,12 @@ fn handle_module(args: &Args, path: PathBuf, isa: &TargetIsa) -> Result<(), Stri
}
let mut module = Module::new();
let environ = ModuleEnvironment::new(isa, &mut module);
let imports_resolver = |_env: &str, _function: &str| None;
let translation = environ.translate(&data).map_err(|e| e.to_string())?;
let instance = match compile_and_link_module(isa, &translation) {
let instance = match compile_and_link_module(isa, &translation, &imports_resolver) {
Ok(compilation) => {
let mut instance = Instance::new(
translation.module,