1#ifndef ROSE_BinaryAnalysis_Assembler_H
2#define ROSE_BinaryAnalysis_Assembler_H
4#include <featureTests.h>
5#ifdef ROSE_ENABLE_BINARY_ANALYSIS
7#include <Rose/Exception.h>
10namespace BinaryAnalysis {
71 void print(std::ostream&)
const;
72 friend std::ostream& operator<<(std::ostream&,
const Exception&);
93 virtual ~Assembler() {}
118 SgUnsignedCharList
assembleBlock(
const std::vector<SgAsmInstruction*> &insns, rose_addr_t starting_rva);
Exception thrown by the assemblers.
Exception(const std::string &reason, SgAsmInstruction *insn)
An exception bound to a particular instruction being assembled.
Exception(const std::string &reason)
An exception not bound to a particular instruction.
SgAsmInstruction * insn
Instruction associated with an assembly error.
Virtual base class for instruction assemblers.
SgUnsignedCharList assembleBlock(const std::vector< SgAsmInstruction * > &insns, rose_addr_t starting_rva)
Assembles a single basic block of instructions like the version that takes an SgAsmBlock pointer.
EncodingType p_encoding_type
Which encoding should be returned by assembleOne.
EncodingType
Assemblers can often assemble a single instruction various ways.
@ ET_SHORTEST
Returns the shortest possible encoding.
@ ET_LONGEST
Returns the longest encoding.
@ ET_MATCHES
Returns an encoding that matches the SgAsmInstruction::p_raw_bytes.
static Assembler * create(SgAsmInterpretation *interp)
Creates an assembler that is appropriate for assembling instructions in the specified interpretation.
FILE * get_debug() const
Returns the file currently used for debugging; null implies no debugging.
void set_encoding_type(EncodingType et)
Controls how the assembleOne() method determines which encoding to return.
SgUnsignedCharList assembleBlock(SgAsmBlock *)
Assembles a single basic block of instructions, packing them together and adjusting their virtual add...
static Assembler * create(SgAsmGenericHeader *)
Creates an assembler that is appropriate for assembling instructions in the specified header.
FILE * p_debug
Set to non-null to get debugging info.
virtual SgUnsignedCharList assembleOne(SgAsmInstruction *insn)=0
This is the lowest level architecture-independent assembly function and is implemented in the archite...
virtual SgUnsignedCharList assembleProgram(const std::string &source)=0
Assembles a program from an assembly listing.
void set_debug(FILE *f)
Sends assembler diagnostics to the specified output stream.
EncodingType get_encoding_type() const
Returns the encoding type employed by this assembler.
Base class for all ROSE exceptions.
Base class for machine instructions.
Represents an interpretation of a binary container.