retdec
Classes | Public Member Functions | Static Public Member Functions | List of all members
retdec::capstone2llvmir::Capstone2LlvmIrTranslator Class Referenceabstract

#include <capstone2llvmir.h>

Inheritance diagram for retdec::capstone2llvmir::Capstone2LlvmIrTranslator:
Inheritance graph
[legend]

Classes

struct  TranslationResult
 
struct  TranslationResultOne
 

Public Member Functions

virtual ~Capstone2LlvmIrTranslator ()=default
 
virtual void setIgnoreUnexpectedOperands (bool f)=0
 
virtual void setIgnoreUnhandledInstructions (bool f)=0
 
virtual void setGeneratePseudoAsmFunctions (bool f)=0
 
virtual bool isIgnoreUnexpectedOperands () const =0
 
virtual bool isIgnoreUnhandledInstructions () const =0
 
virtual bool isGeneratePseudoAsmFunctions () const =0
 
virtual bool isAllowedBasicMode (cs_mode m)=0
 
virtual bool isAllowedExtraMode (cs_mode m)=0
 
virtual void modifyBasicMode (cs_mode m)=0
 
virtual void modifyExtraMode (cs_mode m)=0
 
virtual uint32_t getArchByteSize ()=0
 
virtual uint32_t getArchBitSize ()=0
 
virtual TranslationResult translate (const uint8_t *bytes, std::size_t size, retdec::common::Address a, llvm::IRBuilder<> &irb, std::size_t count=0, bool stopOnBranch=false)=0
 
virtual TranslationResultOne translateOne (const uint8_t *&bytes, std::size_t &size, retdec::common::Address &a, llvm::IRBuilder<> &irb)=0
 
virtual const csh & getCapstoneEngine () const =0
 
virtual cs_arch getArchitecture () const =0
 
virtual cs_mode getBasicMode () const =0
 
virtual cs_mode getExtraMode () const =0
 
virtual bool hasDelaySlot (uint32_t id) const =0
 
virtual bool hasDelaySlotTypical (uint32_t id) const =0
 
virtual bool hasDelaySlotLikely (uint32_t id) const =0
 
virtual std::size_t getDelaySlot (uint32_t id) const =0
 
virtual llvm::GlobalVariable * getRegister (uint32_t r)=0
 
virtual std::string getRegisterName (uint32_t r) const =0
 
virtual uint32_t getRegisterBitSize (uint32_t r) const =0
 
virtual uint32_t getRegisterByteSize (uint32_t r) const =0
 
virtual llvm::Type * getRegisterType (uint32_t r) const =0
 
virtual bool isControlFlowInstruction (cs_insn &i) const =0
 
virtual bool isCallInstruction (cs_insn &i) const =0
 
virtual bool isReturnInstruction (cs_insn &i) const =0
 
virtual bool isBranchInstruction (cs_insn &i) const =0
 
virtual bool isCondBranchInstruction (cs_insn &i) const =0
 
virtual llvm::Module * getModule () const =0
 
virtual bool isSpecialAsm2LlvmMapGlobal (llvm::Value *v) const =0
 
virtual llvm::StoreInst * isSpecialAsm2LlvmInstr (llvm::Value *v) const =0
 
virtual llvm::GlobalVariable * getAsm2LlvmMapGlobalVariable () const =0
 
virtual bool isCallFunction (llvm::Function *f) const =0
 
virtual bool isCallFunctionCall (llvm::CallInst *c) const =0
 
virtual llvm::BranchInst * isInConditionCallFunctionCall (llvm::CallInst *c) const =0
 
virtual llvm::Function * getCallFunction () const =0
 
virtual bool isReturnFunction (llvm::Function *f) const =0
 
virtual bool isReturnFunctionCall (llvm::CallInst *c) const =0
 
virtual llvm::BranchInst * isInConditionReturnFunctionCall (llvm::CallInst *c) const =0
 
virtual llvm::Function * getReturnFunction () const =0
 
virtual bool isBranchFunction (llvm::Function *f) const =0
 
virtual bool isBranchFunctionCall (llvm::CallInst *c) const =0
 
