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
impl Section
Sourcepub fn new(
name: impl Into<Cow<'static, str>>,
align: u32,
) -> Result<Self, AsmError>
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.
Sourcepub fn with_env(
name: impl Into<Cow<'static, str>>,
align: u32,
environment: Environment,
) -> Result<Self, AsmError>
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.
pub fn name(&self) -> &str
pub fn align(&self) -> u32
pub fn buffer(&self) -> &CodeBuffer
pub fn buffer_mut(&mut self) -> &mut CodeBuffer
Sourcepub fn finish(self) -> Result<FinalizedSection, AsmError>
pub fn finish(self) -> Result<FinalizedSection, AsmError>
Finalizes the section’s buffer, making it ready for linking.
Auto Trait Implementations§
impl Freeze for Section
impl RefUnwindSafe for Section
impl Send for Section
impl Sync for Section
impl Unpin for Section
impl UnsafeUnpin for Section
impl UnwindSafe for Section
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more