read what the binary says about itself: names, signatures, prototypes; gen v2
This commit is contained in:
parent
54ef572202
commit
c458b4cb50
34 changed files with 58363 additions and 192 deletions
19
src/elf.rs
19
src/elf.rs
|
|
@ -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> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue