elf_utilities/segment/
base.rs1use super::{Phdr32, Phdr64, Segment32, Segment64};
2
3pub(crate) struct Segment {
4 pub phdr: Phdr,
5}
6
7pub(crate) enum Phdr {
8 Phdr32(Phdr32),
9 Phdr64(Phdr64),
10}
11
12impl Segment {
13 pub fn as_64bit(&self) -> Segment64 {
14 Segment64 {
15 header: self.phdr.as_64bit(),
16 }
17 }
18 pub fn as_32bit(&self) -> Segment32 {
19 Segment32 {
20 header: self.phdr.as_32bit(),
21 }
22 }
23}
24
25impl Phdr {
26 pub fn as_64bit(&self) -> Phdr64 {
27 match self {
28 Self::Phdr64(phdr) => *phdr,
29 _ => unreachable!(),
30 }
31 }
32
33 pub fn as_32bit(&self) -> Phdr32 {
34 match self {
35 Self::Phdr32(phdr) => *phdr,
36 _ => unreachable!(),
37 }
38 }
39}