virtual llvm::BranchInst * isInConditionBranchFunctionCall (llvm::CallInst *c) const =0
 
virtual llvm::Function * getBranchFunction () const =0
 
virtual bool isCondBranchFunction (llvm::Function *f) const =0
 
virtual llvm::BranchInst * isInConditionCondBranchFunctionCall (llvm::CallInst *c) const =0
 
virtual bool isCondBranchFunctionCall (llvm::CallInst *c) const =0
 
virtual llvm::Function * getCondBranchFunction () const =0
 
virtual bool isAnyPseudoFunction (llvm::Function *f) const =0
 
virtual bool isAnyPseudoFunctionCall (llvm::CallInst *c) const =0
 
virtual llvm::GlobalVariable * isRegister (llvm::Value *v) const =0
 
virtual uint32_t getCapstoneRegister (llvm::GlobalVariable *gv) const =0
 
virtual bool isPseudoAsmFunction (llvm::Function *f) const =0
 
virtual bool isPseudoAsmFunctionCall (llvm::CallInst *c) const =0
 
virtual const std::set< llvm::Function * > & getPseudoAsmFunctions () const =0
 

Static Public Member Functions

static std::unique_ptr< Capstone2LlvmIrTranslatorcreateArch (cs_arch a, llvm::Module *m, cs_mode basic=CS_MODE_LITTLE_ENDIAN, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateArm (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateThumb (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateArm64 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateMips32 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateMips64 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateMips3 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateMips32R6 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateX86_16 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateX86_32 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateX86_64 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreatePpc32 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreatePpc64 (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreatePpcQpx (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateSparc (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateSysz (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 
static std::unique_ptr< Capstone2LlvmIrTranslatorcreateXcore (llvm::Module *m, cs_mode extra=CS_MODE_LITTLE_ENDIAN)
 

Detailed Description

Abstract public interface class for all translators.

Translator accepts binary data and position in LLVM module, disassembles the data into Capstone instruction(s), and translates these instruction(s) to LLVM IR instructions located at the given position.

Constructor & Destructor Documentation

◆ ~Capstone2LlvmIrTranslator()

virtual retdec::capstone2llvmir::Capstone2LlvmIrTranslator::~Capstone2LlvmIrTranslator ( )
virtualdefault

Member Function Documentation

◆ createArch()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createArch ( cs_arch  a,
llvm::Module *  m,
cs_mode  basic = CS_MODE_LITTLE_ENDIAN,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create translator for the specified architecture a, module m, architecture basic HW mode basicMode corresponding to HW architectures (e.g. CS_MODE_ARM or CS_MODE_THUMB for CS_ARCH_ARM), and extra mode extraMode that can be combined with basic HW mode (e.g. CS_MODE_BIG_ENDIAN).

Returns
Unique pointer to created translator, or nullptr if translator (with the specified modes) could not be created.

◆ createArm()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createArm ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create 32-bit ARM translator with basic mode CS_MODE_ARM, and extra mode extra. This is meant to be used when ARM needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create THUMB translator use createThumb().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createArm64()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createArm64 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create 64-bit ARM translator with basic mode CS_MODE_ARM, and extra mode extra. This is meant to be used when 64-bit ARM needs to be used with extra mode like CS_MODE_BIG_ENDIAN.

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createMips3()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createMips3 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create MIPS translator with basic mode CS_MODE_MIPS3, and extra mode extra. This is meant to be used when MIPS needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create a different flavour of MIPS translator use createMips32(), createMips64(), or createMips32R6().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createMips32()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createMips32 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create MIPS translator with basic mode CS_MODE_MIPS32, and extra mode extra. This is meant to be used when MIPS needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create a different flavour of MIPS translator use createMips64(), createMips3(), or createMips32R6().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createMips32R6()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createMips32R6 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create MIPS translator with basic mode CS_MODE_MIPS32R6, and extra mode extra. This is meant to be used when MIPS needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create a different flavour of MIPS translator use createMips32(), createMips64(), or createMips3().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createMips64()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createMips64 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create MIPS translator with basic mode CS_MODE_MIPS64, and extra mode extra. This is meant to be used when MIPS needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create a different flavour of MIPS translator use createMips32(), createMips3(), or createMips32R6().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createPpc32()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createPpc32 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create 32-bit PowerPC translator with basic mode CS_MODE_32, and extra mode extra. This is meant to be used when PowerPC needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create 64-bit PowerPC translator use createPpc64().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createPpc64()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createPpc64 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create 64-bit PowerPC translator with basic mode CS_MODE_64, and extra mode extra. This is meant to be used when PowerPC needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create 32-bit PowerPC translator use createPpc32().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createPpcQpx()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createPpcQpx ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create QPX PowerPC translator with basic mode CS_MODE_QPX, and extra mode extra. This is meant to be used when PowerPC needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create 32-bit PowerPC translator use createPpc32().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createSparc()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createSparc ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create SPARC translator with extra mode extra. This is meant to be used when SPARC needs to be used with extra mode like CS_MODE_BIG_ENDIAN.

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createSysz()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createSysz ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create SystemZ translator with extra mode extra. This is meant to be used when SystemZ needs to be used with extra mode like CS_MODE_BIG_ENDIAN.

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createThumb()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createThumb ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create 32-bit ARM translator with basic mode CS_MODE_THUMB, and extra mode extra. This is meant to be used when THUMB needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create ARM translator use createArm().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createX86_16()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createX86_16 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create x86 translator with basic mode CS_MODE_16, and extra mode extra. This is meant to be used when x86 needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create a different flavour of x86 translator use createX86_32() or createX86_64().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createX86_32()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createX86_32 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create x86 translator with basic mode CS_MODE_32, and extra mode extra. This is meant to be used when x86 needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create a different flavour of x86 translator use createX86_16() or createX86_64().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createX86_64()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createX86_64 ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create x86 translator with basic mode CS_MODE_64, and extra mode extra. This is meant to be used when x86 needs to be used with extra mode like CS_MODE_BIG_ENDIAN. If you want to create a different flavour of x86 translator use createX86_16() or createX86_32().

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ createXcore()

std::unique_ptr< Capstone2LlvmIrTranslator > retdec::capstone2llvmir::Capstone2LlvmIrTranslator::createXcore ( llvm::Module *  m,
cs_mode  extra = CS_MODE_LITTLE_ENDIAN 
)
static

Create XCore translator with extra mode extra. This is meant to be used when XCore needs to be used with extra mode like CS_MODE_BIG_ENDIAN.

Returns
Unique pointer to created translator, or nullptr if translator (with the specified mode) could not be created.

◆ getArchBitSize()

virtual uint32_t retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getArchBitSize ( )
pure virtual

◆ getArchByteSize()

virtual uint32_t retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getArchByteSize ( )
pure virtual

◆ getArchitecture()

virtual cs_arch retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getArchitecture ( ) const
pure virtual

◆ getAsm2LlvmMapGlobalVariable()

virtual llvm::GlobalVariable* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getAsm2LlvmMapGlobalVariable ( ) const
pure virtual

◆ getBasicMode()

virtual cs_mode retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getBasicMode ( ) const
pure virtual

◆ getBranchFunction()

virtual llvm::Function* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getBranchFunction ( ) const
pure virtual

◆ getCallFunction()

virtual llvm::Function* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getCallFunction ( ) const
pure virtual

◆ getCapstoneEngine()

virtual const csh& retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getCapstoneEngine ( ) const
pure virtual

◆ getCapstoneRegister()

virtual uint32_t retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getCapstoneRegister ( llvm::GlobalVariable *  gv) const
pure virtual

◆ getCondBranchFunction()

virtual llvm::Function* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getCondBranchFunction ( ) const
pure virtual

◆ getDelaySlot()

virtual std::size_t retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getDelaySlot ( uint32_t  id) const
pure virtual

◆ getExtraMode()

virtual cs_mode retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getExtraMode ( ) const
pure virtual

◆ getModule()

virtual llvm::Module* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getModule ( ) const
pure virtual

◆ getPseudoAsmFunctions()

virtual const std::set<llvm::Function*>& retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getPseudoAsmFunctions ( ) const
pure virtual

◆ getRegister()

virtual llvm::GlobalVariable* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getRegister ( uint32_t  r)
pure virtual

◆ getRegisterBitSize()

virtual uint32_t retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getRegisterBitSize ( uint32_t  r) const
pure virtual
Returns
Register bit size corresponding to the specified Capstone register r. This function works even for the additional registers defined in translators and missing in Capstone (e.g. individual flag registers). Throws Capstone2LlvmIrError exception if register bit size not found.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< CInsn, CInsnOp >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm, cs_arm_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_x86, cs_x86_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm64, cs_arm64_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_mips, cs_mips_op >, and retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_ppc, cs_ppc_op >.

◆ getRegisterByteSize()

virtual uint32_t retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getRegisterByteSize ( uint32_t  r) const
pure virtual
Returns
Register byte size corresponding to the specified Capstone register r. This function works even for the additional registers defined in translators and missing in Capstone (e.g. individual flag registers). Throws Capstone2LlvmIrError exception if register byte size not found.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< CInsn, CInsnOp >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm, cs_arm_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_x86, cs_x86_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm64, cs_arm64_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_mips, cs_mips_op >, and retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_ppc, cs_ppc_op >.

◆ getRegisterName()

virtual std::string retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getRegisterName ( uint32_t  r) const
pure virtual
Returns
Register name corresponding to the specified Capstone register r. The name may differ from names used by the Capstone library. This function works even for the additional registers defined in translators and missing in Capstone (e.g. individual flag registers). Throws Capstone2LlvmIrError exception if register name not found.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< CInsn, CInsnOp >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm, cs_arm_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_x86, cs_x86_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm64, cs_arm64_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_mips, cs_mips_op >, and retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_ppc, cs_ppc_op >.

◆ getRegisterType()

virtual llvm::Type* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getRegisterType ( uint32_t  r) const
pure virtual
Returns
Register data type corresponding to the specified Capstone register r. This function works even for the additional registers defined in translators and missing in Capstone (e.g. individual flag registers). Throws Capstone2LlvmIrError exception if register data type not found.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< CInsn, CInsnOp >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm, cs_arm_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_x86, cs_x86_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm64, cs_arm64_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_mips, cs_mips_op >, and retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_ppc, cs_ppc_op >.

◆ getReturnFunction()

virtual llvm::Function* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::getReturnFunction ( ) const
pure virtual

◆ hasDelaySlot()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::hasDelaySlot ( uint32_t  id) const
pure virtual

◆ hasDelaySlotLikely()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::hasDelaySlotLikely ( uint32_t  id) const
pure virtual

◆ hasDelaySlotTypical()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::hasDelaySlotTypical ( uint32_t  id) const
pure virtual

◆ isAllowedBasicMode()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isAllowedBasicMode ( cs_mode  m)
pure virtual

Check if mode m is an allowed basic mode for the translator. This must be implemented in concrete classes, since it is architecture and translator specific.

Returns
True if mode is allowed, false otherwise.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslatorX86_impl, retdec::capstone2llvmir::Capstone2LlvmIrTranslatorPowerpc_impl, retdec::capstone2llvmir::Capstone2LlvmIrTranslatorMips_impl, retdec::capstone2llvmir::Capstone2LlvmIrTranslatorArm64_impl, and retdec::capstone2llvmir::Capstone2LlvmIrTranslatorArm_impl.

◆ isAllowedExtraMode()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isAllowedExtraMode ( cs_mode  m)
pure virtual

Check if mode m is an allowed extra mode for the translator. This must be implemented in concrete classes, since it is architecture and translator specific.

Returns
True if mode is allowed, false otherwise.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslatorX86_impl, retdec::capstone2llvmir::Capstone2LlvmIrTranslatorPowerpc_impl, retdec::capstone2llvmir::Capstone2LlvmIrTranslatorMips_impl, retdec::capstone2llvmir::Capstone2LlvmIrTranslatorArm64_impl, and retdec::capstone2llvmir::Capstone2LlvmIrTranslatorArm_impl.

◆ isAnyPseudoFunction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isAnyPseudoFunction ( llvm::Function *  f) const
pure virtual

◆ isAnyPseudoFunctionCall()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isAnyPseudoFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isBranchFunction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isBranchFunction ( llvm::Function *  f) const
pure virtual

◆ isBranchFunctionCall()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isBranchFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isBranchInstruction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isBranchInstruction ( cs_insn &  i) const
pure virtual

◆ isCallFunction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isCallFunction ( llvm::Function *  f) const
pure virtual

◆ isCallFunctionCall()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isCallFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isCallInstruction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isCallInstruction ( cs_insn &  i) const
pure virtual

◆ isCondBranchFunction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isCondBranchFunction ( llvm::Function *  f) const
pure virtual

◆ isCondBranchFunctionCall()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isCondBranchFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isCondBranchInstruction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isCondBranchInstruction ( cs_insn &  i) const
pure virtual
Returns
True if the Capstone instruction i is any kind of conditional branch instruction, translation of which would produce conditional branch pseudo call. False otherwise.
Note
This may not be always known for all architectures. Right now, it only works for x86 and MIPS. See isControlFlowInstruction() for more details.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< CInsn, CInsnOp >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm, cs_arm_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_x86, cs_x86_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm64, cs_arm64_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_mips, cs_mips_op >, and retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_ppc, cs_ppc_op >.

◆ isControlFlowInstruction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isControlFlowInstruction ( cs_insn &  i) const
pure virtual

Check if the translation of this instruction will/may produce any kind of control flow changing pseudo call (i.e. call/return/br/condbr pseudo function call).

For ARM, parameter i must include detail member - instruction cannot be disassembled with CS_OP_DETAIL = CS_OPT_OFF, or with CS_OP_SKIPDATA = CS_OPT_OFF.

For x86, MIPS, PowerPC, parameter i may not include detail member - instruction can be disassembled with CS_OP_DETAIL = CS_OPT_ON, or with CS_OP_SKIPDATA = CS_OPT_ON.

It is sometimes tricky to find this information without actually translating the instruction. On the other hand, for some architectures, it would be possible to give more detailed information (e.g. the kind of pseudo function call), sometimes even from instruction ID alone (i.e. cs_insn::id):

  • x86: All kinds of pseudo function calls can be recognized from the instruction ID alone.
  • mips: All kinds of pseudo function calls can be recognized from the instruction ID alone.
  • powerpc: Can determine if the instruction is control flow changing from the instruction ID alone. Hard/impossible to determine the type without detail and replicating the full analysis used in translation.
  • arm: Impossible to determine if the instruction is control flow changing from the instruction ID alone. Instructions may directly write the program counter - instruction details are needed. Instructions may be conditional.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< CInsn, CInsnOp >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm, cs_arm_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_x86, cs_x86_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm64, cs_arm64_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_mips, cs_mips_op >, and retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_ppc, cs_ppc_op >.

◆ isGeneratePseudoAsmFunctions()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isGeneratePseudoAsmFunctions ( ) const
pure virtual

◆ isIgnoreUnexpectedOperands()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isIgnoreUnexpectedOperands ( ) const
pure virtual

◆ isIgnoreUnhandledInstructions()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isIgnoreUnhandledInstructions ( ) const
pure virtual

◆ isInConditionBranchFunctionCall()

virtual llvm::BranchInst* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isInConditionBranchFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isInConditionCallFunctionCall()

virtual llvm::BranchInst* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isInConditionCallFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isInConditionCondBranchFunctionCall()

virtual llvm::BranchInst* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isInConditionCondBranchFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isInConditionReturnFunctionCall()

virtual llvm::BranchInst* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isInConditionReturnFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isPseudoAsmFunction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isPseudoAsmFunction ( llvm::Function *  f) const
pure virtual

◆ isPseudoAsmFunctionCall()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isPseudoAsmFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isRegister()

virtual llvm::GlobalVariable* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isRegister ( llvm::Value *  v) const
pure virtual

◆ isReturnFunction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isReturnFunction ( llvm::Function *  f) const
pure virtual

◆ isReturnFunctionCall()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isReturnFunctionCall ( llvm::CallInst *  c) const
pure virtual

◆ isReturnInstruction()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isReturnInstruction ( cs_insn &  i) const
pure virtual

◆ isSpecialAsm2LlvmInstr()

virtual llvm::StoreInst* retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isSpecialAsm2LlvmInstr ( llvm::Value *  v) const
pure virtual

◆ isSpecialAsm2LlvmMapGlobal()

virtual bool retdec::capstone2llvmir::Capstone2LlvmIrTranslator::isSpecialAsm2LlvmMapGlobal ( llvm::Value *  v) const
pure virtual

◆ modifyBasicMode()

virtual void retdec::capstone2llvmir::Capstone2LlvmIrTranslator::modifyBasicMode ( cs_mode  m)
pure virtual

Modify basic mode (e.g. CS_MODE_ARM to CS_MODE_THUMB). This must be implemented in concrete classes, so they can check if the requested mode is applicable. Not every basic mode can be used with every architecture. Translators for some architectures (e.g. CS_ARCH_X86) may not even allow switching between modes that is otherwise allowed by Capstone due to internal problems (e.g. different register environments between 16/32/64 x86 architectures).

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< CInsn, CInsnOp >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm, cs_arm_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_x86, cs_x86_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm64, cs_arm64_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_mips, cs_mips_op >, and retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_ppc, cs_ppc_op >.

◆ modifyExtraMode()

virtual void retdec::capstone2llvmir::Capstone2LlvmIrTranslator::modifyExtraMode ( cs_mode  m)
pure virtual

◆ setGeneratePseudoAsmFunctions()

virtual void retdec::capstone2llvmir::Capstone2LlvmIrTranslator::setGeneratePseudoAsmFunctions ( bool  f)
pure virtual

◆ setIgnoreUnexpectedOperands()

virtual void retdec::capstone2llvmir::Capstone2LlvmIrTranslator::setIgnoreUnexpectedOperands ( bool  f)
pure virtual

◆ setIgnoreUnhandledInstructions()

virtual void retdec::capstone2llvmir::Capstone2LlvmIrTranslator::setIgnoreUnhandledInstructions ( bool  f)
pure virtual

◆ translate()

virtual TranslationResult retdec::capstone2llvmir::Capstone2LlvmIrTranslator::translate ( const uint8_t *  bytes,
std::size_t  size,
retdec::common::Address  a,
llvm::IRBuilder<> &  irb,
std::size_t  count = 0,
bool  stopOnBranch = false 
)
pure virtual

Translate the given bytes.

Parameters
bytesBytes to translate.
sizeSize of the bytes buffer.
aMemory address where bytes are located.
irbLLVM IR builder used to create LLVM IR translation. Translated LLVM IR instructions are created at its current position.
countNumber of assembly instructions to translate, or 0 to translate them all.
stopOnBranchIf set, the translation aborts after any kind of branch is encountered (call, return, branch, conditional branch).
Returns
See TranslationResult structure.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< CInsn, CInsnOp >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm, cs_arm_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_x86, cs_x86_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm64, cs_arm64_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_mips, cs_mips_op >, and retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_ppc, cs_ppc_op >.

◆ translateOne()

virtual TranslationResultOne retdec::capstone2llvmir::Capstone2LlvmIrTranslator::translateOne ( const uint8_t *&  bytes,
std::size_t &  size,
retdec::common::Address a,
llvm::IRBuilder<> &  irb 
)
pure virtual

Translate one assembly instruction from the given bytes.

Parameters
bytesBytes to translate. This will be updated to point to the next instruction.
sizeSize of the bytes buffer. This will be updated to reflect bytes update.
aMemory address where bytes are located. This will be updated to point to the next instruction.
irbLLVM IR builder used to create LLVM IR translation. Translated LLVM IR instructions are created at its current position.
Returns
See TranslationResult structure.

Implemented in retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< CInsn, CInsnOp >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm, cs_arm_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_x86, cs_x86_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_arm64, cs_arm64_op >, retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_mips, cs_mips_op >, and retdec::capstone2llvmir::Capstone2LlvmIrTranslator_impl< cs_ppc, cs_ppc_op >.


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