Skip to main content

Section

Struct Section 

Source
pub struct Section { /* private fields */ }
Expand description

A named section: its own code buffer plus an alignment requirement.

Sections are emitted independently (each gets its own CodeBuffer, so labels and fixups stay section-local) and are laid out — concatenated with alignment — at link time by Linker. A section name is diagnostic only: the in-memory linker creates one flat image and does not model per-section read/write/execute permissions.

Implementations§

Source§

impl Section

Source

pub fn new( name: impl Into<Cow<'static, str>>, align: u32, ) -> Result<Self, AsmError>

Creates a section with the given name (conventionally .text, .data, .rodata, …) and alignment for the host target.

Cross-target users should use Self::with_env.

Source

pub fn with_env( name: impl Into<Cow<'static, str>>, align: u32, environment: Environment, ) -> Result<Self, AsmError>

Creates a section for an explicit target environment.

Source

pub fn name(&self) -> &str

Source

pub fn align(&self) -> u32

Source

pub fn buffer(&self) -> &CodeBuffer

Source

pub fn buffer_mut(&mut self) -> &mut CodeBuffer

Source

pub fn finish(self) -> Result<FinalizedSection, AsmError>

Finalizes the section’s buffer, making it ready for linking.

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.