read what the binary says about itself: names, signatures, prototypes; gen v2
All checks were successful
CI / lint (push) Successful in 17s
CI / fuzz (push) Successful in 1m52s
CI / test (push) Successful in 24s

This commit is contained in:
Kamal Tufekcic 2026-07-29 20:09:21 +03:00
commit c458b4cb50
34 changed files with 58363 additions and 192 deletions

View file

@ -325,6 +325,25 @@ impl CodeImage {
.collect()
}
/// Allocated, initialised, WRITABLE data sections as `(vaddr, byte_len)` — `.data` and
/// `.data.rel.ro`, where a module's static tables live. Returned as ranges rather than slices so
/// callers keep reading through [`read_ptr`](Self::read_ptr) and get the relocated pointer values
/// (a table of function pointers is relocation-driven; its raw file bytes are only incidentally
/// correct).
pub fn data_blocks(&self) -> Vec<(u64, usize)> {
self.secs
.iter()
.filter(|s| {
s.flags & SHF_ALLOC != 0
&& s.flags & SHF_WRITE != 0
&& s.flags & SHF_EXECINSTR == 0
&& s.typ != SHT_NOBITS
&& s.off + s.size <= self.data.len()
})
.map(|s| (s.addr, s.size))
.collect()
}
/// Relocation values that point into executable code — vtable slots and function pointers, i.e.
/// a large set of real function entry addresses obtained without disassembling anything.
pub fn code_pointer_targets(&self) -> Vec<u64> {