1//! TODO: Support the segment for XCOFF when auxiliary file header and loader section is ready.
2
3use core::fmt::Debug;
4use core::str;
5
6use crate::read::{self, ObjectSegment, ReadRef, Result};
7use crate::xcoff;
8
9use super::{FileHeader, XcoffFile};
10
11/// An iterator for the segments in an [`XcoffFile32`](super::XcoffFile32).
12pub type XcoffSegmentIterator32<'data, 'file, R = &'data [u8]> =
13 XcoffSegmentIterator<'data, 'file, xcoff::FileHeader32, R>;
14/// An iterator for the segments in an [`XcoffFile64`](super::XcoffFile64).
15pub type XcoffSegmentIterator64<'data, 'file, R = &'data [u8]> =
16 XcoffSegmentIterator<'data, 'file, xcoff::FileHeader64, R>;
17
18/// An iterator for the segments in an [`XcoffFile`].
19///
20/// This is a stub that doesn't implement any functionality.
21#[derive(Debug)]
22pub struct XcoffSegmentIterator<'data, 'file, Xcoff, R = &'data [u8]>
23where
24 Xcoff: FileHeader,
25 R: ReadRef<'data>,
26{
27 #[allow(unused)]
28 pub(super) file: &'file XcoffFile<'data, Xcoff, R>,
29}
30
31impl<'data, 'file, Xcoff, R> Iterator for XcoffSegmentIterator<'data, 'file, Xcoff, R>
32where
33 Xcoff: FileHeader,
34 R: ReadRef<'data>,
35{
36 type Item = XcoffSegment<'data, 'file, Xcoff, R>;
37
38 fn next(&mut self) -> Option<Self::Item> {
39 None
40 }
41}
42
43/// A segment in an [`XcoffFile32`](super::XcoffFile32).
44pub type XcoffSegment32<'data, 'file, R = &'data [u8]> =
45 XcoffSegment<'data, 'file, xcoff::FileHeader32, R>;
46/// A segment in an [`XcoffFile64`](super::XcoffFile64).
47pub type XcoffSegment64<'data, 'file, R = &'data [u8]> =
48 XcoffSegment<'data, 'file, xcoff::FileHeader64, R>;
49
50/// A loadable section in an [`XcoffFile`].
51///
52/// This is a stub that doesn't implement any functionality.
53#[derive(Debug)]
54pub struct XcoffSegment<'data, 'file, Xcoff, R = &'data [u8]>
55where
56 Xcoff: FileHeader,
57 R: ReadRef<'data>,
58{
59 #[allow(unused)]
60 pub(super) file: &'file XcoffFile<'data, Xcoff, R>,
61}
62
63impl<'data, 'file, Xcoff, R> XcoffSegment<'data, 'file, Xcoff, R>
64where
65 Xcoff: FileHeader,
66 R: ReadRef<'data>,
67{
68}
69
70impl<'data, 'file, Xcoff, R> read::private::Sealed for XcoffSegment<'data, 'file, Xcoff, R>
71where
72 Xcoff: FileHeader,
73 R: ReadRef<'data>,
74{
75}
76
77impl<'data, 'file, Xcoff, R> ObjectSegment<'data> for XcoffSegment<'data, 'file, Xcoff, R>
78where
79 Xcoff: FileHeader,
80 R: ReadRef<'data>,
81{
82 fn address(&self) -> u64 {
83 unreachable!();
84 }
85
86 fn size(&self) -> u64 {
87 unreachable!();
88 }
89
90 fn align(&self) -> u64 {
91 unreachable!();
92 }
93
94 fn file_range(&self) -> (u64, u64) {
95 unreachable!();
96 }
97
98 fn data(&self) -> Result<&'data [u8]> {
99 unreachable!();
100 }
101
102 fn data_range(&self, _address: u64, _size: u64) -> Result<Option<&'data [u8]>> {
103 unreachable!();
104 }
105
106 fn name_bytes(&self) -> Result<Option<&[u8]>> {
107 unreachable!();
108 }
109
110 fn name(&self) -> Result<Option<&str>> {
111 unreachable!();
112 }
113
114 fn flags(&self) -> crate::SegmentFlags {
115 unreachable!();
116 }
117}
118