pub struct LitPool { /* private fields */ }Expand description
Literal pool implementation. One can programmatically push items in this literal pool and retrieve offsets to them in the pool. Then later, the pool will be encoded into the instruction stream and items can be retrieved using the address of the literal pool. and the previously emitted offsets. Values are always at least aligned to their size.
Implementations§
Source§impl LitPool
impl LitPool
Sourcepub fn align(&mut self, size: usize, with: u8)
pub fn align(&mut self, size: usize, with: u8)
Add extra alignment for the next value in the literal pool
Sourcepub fn push_dynamic(
&mut self,
id: DynamicLabel,
size: RelocationSize,
relative: bool,
) -> isize
pub fn push_dynamic( &mut self, id: DynamicLabel, size: RelocationSize, relative: bool, ) -> isize
Encode the relative address of a label into the literal pool
if relative is true, the encoded value will be the difference between the target
and the address of this relocation. Else, it will be the absolute address of the target.
Sourcepub fn push_global(
&mut self,
name: &'static str,
size: RelocationSize,
relative: bool,
) -> isize
pub fn push_global( &mut self, name: &'static str, size: RelocationSize, relative: bool, ) -> isize
Encode the relative address of a label into the literal pool
if relative is true, the encoded value will be the difference between the target
and the address of this relocation. Else, it will be the absolute address of the target.
Sourcepub fn push_forward(
&mut self,
name: &'static str,
size: RelocationSize,
relative: bool,
) -> isize
pub fn push_forward( &mut self, name: &'static str, size: RelocationSize, relative: bool, ) -> isize
Encode the relative address of a label into the literal pool
if relative is true, the encoded value will be the difference between the target
and the address of this relocation. Else, it will be the absolute address of the target.
Sourcepub fn push_backward(
&mut self,
name: &'static str,
size: RelocationSize,
relative: bool,
) -> isize
pub fn push_backward( &mut self, name: &'static str, size: RelocationSize, relative: bool, ) -> isize
Encode the relative address of a label into the literal pool
if relative is true, the encoded value will be the difference between the target
and the address of this relocation. Else, it will be the absolute address of the target.
Sourcepub fn push_absolute_as_relative(
&mut self,
target: usize,
size: RelocationSize,
) -> isize
pub fn push_absolute_as_relative( &mut self, target: usize, size: RelocationSize, ) -> isize
Encode a relative offset of an absolute address into the literal pool.
Sourcepub fn push_relative_as_absolute(
&mut self,
target: usize,
size: RelocationSize,
) -> isize
pub fn push_relative_as_absolute( &mut self, target: usize, size: RelocationSize, ) -> isize
Encode the absolute address of a relative offset into the literal pool.
Note: offset is an usize, to use a negative offset the value can simply be wrapped.
Sourcepub fn emit<D: DynasmLabelApi>(self, assembler: &mut D)
pub fn emit<D: DynasmLabelApi>(self, assembler: &mut D)
Emit this literal pool into the specified assembler