pub struct Segment {
pub vaddr: u64,
pub memsz: u64,
pub filesz: u64,
pub file_offset: u64,
pub flags: u32,
}Expand description
One loadable segment of a guest image.
All addresses are guest virtual addresses as encoded in the image; the
kernel layer relocates them through Image::segment_gpa.
Fields§
§vaddr: u64First guest virtual address of the segment.
memsz: u64Size in memory, including the zero-filled tail (BSS).
filesz: u64Size of the file-backed prefix.
file_offset: u64Offset of the file-backed prefix in the image file.
flags: u32Raw ELF p_flags bits (PF_X, PF_W, PF_R).
Implementations§
Source§impl Segment
impl Segment
Sourcepub const fn page_start(&self) -> u64
pub const fn page_start(&self) -> u64
First virtual address of the segment, page-aligned down.
Sourcepub const fn page_offset(&self) -> u64
pub const fn page_offset(&self) -> u64
Offset of the segment start inside its first page.
Sourcepub fn page_count(&self) -> u64
pub fn page_count(&self) -> u64
Number of 4 KiB pages covered by the segment.
Sourcepub fn page_len(&self) -> u64
pub fn page_len(&self) -> u64
Length in bytes of the page-aligned footprint.
Only meaningful for a segment parsed by Image::parse (the length is
then always a non-zero multiple of PAGE_SIZE); a segment built by
hand with overflowing values yields 0 instead of panicking.
Sourcepub const fn end_vaddr(&self) -> u64
pub const fn end_vaddr(&self) -> u64
End virtual address (exclusive); valid because parsing checked for overflow.
Sourcepub const fn is_readable(&self) -> bool
pub const fn is_readable(&self) -> bool
True if the segment is readable.
Sourcepub const fn is_writable(&self) -> bool
pub const fn is_writable(&self) -> bool
True if the segment is writable.
Sourcepub const fn is_executable(&self) -> bool
pub const fn is_executable(&self) -> bool
True if the segment is executable.
Sourcepub const fn perms_bits(&self) -> u32
pub const fn perms_bits(&self) -> u32
Permissions encoded for the world memory map (s9vm::memmap):
bit 1 = read, bit 2 = write, bit 4 = execute.
A segment without any ELF permission maps to 0, which the ABI layer
interprets as implicit read; this is harmless because such a segment
cannot be used as intended anyway.
Trait Implementations§
impl Copy for Segment
impl Eq for Segment
impl StructuralPartialEq for Segment
Auto Trait Implementations§
impl Forget for Segment
impl Freeze for Segment
impl Move for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnsafeUnpin for Segment
impl UnwindSafe for Segment
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more