ROSE 0.11.145.147
Public Types | Public Member Functions | Protected Member Functions | List of all members
Rose::BinaryAnalysis::Architecture::X86 Class Reference

Description

Common base class for all x86 architectures.

Definition at line 12 of file Architecture/X86.h.

#include <Rose/BinaryAnalysis/Architecture/X86.h>

Inheritance diagram for Rose::BinaryAnalysis::Architecture::X86:
Inheritance graph
[legend]
Collaboration diagram for Rose::BinaryAnalysis::Architecture::X86:
Collaboration graph
[legend]

Public Types

using Ptr = X86Ptr
 
- Public Types inherited from Rose::BinaryAnalysis::Architecture::Base
using Ptr = BasePtr
 Reference counting pointer.
 
using ConstPtr = BaseConstPtr
 Reference counting pointer to const object.
 

Public Member Functions

virtual const CallingConvention::DictionarycallingConventions () const override
 Property: Calling convention definitions.
 
Sawyer::Container::Interval< size_t > bytesPerInstruction () const override
 Valid sizes for encoded machine instructions.
 
Alignment instructionAlignment () const override
 Alignment for encoded machine instructions.
 
std::string instructionMnemonic (const SgAsmInstruction *) const override
 Mnemonic for an instruction.
 
bool terminatesBasicBlock (SgAsmInstruction *) const override
 Determines whether the specified instruction normally terminates a basic block.
 
bool isUnknown (const SgAsmInstruction *) const override
 Returns true if the instruction is the special "unknown" instruction.
 
bool isFunctionCallFast (const std::vector< SgAsmInstruction * > &, rose_addr_t *target, rose_addr_t *ret) const override
 Returns true if the specified basic block looks like a function call.
 
bool isFunctionCallSlow (const std::vector< SgAsmInstruction * > &, rose_addr_t *target, rose_addr_t *ret) const override
 Returns true if the specified basic block looks like a function call.
 
bool isFunctionReturnFast (const std::vector< SgAsmInstruction * > &) const override
 Returns true if the specified basic block looks like a function return.
 
Sawyer::Optional< rose_addr_t > branchTarget (SgAsmInstruction *) const override
 Obtains the virtual address for a branching instruction.
 
AddressSet getSuccessors (SgAsmInstruction *, bool &complete) const override
 Control flow successors for a single instruction.
 
AddressSet getSuccessors (const std::vector< SgAsmInstruction * > &basicBlock, bool &complete, const MemoryMapPtr &initial_memory=MemoryMapPtr()) const override
 Control flow successors for a basic block.
 
Disassembler::BasePtr newInstructionDecoder () const override
 Construct and return a new instruction decoder.
 
Unparser::BasePtr newUnparser () const override
 Construct and return a new instruction unparser.
 
virtual InstructionSemantics::BaseSemantics::DispatcherPtr newInstructionDispatcher (const InstructionSemantics::BaseSemantics::RiscOperatorsPtr &) const override
 Construct and return a new instruction dispatcher.
 
virtual std::vector< Partitioner2::FunctionPrologueMatcherPtrfunctionPrologueMatchers (const Partitioner2::EnginePtr &) const override
 Instruction patterns matching function prologues.
 
virtual std::vector< Partitioner2::BasicBlockCallbackPtrbasicBlockCreationHooks (const Partitioner2::EnginePtr &) const override
 Architecture-specific basic block callbacks for partitioning.
 
- Public Member Functions inherited from Rose::BinaryAnalysis::Architecture::Base
const std::string & name () const
 Property: Architecture definition name.
 
ByteOrder::Endianness byteOrder () const
 Property: Byte order for memory.
 
virtual RegisterDictionaryPtr registerDictionary () const =0
 Property: Register dictionary.
 
virtual RegisterDictionaryPtr interruptDictionary () const
 Property: Interrupt dictionary.
 
virtual bool matchesName (const std::string &) const
 Tests whether this architecture matches a name.
 
