macho_core/model/
segment.rs1use crate::format::constants::{SegmentFlags, VmProtection};
2use crate::model::addr::{ThinFileOffset, Va};
3use crate::model::names::SegmentName;
4use crate::model::section::Section;
5
6#[derive(Debug, Clone)]
7pub struct Segment {
9 pub(crate) name: SegmentName,
10 pub(crate) vm_addr: Va,
11 pub(crate) vm_size: u64,
12 pub(crate) file_offset: ThinFileOffset,
13 pub(crate) file_size: u64,
14 pub(crate) max_prot: VmProtection,
15 pub(crate) init_prot: VmProtection,
16 pub(crate) flags: SegmentFlags,
17 pub(crate) sections: Vec<Section>,
18}
19
20impl Segment {
21 pub const fn name(&self) -> &SegmentName {
23 &self.name
24 }
25 pub const fn vm_addr(&self) -> Va {
27 self.vm_addr
28 }
29 pub const fn vm_size(&self) -> u64 {
31 self.vm_size
32 }
33 pub const fn file_offset(&self) -> ThinFileOffset {
35 self.file_offset
36 }
37 pub const fn file_size(&self) -> u64 {
39 self.file_size
40 }
41 pub const fn max_prot(&self) -> VmProtection {
43 self.max_prot
44 }
45 pub const fn init_prot(&self) -> VmProtection {
47 self.init_prot
48 }
49 pub const fn flags(&self) -> SegmentFlags {
51 self.flags
52 }
53 pub fn sections(&self) -> &[Section] {
55 &self.sections
56 }
57}