Skip to main content

ElfBuilder

Struct ElfBuilder 

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

ELF file builder

Implementations§

Source§

impl ElfBuilder

Source

pub fn new_arm32() -> Self

Create a new ELF builder for ARM32

Source

pub fn with_thumb_funcs(self, thumb: bool) -> Self

#598: mark the object’s functions as A32-encoded (cortex-r5 path) — suppresses the Thumb interworking bit on STT_FUNC st_values and on e_entry. Call BEFORE with_entry.

Source

pub fn with_entry(self, entry: u32) -> Self

Set entry point

For ARM Thumb targets, bit 0 is automatically set to indicate Thumb mode. Cortex-M is Thumb-only, so function addresses in ELF must have bit 0 set. A32 objects (with_thumb_funcs(false), #598) keep bit 0 clear.

Source

pub fn set_flags(&mut self, flags: u32)

Set ELF e_flags (e.g. to add hard-float ABI)

Source

pub fn with_type(self, elf_type: ElfType) -> Self

Set file type

Source

pub fn add_section(&mut self, section: Section)

Add a section

Source

pub fn add_symbol(&mut self, symbol: Symbol)

Add a symbol

Source

pub fn add_symbol_indexed(&mut self, symbol: Symbol) -> u32

Add a symbol and return its 1-based index in .symtab (index 0 is the reserved null symbol). Use when a later relocation must reference this symbol — e.g. the .text base symbol the DWARF .rel.debug_* records resolve against (VCR-DBG-001).

Source

pub fn add_program_header(&mut self, ph: ProgramHeader)

Add a program header (segment)

Source

pub fn add_relocation(&mut self, reloc: Relocation)

Add a relocation entry for the .text section

Source

pub fn add_section_relocations( &mut self, target_section: &str, relocs: Vec<Relocation>, )

Add a relocation table targeting a non-.text section by name (e.g. .debug_line). Produces a separate .rel.<name> section whose sh_info points at the named section. The section must already have been added via [add_section]; if no matching section exists at build time the table is silently dropped. Used by VCR-DBG-001 to relocate the DWARF .text references so a host linker fixes them up alongside .text.

Source

pub fn add_undefined_symbol(&mut self, name: &str) -> u32

Add an undefined external symbol (e.g., __meld_dispatch_import) Returns the symbol index (1-based, accounting for null symbol)

Source

pub fn build(&self) -> Result<Vec<u8>>

Build the ELF file to bytes

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> Same for T

Source§

type Output = T

Should always be Self
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.