virtual bool matchesHeader (SgAsmGenericHeader *) const
 Tests whether this architecture matches a file header.
 
bool instructionsCanOverlap () const
 Whether instructions can overlap in memory.
 
virtual std::string instructionDescription (const SgAsmInstruction *) const
 Description for an instruction.
 
const Sawyer::Optional< size_t > & registrationId () const
 Property: Registration identification number.
 
void registrationId (const Sawyer::Optional< size_t > &)
 Property: Registration identification number.
 
size_t bytesPerWord () const
 Property: Word size.
 
size_t bitsPerWord () const
 Property: Word size.
 
virtual std::string toString (const SgAsmInstruction *) const
 Unparse an instruction to a string.
 
virtual std::string toStringNoAddr (const SgAsmInstruction *) const
 Unparse an instruction to a string.
 
virtual bool isFunctionReturnSlow (const std::vector< SgAsmInstruction * > &) const
 Returns true if the specified basic block looks like a function return.
 
AddressSet getSuccessors (const std::vector< SgAsmInstruction * > &basicBlock, bool &complete) const
 Control flow successors for a basic block.
 

Protected Member Functions

 X86 (const std::string &name, size_t bytesPerWord)
 
CallingConvention::Definition::Ptr cc_cdecl (size_t bitsPerWord) const
 
CallingConvention::Definition::Ptr cc_stdcall (size_t bitsPerWord) const
 
CallingConvention::Definition::Ptr cc_fastcall (size_t bitsPerWord) const
 
- Protected Member Functions inherited from Rose::BinaryAnalysis::Architecture::Base
 Base (const std::string &name, size_t bytesPerWord, ByteOrder::Endianness byteOrder)
 
Ptr ptr ()
 
ConstPtr constPtr () const
 

Additional Inherited Members

- Protected Attributes inherited from Rose::BinaryAnalysis::Architecture::Base
Sawyer::Cached< RegisterDictionaryPtrregisterDictionary_
 
Sawyer::Cached< RegisterDictionaryPtrinterruptDictionary_
 
Sawyer::Cached< CallingConvention::DictionarycallingConventions_
 
Sawyer::Cached< Unparser::Base::PtrinsnToString_
 
Sawyer::Cached< Unparser::Base::PtrinsnToStringNoAddr_
 

Member Typedef Documentation

◆ Ptr

using Rose::BinaryAnalysis::Architecture::X86::Ptr = X86Ptr

Definition at line 14 of file Architecture/X86.h.

Member Function Documentation

◆ callingConventions()

virtual const CallingConvention::Dictionary & Rose::BinaryAnalysis::Architecture::X86::callingConventions ( ) const
overridevirtual

Property: Calling convention definitions.

Returns a list of calling convention definitions used by this architecture. Since definitions are generally not modified, it is permissible for this function to return the same definitions every time it's called. The list can be constructed on the first call.

The default implementation returns an empty list.

Thread safety: Thread safe.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.

Reimplemented in Rose::BinaryAnalysis::Architecture::Amd64.

◆ bytesPerInstruction()

Sawyer::Container::Interval< size_t > Rose::BinaryAnalysis::Architecture::X86::bytesPerInstruction ( ) const
overridevirtual

Valid sizes for encoded machine instructions.

Returns the range of valid sizes for encoded machine instructions. For instance, an x86 instruction can be from one to 15 bytes in length, but a PowerPC PPC32 instruction is always exactly 4 bytes.

Implements Rose::BinaryAnalysis::Architecture::Base.

◆ instructionAlignment()

Alignment Rose::BinaryAnalysis::Architecture::X86::instructionAlignment ( ) const
overridevirtual

Alignment for encoded machine instructions.

Implements Rose::BinaryAnalysis::Architecture::Base.

◆ instructionMnemonic()

std::string Rose::BinaryAnalysis::Architecture::X86::instructionMnemonic ( const SgAsmInstruction ) const
overridevirtual

