Struct kerbalobjects::ko::sections::ReldSection
source · pub struct ReldSection { /* private fields */ }
Expand description
A relocation data section in a KerbalObject file.
This section stores a list of entries which describe which symbols should replace instruction operands in the final linked binary.
This does things like replace an external symbol with the correct value from a different file.
See the Kerbal Object file format docs to learn more, as if you are not familiar with the concept from ELF files, this may be confusing.
Implementations§
source§impl ReldSection
impl ReldSection
sourcepub fn new(section_index: SectionIdx) -> Self
pub fn new(section_index: SectionIdx) -> Self
Creates a new relocation data section with the provided section index.
sourcepub fn with_capacity(amount: usize, section_index: SectionIdx) -> Self
pub fn with_capacity(amount: usize, section_index: SectionIdx) -> Self
Creates a new relocation data section with the provided section index, with internal data structures pre-allocated for the provided amount of items
sourcepub fn add(&mut self, entry: ReldEntry) -> ReldIdx
pub fn add(&mut self, entry: ReldEntry) -> ReldIdx
Adds a new relocation data entry to this section.
Returns the entry’s index into this section
sourcepub fn get(&self, index: ReldIdx) -> Option<&ReldEntry>
pub fn get(&self, index: ReldIdx) -> Option<&ReldEntry>
Gets a relocation data entry at the provided index into this section, or None if the index doesn’t exist
sourcepub fn entries(&self) -> Iter<'_, ReldEntry>
pub fn entries(&self) -> Iter<'_, ReldEntry>
Returns an iterator over all relocation data entries in this section
sourcepub fn section_index(&self) -> SectionIdx
pub fn section_index(&self) -> SectionIdx
The index of this section’s section header
sourcepub fn parse(
source: &mut BufferIterator<'_>,
size: u32,
section_index: SectionIdx
) -> Result<Self, ReldSectionParseError>
pub fn parse( source: &mut BufferIterator<'_>, size: u32, section_index: SectionIdx ) -> Result<Self, ReldSectionParseError>
Parses a relocation data section from the provided byte buffer
sourcepub fn write(&self, buf: &mut impl WritableBuffer)
pub fn write(&self, buf: &mut impl WritableBuffer)
Converts this relocation data section to its binary representation and appends it to the provided buffer