1 | //! TODO: Support the segment for XCOFF when auxiliary file header and loader section is ready. |
2 | |
3 | use core::fmt::Debug; |
4 | use core::str; |
5 | |
6 | use crate::read::{self, ObjectSegment, ReadRef, Result}; |
7 | use crate::xcoff; |
8 | |
9 | use super::{FileHeader, XcoffFile}; |
10 | |
11 | /// An iterator for the segments in an [`XcoffFile32`](super::XcoffFile32). |
12 | pub 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). |
15 | pub 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)] |
22 | pub struct XcoffSegmentIterator<'data, 'file, Xcoff, R = &'data [u8]> |
23 | where |
24 | Xcoff: FileHeader, |
25 | R: ReadRef<'data>, |
26 | { |
27 | #[allow (unused)] |
28 | pub(super) file: &'file XcoffFile<'data, Xcoff, R>, |
29 | } |
30 | |
31 | impl<'data, 'file, Xcoff, R> Iterator for XcoffSegmentIterator<'data, 'file, Xcoff, R> |
32 | where |
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). |
44 | pub type XcoffSegment32<'data, 'file, R = &'data [u8]> = |
45 | XcoffSegment<'data, 'file, xcoff::FileHeader32, R>; |
46 | /// A segment in an [`XcoffFile64`](super::XcoffFile64). |
47 | pub 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)] |
54 | pub struct XcoffSegment<'data, 'file, Xcoff, R = &'data [u8]> |
55 | where |
56 | Xcoff: FileHeader, |
57 | R: ReadRef<'data>, |
58 | { |
59 | #[allow (unused)] |
60 | pub(super) file: &'file XcoffFile<'data, Xcoff, R>, |
61 | } |
62 | |
63 | impl<'data, 'file, Xcoff, R> XcoffSegment<'data, 'file, Xcoff, R> |
64 | where |
65 | Xcoff: FileHeader, |
66 | R: ReadRef<'data>, |
67 | { |
68 | } |
69 | |
70 | impl<'data, 'file, Xcoff, R> read::private::Sealed for XcoffSegment<'data, 'file, Xcoff, R> |
71 | where |
72 | Xcoff: FileHeader, |
73 | R: ReadRef<'data>, |
74 | { |
75 | } |
76 | |
77 | impl<'data, 'file, Xcoff, R> ObjectSegment<'data> for XcoffSegment<'data, 'file, Xcoff, R> |
78 | where |
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 | |