propose output layout

This commit is contained in:
🪞👃🪞 2025-02-24 01:00:59 +02:00
parent 88a5f28f9e
commit 8f7faca54a

View file

@ -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<Self>) -> Usually<Arc<Self>> {
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<usize, Arc<Self>> = Default::default();
let mut index = 0;
let mut append = |module: &Arc<Self>|{
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<Path>) -> Arc<str> {