pub trait Section:
Debug
+ Pod
+ Sealed {
type Word: Into<u64>;
type Endian: Endian;
Show 21 methods
// Required methods
fn sectname(&self) -> &[u8; 16];
fn segname(&self) -> &[u8; 16];
fn addr(&self, endian: Self::Endian) -> Self::Word;
fn size(&self, endian: Self::Endian) -> Self::Word;
fn offset(&self, endian: Self::Endian) -> u32;
fn align(&self, endian: Self::Endian) -> u32;
fn reloff(&self, endian: Self::Endian) -> u32;
fn nreloc(&self, endian: Self::Endian) -> u32;
fn flags(&self, endian: Self::Endian) -> SectionFlags;
fn reserved1(&self, endian: Self::Endian) -> u32;
fn reserved2(&self, endian: Self::Endian) -> u32;
fn reserved3(&self, endian: Self::Endian) -> u32;
// Provided methods
fn name(&self) -> &[u8] ⓘ { ... }
fn segment_name(&self) -> &[u8] ⓘ { ... }
fn section_type(&self, endian: Self::Endian) -> SectionType { ... }
fn file_size(&self, endian: Self::Endian) -> Option<u64> { ... }
fn file_range(
&self,
endian: Self::Endian,
offset: u64,
) -> Option<(u64, u64)> { ... }
fn data<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
offset: u64,
) -> Result<&'data [u8]> { ... }
fn relocations<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<&'data [Relocation<Self::Endian>]> { ... }
fn symbol_stub_size(&self, endian: Self::Endian) -> u32 { ... }
fn indirect_symbols<'data>(
&self,
endian: Self::Endian,
indirect_symbols: &'data [U32<Self::Endian, IndirectSymbol>],
) -> Result<&'data [U32<Self::Endian, IndirectSymbol>]> { ... }
}Expand description
A trait for generic access to macho::Section32 and macho::Section64.
Required Associated Types§
Required Methods§
fn sectname(&self) -> &[u8; 16]
fn segname(&self) -> &[u8; 16]
fn addr(&self, endian: Self::Endian) -> Self::Word
fn size(&self, endian: Self::Endian) -> Self::Word
Sourcefn offset(&self, endian: Self::Endian) -> u32
fn offset(&self, endian: Self::Endian) -> u32
The file offset of the section.
Note that for offsets larger than u32::MAX this will be truncated, so you will
need to determine the offset in another way.
(section.addr - segment.vmaddr) + segment.fileoff is equivalent for well-formed files.
Alternatively, you can use Segment::section_offsets
to track the file offset of consecutive sections to determine when overflow occurs.
fn align(&self, endian: Self::Endian) -> u32
fn reloff(&self, endian: Self::Endian) -> u32
fn nreloc(&self, endian: Self::Endian) -> u32
fn flags(&self, endian: Self::Endian) -> SectionFlags
fn reserved1(&self, endian: Self::Endian) -> u32
fn reserved2(&self, endian: Self::Endian) -> u32
fn reserved3(&self, endian: Self::Endian) -> u32
Provided Methods§
Sourcefn segment_name(&self) -> &[u8] ⓘ
fn segment_name(&self) -> &[u8] ⓘ
Return the segname bytes up until the null terminator.
Sourcefn section_type(&self, endian: Self::Endian) -> SectionType
fn section_type(&self, endian: Self::Endian) -> SectionType
Return the section type from the flags field.
Sourcefn file_size(&self, endian: Self::Endian) -> Option<u64>
fn file_size(&self, endian: Self::Endian) -> Option<u64>
Return the size of the section in the file.
Returns None for sections that have no data in the file.
Sourcefn file_range(&self, endian: Self::Endian, offset: u64) -> Option<(u64, u64)>
fn file_range(&self, endian: Self::Endian, offset: u64) -> Option<(u64, u64)>
Return the offset and size of the section in the file.
offset must be the section file offset. See Self::offset and
Segment::section_offsets.
Returns None for sections that have no data in the file.
Sourcefn data<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
offset: u64,
) -> Result<&'data [u8]>
fn data<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, offset: u64, ) -> Result<&'data [u8]>
Return the section data.
offset must be the section file offset. See Self::offset and
Segment::section_offsets.
Returns Ok(&[]) if the section has no data.
Returns Err for invalid values.
Sourcefn relocations<'data, R: ReadRef<'data>>(
&self,
endian: Self::Endian,
data: R,
) -> Result<&'data [Relocation<Self::Endian>]>
fn relocations<'data, R: ReadRef<'data>>( &self, endian: Self::Endian, data: R, ) -> Result<&'data [Relocation<Self::Endian>]>
Return the relocation array.
Returns Err for invalid values.
Sourcefn symbol_stub_size(&self, endian: Self::Endian) -> u32
fn symbol_stub_size(&self, endian: Self::Endian) -> u32
Return the size of symbol stubs in this section.
Returns 0 if this section does not contain symbol stubs.
Sourcefn indirect_symbols<'data>(
&self,
endian: Self::Endian,
indirect_symbols: &'data [U32<Self::Endian, IndirectSymbol>],
) -> Result<&'data [U32<Self::Endian, IndirectSymbol>]>
fn indirect_symbols<'data>( &self, endian: Self::Endian, indirect_symbols: &'data [U32<Self::Endian, IndirectSymbol>], ) -> Result<&'data [U32<Self::Endian, IndirectSymbol>]>
Return the indirect symbols referenced by this section.
Returns an empty slice if this section does not reference indirect symbols.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".