Crate dynasmrt

Source
Expand description

This crate provides runtime support for dynasm-rs. It contains traits that document the interface used by the dynasm proc_macro to generate code, Assemblers that implement these traits, and relocation models for the various supported architectures. Additionally, it also provides the tools to write your own Assemblers using these components.

Re-exports§

pub use crate::mmap::ExecutableBuffer;

Modules§

aarch64
Runtime support for the aarch64 architecture assembling target.
cache_control
This module contains several utility functions to manage the state of the caches of the executing processor. On von Neumann architectures (like x86/AMD64), these are no-ops, as these processors ensure synchronization of the instruction and data caches internally. On modified Harvard architectures like ARMv8, these functions are needed to ensure that the data cache and instruction cache stay synchronized.
components
This module provides several reusable compoments for implementing assemblers
mmap
This module implements some wrappers around Mmap/MmapMut to also support a cheap “empty” variant.
relocations
This module defines the Relocation trait and several utilities for implementing relocations.
riscv
Runtime support for the 32-bit and 64-bit RISC-V architecture assembling targets.
x64
Runtime support for the x64 architecture assembling target.
x86
Runtime support for the x86 architecture assembling target.

Macros§

MutPointer
Preforms the same action as the Pointer! macro, but casts to a *mut pointer.
Pointer
This macro takes a *const pointer from the source operand, and then casts it to the desired return type. this allows it to be used as an easy shorthand for passing pointers as dynasm immediate arguments.
dynasm
The whole point. This macro compiles given assembly/Rust templates down to DynasmApi and DynasmLabelApi compliant calls to an assembler.
dynasm_backwards
Similar to dynasm!, but the calls to the assembler are executed in piecewise reversed order. This is to allow the system to be used with assemblers that assemble backwards. Currently this is not supported by the dynasmrt crate, but this allows experimentation with it out of tree.

Structs§

Assembler
A full assembler implementation. Supports labels, all types of relocations, incremental compilation and multithreaded execution with simultaneous compilation. Its implementation guarantees no memory is executable and writable at the same time.
AssemblyOffset
A struct representing an offset into the assembling buffer of a DynasmLabelApi struct. The wrapped usize is the offset from the start of the assembling buffer in bytes.
DynamicLabel
A dynamic label
Executor
A read-only shared reference to the executable buffer inside an Assembler. By locking it the internal ExecutableBuffer can be accessed and executed.
Modifier
Allows modification of already committed assembly code. Contains an internal cursor into the emitted assembly, initialized to the start, that can be moved around either with the goto function, or just by assembling new code into this Modifier.
SimpleAssembler
An assembler that is purely a Vec<u8>. It doesn’t support labels or architecture-specific directives, but can be used to easily inspect generated code. It is intended to be used in testcases.
UncommittedModifier
This struct is a wrapper around an Assembler normally created using the Assembler.alter_uncommitted method. It allows the user to edit parts of the assembling buffer that cannot be determined easily or efficiently in advance. Due to limitations of the label resolution algorithms, this assembler does not allow labels to be used.
VecAssembler
An assembler that assembles into a Vec<u8>, while supporting labels. To support the different types of relocations it requires a base address of the to be assembled code to be specified.

Enums§

DynasmError
The various error types generated by dynasm functions.
LabelKind
A description of a label. Used for error reporting.
TargetKind
A description of a relocation target. Used for error reporting.

Traits§

DynasmApi
This trait represents the interface that must be implemented to allow the dynasm preprocessor to assemble into a datastructure.
DynasmLabelApi
This trait extends DynasmApi to not only allow assembling, but also labels and various directives.
Register
A trait abstracting over architectural register families. This is usually implemented over an enum of all available registers in each family. This allows for code that is generic over register families.