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

source

pub fn new(section_index: SectionIdx) -> Self

Creates a new relocation data section with the provided section index.

source

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

source

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

source

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

source

pub fn entries(&self) -> Iter<'_, ReldEntry>

Returns an iterator over all relocation data entries in this section

source

pub fn size(&self) -> u32

The size of this relocation data section in bytes

source

pub fn section_index(&self) -> SectionIdx

The index of this section’s section header

source

pub fn parse( source: &mut BufferIterator<'_>, size: u32, section_index: SectionIdx ) -> Result<Self, ReldSectionParseError>

Parses a relocation data section from the provided byte buffer

source

pub fn write(&self, buf: &mut impl WritableBuffer)

Converts this relocation data section to its binary representation and appends it to the provided buffer

Trait Implementations§

source§

impl Debug for ReldSection

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.