findshlibs

Trait Segment

Source
pub trait Segment: Sized + Debug {
    type SharedLibrary: SharedLibrary<Segment = Self>;

    // Required methods
    fn name(&self) -> &str;
    fn stated_virtual_memory_address(&self) -> Svma;
    fn len(&self) -> usize;

    // Provided methods
    fn is_code(&self) -> bool { ... }
    fn is_load(&self) -> bool { ... }
    fn actual_virtual_memory_address(&self, shlib: &Self::SharedLibrary) -> Avma { ... }
    fn contains_svma(&self, address: Svma) -> bool { ... }
    fn contains_avma(&self, shlib: &Self::SharedLibrary, address: Avma) -> bool { ... }
}
Expand description

A mapped segment in a shared library.

Required Associated Types§

Source

type SharedLibrary: SharedLibrary<Segment = Self>

The associated shared library type for this segment.

Required Methods§

Source

fn name(&self) -> &str

Get this segment’s name.

Source

fn stated_virtual_memory_address(&self) -> Svma

Get this segment’s stated virtual address of this segment.

This is the virtual memory address without the bias applied. See the module documentation for details.

Source

fn len(&self) -> usize

Get the length of this segment in memory (in bytes).

Provided Methods§

Source

fn is_code(&self) -> bool

Returns true if this is a code segment.

Source

fn is_load(&self) -> bool

Returns true if this is a segment loaded into memory.

Source

fn actual_virtual_memory_address(&self, shlib: &Self::SharedLibrary) -> Avma

Get this segment’s actual virtual memory address.

This is the virtual memory address with the bias applied. See the module documentation for details.

Examples found in repository?
examples/list_segments.rs (line 11)
4
5
6
7
8
9
10
11
12
13
14
15
16
fn main() {
    TargetSharedLibrary::each(|shlib| {
        println!("{}", shlib.name().to_string_lossy());

        for seg in shlib.segments() {
            println!(
                "    {}: segment {}",
                seg.actual_virtual_memory_address(shlib),
                seg.name()
            );
        }
    });
}
Source

fn contains_svma(&self, address: Svma) -> bool

Does this segment contain the given address?

Source

fn contains_avma(&self, shlib: &Self::SharedLibrary, address: Avma) -> bool

Does this segment contain the given address?

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<'a> Segment for findshlibs::linux::Segment<'a>

Source§

impl<'a> Segment for findshlibs::unsupported::Segment<'a>