Mnemonic for an instruction.

Returns the mnemonic for a particular instruction.

Thread safety: Thread safe.

Implements Rose::BinaryAnalysis::Architecture::Base.

◆ terminatesBasicBlock()

bool Rose::BinaryAnalysis::Architecture::X86::terminatesBasicBlock ( SgAsmInstruction ) const
overridevirtual

Determines whether the specified instruction normally terminates a basic block.

The analysis generally only looks at the individual instruction and therefore is not very sophisticated. For instance, a conditional branch will always terminate a basic block by this method even if its condition is opaque. The instruction argument must not be a null pointer and must be valid for this architecture.

Thread safety: Thread safe.

Implements Rose::BinaryAnalysis::Architecture::Base.

◆ isUnknown()

bool Rose::BinaryAnalysis::Architecture::X86::isUnknown ( const SgAsmInstruction ) const
overridevirtual

Returns true if the instruction is the special "unknown" instruction.

Each instruction architecture in ROSE defines an "unknown" instruction to be used when the disassembler is unable to create a real instruction. This can happen, for instance, if the bit pattern does not represent a valid instruction for the architecture. The instruction must not be a null pointer, and must be valid for this architecture.

Thread safety: Thread safe.

Implements Rose::BinaryAnalysis::Architecture::Base.

◆ isFunctionCallFast()

bool Rose::BinaryAnalysis::Architecture::X86::isFunctionCallFast ( const std::vector< SgAsmInstruction * > &  ,
rose_addr_t *  target,
rose_addr_t *  ret 
) const
overridevirtual

Returns true if the specified basic block looks like a function call.

If the basic block looks like a function call then this method returns true. If (and only if) the target address is known (i.e., the address of the called function) then target is set to this address (otherwise target is unmodified). If the return address is known or can be guessed, then return_va is initialized to the return address, which is normally the fall-through address of the last instruction; otherwise the return_va is unmodified.

The "fast" and "slow" versions differ only in what kind of anlysis they do. The "fast" version typically looks only at instruction patterns while the slow version might incur more expense by looking at instruction semantics.

The base implementation of the fast method always returns false. The base implementation of the slow method just calls the fast method.

Thread safety: Thread safe.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.

◆ isFunctionCallSlow()

bool Rose::BinaryAnalysis::Architecture::X86::isFunctionCallSlow ( const std::vector< SgAsmInstruction * > &  ,
rose_addr_t *  target,
rose_addr_t *  ret 
) const
overridevirtual

Returns true if the specified basic block looks like a function call.

If the basic block looks like a function call then this method returns true. If (and only if) the target address is known (i.e., the address of the called function) then target is set to this address (otherwise target is unmodified). If the return address is known or can be guessed, then return_va is initialized to the return address, which is normally the fall-through address of the last instruction; otherwise the return_va is unmodified.

The "fast" and "slow" versions differ only in what kind of anlysis they do. The "fast" version typically looks only at instruction patterns while the slow version might incur more expense by looking at instruction semantics.

The base implementation of the fast method always returns false. The base implementation of the slow method just calls the fast method.

Thread safety: Thread safe.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.

◆ isFunctionReturnFast()

bool Rose::BinaryAnalysis::Architecture::X86::isFunctionReturnFast ( const std::vector< SgAsmInstruction * > &  ) const
overridevirtual

Returns true if the specified basic block looks like a function return.

The "fast" and "slow" versions differ only in what kind of anlysis they do. The "fast" version typically looks only at instruction patterns while the slow version might incur more expense by looking at instruction semantics.

The base implementaiton of the fast method always returns false. The base implementation of the slow method just calls the fast method.

Thread safety: Thread safe.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.

◆ branchTarget()

Sawyer::Optional< rose_addr_t > Rose::BinaryAnalysis::Architecture::X86::branchTarget ( SgAsmInstruction ) const
overridevirtual

Obtains the virtual address for a branching instruction.

