mirror of
https://codeberg.org/unspeaker/vestal.git
synced 2025-12-06 08:36:41 +01:00
prepare for relocation
This commit is contained in:
parent
8726b94122
commit
830e75db19
2 changed files with 15 additions and 10 deletions
|
|
@ -163,17 +163,8 @@ impl Module {
|
||||||
let mut layout: BTreeMap<usize, Arc<Self>> = Default::default();
|
let mut layout: BTreeMap<usize, Arc<Self>> = Default::default();
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
let mut append = |module: &Arc<Self>|{
|
let mut append = |module: &Arc<Self>|{
|
||||||
println!("{} [+{}] {:16}",
|
|
||||||
fmt_num(index),
|
|
||||||
fmt_num(module.code_size),
|
|
||||||
module.name);
|
|
||||||
layout.insert(index, self.clone());
|
layout.insert(index, self.clone());
|
||||||
index += module.code_size.div_ceil(page) * page;
|
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);
|
append(&self);
|
||||||
for module in self.namespace.read().unwrap().values() {
|
for module in self.namespace.read().unwrap().values() {
|
||||||
|
|
@ -182,6 +173,20 @@ impl Module {
|
||||||
}
|
}
|
||||||
append(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];
|
let mut output = vec![0x90;size];
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,7 @@ impl CallSite {
|
||||||
let label = self.caller.imports.read().unwrap().get(&self.target)
|
let label = self.caller.imports.read().unwrap().get(&self.target)
|
||||||
.map(|(module, method)|format!("{GREEN}{module}::{method}{RESET}"))
|
.map(|(module, method)|format!("{GREEN}{module}::{method}{RESET}"))
|
||||||
.unwrap_or_else(||format!("{RED}unresolved{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,
|
&self.caller.name,
|
||||||
fmt_num(self.offset as usize),
|
fmt_num(self.offset as usize),
|
||||||
fmt_num(self.source as usize),
|
fmt_num(self.source as usize),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue