Nyxstone
Loading...
Searching...
No Matches
nyxstone::Nyxstone Class Reference

Nyxstone class for assembling and disassembling for a given architecture. More...

#include <nyxstone.h>

Classes

struct  Instruction
 Complete instruction information. More...
 
struct  LabelDefinition
 Defines the location of a label by absolute address. More...
 

Public Member Functions

 Nyxstone (llvm::Triple &&triple, const llvm::Target &target, llvm::MCTargetOptions &&target_options, std::unique_ptr< llvm::MCRegisterInfo > &&register_info, std::unique_ptr< llvm::MCAsmInfo > &&assembler_info, std::unique_ptr< llvm::MCInstrInfo > &&instruction_info, std::unique_ptr< llvm::MCSubtargetInfo > &&subtarget_info, std::unique_ptr< llvm::MCInstPrinter > &&instruction_printer) noexcept
 Nyxstone constructor called by NyxstoneBuilder::build.
 
tl::expected< std::vector< u8 >, std::string > assemble (const std::string &assembly, uint64_t address, const std::vector< LabelDefinition > &labels) const
 Translates assembly instructions at a given start address to bytes.
 
tl::expected< std::vector< Instruction >, std::string > assemble_to_instructions (const std::string &assembly, uint64_t address, const std::vector< LabelDefinition > &labels) const
 Translates assembly instructions at given start address to instruction details containing bytes.
 
tl::expected< std::string, std::string > disassemble (const std::vector< uint8_t > &bytes, uint64_t address, size_t count) const
 Translates bytes to disassembly text at given start address.
 
tl::expected< std::vector< Instruction >, std::string > disassemble_to_instructions (const std::vector< uint8_t > &bytes, uint64_t address, size_t count) const
 Translates bytes to instruction details containing disassembly text at given start address.
 

Detailed Description

Nyxstone class for assembling and disassembling for a given architecture.

Constructor & Destructor Documentation

◆ Nyxstone()

nyxstone::Nyxstone::Nyxstone ( llvm::Triple && triple,
const llvm::Target & target,
llvm::MCTargetOptions && target_options,
std::unique_ptr< llvm::MCRegisterInfo > && register_info,
std::unique_ptr< llvm::MCAsmInfo > && assembler_info,
std::unique_ptr< llvm::MCInstrInfo > && instruction_info,
std::unique_ptr< llvm::MCSubtargetInfo > && subtarget_info,
std::unique_ptr< llvm::MCInstPrinter > && instruction_printer )
inlinenoexcept

Nyxstone constructor called by NyxstoneBuilder::build.

Warning
This function should not be called directly, use NyxstoneBuilder instead.
Parameters
tripleThe llvm triple used to construct the llvm objects.
cpuThe cpu string used to construct the subtarget_info (as it points to the data inside).
featuresThe cpu features used to construct the subtarget_info (as it points to the data inside).
targetTarget for the given triple.
target_optionsEmpty target options (reused from creating assembler_info).
register_infoRegister info for the given triple.
assembler_infoAssembler info for given triple.
instruction_infoInstruction information for the given triple.
subtarget_infoInformation about the subtarget, created with cpu and features.
instruction_printerInstruction printer for the given architecture.

Member Function Documentation

◆ assemble()

tl::expected< std::vector< u8 >, std::string > nyxstone::Nyxstone::assemble ( const std::string & assembly,
uint64_t address,
const std::vector< LabelDefinition > & labels ) const

Translates assembly instructions at a given start address to bytes.

Additional label definitions by absolute address may be supplied. Does not support assembly directives that impact the layout (f. i., .section, .org).

Parameters
assemblyThe assembly instruction(s) to be assembled.
addressThe absolute address of the first instruction.
labelsLabel definitions, should hold all external labels used in the assembly.
Returns
The assembled bytes on success, an error string otherwise.

◆ assemble_to_instructions()

tl::expected< std::vector< Nyxstone::Instruction >, std::string > nyxstone::Nyxstone::assemble_to_instructions ( const std::string & assembly,
uint64_t address,
const std::vector< LabelDefinition > & labels ) const

Translates assembly instructions at given start address to instruction details containing bytes.

Additional label definitions by absolute address may be supplied. Does not support assembly directives that impact the layout (f. i., .section, .org).

Parameters
assemblyThe assembly instruction(s) to be assembled.
addressThe absolute address of the first instruction.
labelsLabel definitions, should hold all external labels used in the assembly.
Returns
The instruction details on success, an error string otherwise.

◆ disassemble()

tl::expected< std::string, std::string > nyxstone::Nyxstone::disassemble ( const std::vector< uint8_t > & bytes,
uint64_t address,
size_t count ) const

Translates bytes to disassembly text at given start address.

Parameters
bytesThe byte code to be disassembled.
addressThe absolute address of the byte code.
countThe number of instructions which should be disassembled, 0 means all.
Returns
The disassembly on success, an error string otherwise.

◆ disassemble_to_instructions()

tl::expected< std::vector< Nyxstone::Instruction >, std::string > nyxstone::Nyxstone::disassemble_to_instructions ( const std::vector< uint8_t > & bytes,
uint64_t address,
size_t count ) const

Translates bytes to instruction details containing disassembly text at given start address.

Parameters
bytesThe byte code to be disassembled.
addressThe absolute address of the byte code.
countThe number of instructions which should be disassembled, 0 means all.
Returns
The instruction details on success, an error string otherwise.

The documentation for this class was generated from the following files: