pub trait TextSectionBuilder {
// Required methods
fn append(
&mut self,
labeled: bool,
data: &[u8],
align: u32,
ctrl_plane: &mut ControlPlane,
) -> u64;
fn resolve_reloc(
&mut self,
offset: u64,
reloc: Reloc,
addend: Addend,
target: usize,
) -> bool;
fn force_veneers(&mut self);
fn finish(&mut self, ctrl_plane: &mut ControlPlane) -> Vec<u8> ⓘ;
}
Expand description
An object that can be used to create the text section of an executable.
This primarily handles resolving relative relocations at text-section-assembly time rather than at load/link time. This architecture-specific logic is sort of like a linker, but only for one object file at a time.
Required Methods§
Sourcefn append(
&mut self,
labeled: bool,
data: &[u8],
align: u32,
ctrl_plane: &mut ControlPlane,
) -> u64
fn append( &mut self, labeled: bool, data: &[u8], align: u32, ctrl_plane: &mut ControlPlane, ) -> u64
Appends data
to the text section with the align
specified.
If labeled
is true
then this also binds the appended data to the
n
th label for how many times this has been called with labeled: true
. The label target can be passed as the target
argument to
resolve_reloc
.
This function returns the offset at which the data was placed in the text section.
Sourcefn resolve_reloc(
&mut self,
offset: u64,
reloc: Reloc,
addend: Addend,
target: usize,
) -> bool
fn resolve_reloc( &mut self, offset: u64, reloc: Reloc, addend: Addend, target: usize, ) -> bool
Attempts to resolve a relocation for this function.
The offset
is the offset of the relocation, within the text section.
The reloc
is the kind of relocation.
The addend
is the value to add to the relocation.
The target
is the labeled function that is the target of this
relocation.
Labeled functions are created with the append
function above by
setting the labeled
parameter to true
.
If this builder does not know how to handle reloc
then this function
will return false
. Otherwise this function will return true
and this
relocation will be resolved in the final bytes returned by finish
.
Sourcefn force_veneers(&mut self)
fn force_veneers(&mut self)
A debug-only option which is used to for