pub struct Segment<'a> {
pub cmd: u32,
pub cmdsize: u32,
pub segname: [u8; 16],
pub vmaddr: u64,
pub vmsize: u64,
pub fileoff: u64,
pub filesize: u64,
pub maxprot: u32,
pub initprot: u32,
pub nsects: u32,
pub flags: u32,
pub data: &'a [u8],
/* private fields */
}
Expand description
Generalized 32/64 bit Segment Command
Fields§
§cmd: u32
§cmdsize: u32
§segname: [u8; 16]
§vmaddr: u64
§vmsize: u64
§fileoff: u64
§filesize: u64
§maxprot: u32
§initprot: u32
§nsects: u32
§flags: u32
§data: &'a [u8]
Implementations§
Source§impl<'a> Segment<'a>
impl<'a> Segment<'a>
Sourcepub fn new(ctx: Ctx, sections: &'a [u8]) -> Self
pub fn new(ctx: Ctx, sections: &'a [u8]) -> Self
Create a new, blank segment, with cmd either LC_SEGMENT_64
, or LC_SEGMENT
, depending on ctx
.
NB You are responsible for providing a correctly marshalled byte array as the sections. You should not use this for anything other than writing.
Sourcepub fn sections(&self) -> Result<Vec<(Section, SectionData<'a>)>>
pub fn sections(&self) -> Result<Vec<(Section, SectionData<'a>)>>
Get the sections from this segment, erroring if any section couldn’t be retrieved
Sourcepub fn from_32(
bytes: &'a [u8],
segment: &SegmentCommand32,
offset: usize,
ctx: Ctx,
) -> Result<Self, Error>
pub fn from_32( bytes: &'a [u8], segment: &SegmentCommand32, offset: usize, ctx: Ctx, ) -> Result<Self, Error>
Convert the raw C 32-bit segment command to a generalized version
Sourcepub fn from_32_lossy(
bytes: &'a [u8],
segment: &SegmentCommand32,
offset: usize,
ctx: Ctx,
) -> Result<Self, Error>
pub fn from_32_lossy( bytes: &'a [u8], segment: &SegmentCommand32, offset: usize, ctx: Ctx, ) -> Result<Self, Error>
Convert the raw C 32-bit segment command to a generalized version
Sourcepub fn from_64(
bytes: &'a [u8],
segment: &SegmentCommand64,
offset: usize,
ctx: Ctx,
) -> Result<Self, Error>
pub fn from_64( bytes: &'a [u8], segment: &SegmentCommand64, offset: usize, ctx: Ctx, ) -> Result<Self, Error>
Convert the raw C 64-bit segment command to a generalized version
Sourcepub fn from_64_lossy(
bytes: &'a [u8],
segment: &SegmentCommand64,
offset: usize,
ctx: Ctx,
) -> Result<Self, Error>
pub fn from_64_lossy( bytes: &'a [u8], segment: &SegmentCommand64, offset: usize, ctx: Ctx, ) -> Result<Self, Error>
Convert the raw C 64-bit segment command to a generalized version
Trait Implementations§
Source§impl<'a> From<Segment<'a>> for SegmentCommand32
impl<'a> From<Segment<'a>> for SegmentCommand32
Source§impl<'a> From<Segment<'a>> for SegmentCommand64
impl<'a> From<Segment<'a>> for SegmentCommand64
Source§impl<'a, 'b> IntoIterator for &'b Segment<'a>
impl<'a, 'b> IntoIterator for &'b Segment<'a>
Auto Trait Implementations§
impl<'a> Freeze for Segment<'a>
impl<'a> RefUnwindSafe for Segment<'a>
impl<'a> Send for Segment<'a>
impl<'a> Sync for Segment<'a>
impl<'a> Unpin for Segment<'a>
impl<'a> UnwindSafe for Segment<'a>
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