Returns the branch target address if the specified instruction is a branching instruction and the target is known; otherwise returns nothing.

The default implementation returns nothing.

Thread safety: Thread safe.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.

◆ getSuccessors() [1/2]

AddressSet Rose::BinaryAnalysis::Architecture::X86::getSuccessors ( SgAsmInstruction ,
bool &  complete 
) const
overridevirtual

Control flow successors for a single instruction.

The return value does not consider neighboring instructions, and therefore is quite naive. It returns only the information it can glean from this single instruction. If the returned set of virtual instructions is fully known then the complete argument will be set to true, otherwise false. The instruction must not be null, and must be valid for this architecture.

The default implementation always returns an empty set and clears complete.

Thread safety: Thread saafe.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.

◆ getSuccessors() [2/2]

AddressSet Rose::BinaryAnalysis::Architecture::X86::getSuccessors ( const std::vector< SgAsmInstruction * > &  basicBlock,
bool &  complete,
const MemoryMapPtr initial_memory = MemoryMapPtr() 
) const
overridevirtual

Control flow successors for a basic block.

The basicBlock argument is a vector of instructions that is assumed to be a basic block that is entered only at the first instruction and exits only at the last instruction. A memory map can supply initial values for the analysis' memory state. The return value is a set of control flow successor virtual addresses, and the complete argument return value indicates whether the returned set is known to be complete (aside from interrupts, faults, etc).

The default implementation calls the single-instruction version, so architecture-specific subclasses might want to override this to do something more sophisticated. However, if the basic block is empty then this function instead returns an empty set and sets complete to true.

Thread safety: Thread safe.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.

◆ newInstructionDecoder()

Disassembler::BasePtr Rose::BinaryAnalysis::Architecture::X86::newInstructionDecoder ( ) const
overridevirtual

Construct and return a new instruction decoder.

Returns a new decoder for this architecture if possible, otherwise a null pointer.

Thread safety: Thread safe.

Implements Rose::BinaryAnalysis::Architecture::Base.

◆ newUnparser()

Unparser::BasePtr Rose::BinaryAnalysis::Architecture::X86::newUnparser ( ) const
overridevirtual

Construct and return a new instruction unparser.

An unparser is responsible for generating pseudo assembly listings.

Thread safety: Thread safe.

Implements Rose::BinaryAnalysis::Architecture::Base.

◆ newInstructionDispatcher()

virtual InstructionSemantics::BaseSemantics::DispatcherPtr Rose::BinaryAnalysis::Architecture::X86::newInstructionDispatcher ( const InstructionSemantics::BaseSemantics::RiscOperatorsPtr ) const
overridevirtual

Construct and return a new instruction dispatcher.

The dispatcher knows the semantics for instructions, but not the low-level operators (arithmetic, memory I/O, etc), nor the domain (concrete, symbolic, etc) on which those operators operate. These other things are supplied by the argument, which also points to the states that are modified by executing the instructions.

The default implementation returns a null pointer, signifying that instruction semantics are not known.

Thread safety: Thread safe.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.

◆ functionPrologueMatchers()

virtual std::vector< Partitioner2::FunctionPrologueMatcherPtr > Rose::BinaryAnalysis::Architecture::X86::functionPrologueMatchers ( const Partitioner2::EnginePtr ) const
overridevirtual

Instruction patterns matching function prologues.

Returns a list of matchers that match sequences of instructions that are often generated by compilers as part of instruction prologues.

The default implementation returns an empty list.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.

◆ basicBlockCreationHooks()

virtual std::vector< Partitioner2::BasicBlockCallbackPtr > Rose::BinaryAnalysis::Architecture::X86::basicBlockCreationHooks ( const Partitioner2::EnginePtr ) const
overridevirtual

Architecture-specific basic block callbacks for partitioning.

Returns a list of basic block callbacks used by the partitioner during disassembly.

The default implementation returns an empty list.

Reimplemented from Rose::BinaryAnalysis::Architecture::Base.


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