diff --git a/crates/vestal/src/main.rs b/crates/vestal/src/main.rs index f329a80..d440168 100644 --- a/crates/vestal/src/main.rs +++ b/crates/vestal/src/main.rs @@ -80,7 +80,8 @@ fn main () -> Usually<()> { .search(canonicalize(path.clone().parent().expect("invalid parent path"))?) .search("/home/user/Lab/Cosmo/wineprefix/drive_c/windows/system32") .load(true)? - .resolve(true)?; + .resolve(true)? + .relink()?; } else { println!("Pass a path to a VST DLL"); } @@ -151,6 +152,34 @@ impl Module { } Ok(module) } + /// Build an ELF executable out of the DLL + fn relink (self: Arc) -> Usually> { + let page = 32*1024; + let mut size = 0; + for module in self.namespace.read().unwrap().values() { + size += module.code_size.div_ceil(page); + } + println!("\n{}", fmt_num(size*page)); + let mut layout: BTreeMap> = Default::default(); + let mut index = 0; + let mut append = |module: &Arc|{ + println!("{} [+{}] {:16}", + fmt_num(index), + fmt_num(module.code_size), + module.name); + layout.insert(index, self.clone()); + index += module.code_size.div_ceil(page) * page; + }; + append(&self); + for module in self.namespace.read().unwrap().values() { + if module.name == self.name { + continue; + } + append(module); + } + let mut output = vec![0x90;size]; + Ok(self) + } } fn to_dll_name (path: &impl AsRef) -> Arc {