From 830e75db19672fbf1802f424837299c0f1ac9e54 Mon Sep 17 00:00:00 2001 From: unspeaker Date: Mon, 24 Feb 2025 01:28:16 +0200 Subject: [PATCH] prepare for relocation --- crates/vestal/src/main.rs | 23 ++++++++++++++--------- crates/vestal/src/show.rs | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/crates/vestal/src/main.rs b/crates/vestal/src/main.rs index dca5fe9..6f2f451 100644 --- a/crates/vestal/src/main.rs +++ b/crates/vestal/src/main.rs @@ -163,17 +163,8 @@ impl Module { 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; - for (addr, call) in module.call_sites.read().unwrap().iter() { - println!(" {} {:?}::{:?}", fmt_num(*addr as usize), - call.module.as_ref().map(|m|m.name.clone()), - call.method); - } }; append(&self); for module in self.namespace.read().unwrap().values() { @@ -182,6 +173,20 @@ impl Module { } append(module); } + for (address, module) in layout.iter() { + println!("{BOLD}{}-{} {:16}{RESET}", + fmt_num(index), + fmt_num(index + module.code_size), + module.name); + for (addr, call) in module.call_sites.read().unwrap().iter() { + let addr = *addr as usize; + println!("{} {DIM}{} ╰->{RESET} {}::{}", + fmt_num(index + addr), + fmt_num(addr), + call.module.as_ref().map(|m|m.name.clone()).unwrap_or("???".into()), + call.method.as_ref().map(|m|m.clone()).unwrap_or("???".into())); + } + } let mut output = vec![0x90;size]; Ok(self) } diff --git a/crates/vestal/src/show.rs b/crates/vestal/src/show.rs index 6d56c23..5165093 100644 --- a/crates/vestal/src/show.rs +++ b/crates/vestal/src/show.rs @@ -190,7 +190,7 @@ impl CallSite { let label = self.caller.imports.read().unwrap().get(&self.target) .map(|(module, method)|format!("{GREEN}{module}::{method}{RESET}")) .unwrap_or_else(||format!("{RED}unresolved{RESET}")); - println!(" ╰-> (call {:15} {} {} {DIM}{:20}{RESET} {} {BOLD}{}{RESET})", + println!(" {DIM}╰->{RESET} (call {:15} {} {} {DIM}{:20}{RESET} {} {BOLD}{}{RESET})", &self.caller.name, fmt_num(self.offset as usize), fmt_num(self.source as usize),