pub struct Segment {
    pub kind: SegmentKind,
    pub flags: SegmentFlags,
    pub offset: u64,
    pub virtual_address: u64,
    pub physical_address: u64,
    pub file_size: u64,
    pub memory_size: u64,
    pub align: u64,
}Expand description
Segment.
Dynamic loader maps segments into virtual address space of a program. Usually segments consists of sections, however, some segment types exist on their own.
Fields§
§kind: SegmentKindSegment type.
flags: SegmentFlagsFlags.
offset: u64In-file offset.
virtual_address: u64Virtual address (in-memory offset).
physical_address: u64Physical address (in-memory offset).
Usually physical address is the same as virtual address.
file_size: u64In-file size.
memory_size: u64In-memory size.
align: u64Alignment.
- Offset and virtual address must have congruent values,
i.e. offset % align == virtual_address % align.
- LOADsegments boundaries are expanded to the nearest page boundaries, i.e.- offsetis rounded down to a multiple of page size and- offset + memory_sizeis rounded up to a multiple of page size.
Implementations§
Source§impl Segment
 
impl Segment
Sourcepub fn read_content<R: ElfRead + ElfSeek, T: BlockRead>(
    &self,
    reader: &mut R,
    class: Class,
    byte_order: ByteOrder,
) -> Result<T, Error>
 
pub fn read_content<R: ElfRead + ElfSeek, T: BlockRead>( &self, reader: &mut R, class: Class, byte_order: ByteOrder, ) -> Result<T, Error>
Read segment contents as bytes.
Sourcepub fn write_content<W: ElfWrite + ElfSeek, T: BlockWrite + ?Sized>(
    &self,
    writer: &mut W,
    class: Class,
    byte_order: ByteOrder,
    content: &T,
) -> Result<(), Error>
 
pub fn write_content<W: ElfWrite + ElfSeek, T: BlockWrite + ?Sized>( &self, writer: &mut W, class: Class, byte_order: ByteOrder, content: &T, ) -> Result<(), Error>
Write segment contents.
Sourcepub fn clear_content<W: ElfWrite + ElfSeek>(
    &self,
    writer: &mut W,
) -> Result<(), Error>
 
pub fn clear_content<W: ElfWrite + ElfSeek>( &self, writer: &mut W, ) -> Result<(), Error>
Zero out the entry’s content.
Sourcepub const fn physical_address_range(&self) -> Range<u64>
 
pub const fn physical_address_range(&self) -> Range<u64>
Physical address range.
Sourcepub const fn virtual_address_range(&self) -> Range<u64>
 
pub const fn virtual_address_range(&self) -> Range<u64>
Virtual address range.
Sourcepub const fn file_offset_range(&self) -> Range<u64>
 
pub const fn file_offset_range(&self) -> Range<u64>
In-file location of the segment.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin 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
Mutably borrows from an owned value. Read more