ROSE
0.11.131.0
|
Engine for Java Virtual Machine (JVM) specimens.
This engine is reponsible for creating a partitioner for a specimen that has byte code for the Java Virtual Machine.
This engine provides an instance static member function that instantiates an engine of this type on the heap and returns a shared-ownership pointer to the instance. Refer to the base class, Partitioner2::Engine, to learn how to instantiate engines from factories.
Definition at line 20 of file EngineJvm.h.
#include <Rose/BinaryAnalysis/Partitioner2/EngineJvm.h>
Classes | |
class | Exception |
Errors from the engine. More... | |
Public Types | |
using | Ptr = EngineJvmPtr |
Shared ownership pointer. More... | |
![]() | |
using | Ptr = EnginePtr |
Shared ownership pointer. More... | |
Public Member Functions | |
EngineJvm ()=delete | |
Default constructor. More... | |
EngineJvm (const EngineJvm &)=delete | |
EngineJvm & | operator= (const EngineJvm &)=delete |
virtual bool | matchFactory (const std::vector< std::string > &specimen) const override |
virtual EnginePtr | instanceFromFactory (const Settings &) override |
virtual std::pair< std::string, std::string > | specimenNameDocumentation () override |
virtual SgAsmBlock * | frontend (const std::vector< std::string > &args, const std::string &purpose, const std::string &description) override |
Most basic usage of the partitioner. More... | |
virtual SgAsmInterpretation * | parseContainers (const std::vector< std::string > &fileNames) override |
Parse specimen binary containers. More... | |
virtual bool | isNonContainer (const std::string &) override |
Determine whether a specimen name is a non-container. More... | |
virtual bool | areContainersParsed () const override |
Returns true if containers are parsed. More... | |
virtual bool | areSpecimensLoaded () const override |
Returns true if specimens are loaded. More... | |
virtual MemoryMapPtr | loadSpecimens (const std::vector< std::string > &fileNames=std::vector< std::string >()) override |
Load and/or link interpretation. More... | |
virtual PartitionerPtr | partition (const std::vector< std::string > &fileNames=std::vector< std::string >()) override |
Partition instructions into basic blocks and functions. More... | |
virtual void | checkCreatePartitionerPrerequisites () const override |
Check that we have everything necessary to create a partitioner. More... | |
PartitionerPtr | createJvmTunedPartitioner () |
Create a partitioner for JVM. More... | |
virtual PartitionerPtr | createPartitioner () override |
Create partitioner. More... | |
virtual void | runPartitionerInit (const PartitionerPtr &) override |
Finds interesting things to work on initially. More... | |
virtual void | runPartitionerRecursive (const PartitionerPtr &) override |
Runs the recursive part of partioning. More... | |
virtual void | runPartitionerFinal (const PartitionerPtr &) override |
Runs the final parts of partitioning. More... | |
virtual void | discoverBasicBlocks (const PartitionerPtr &, const ByteCode::Method *) |
Discover as many basic blocks as possible. More... | |
virtual void | discoverFunctions (const PartitionerPtr &, const ByteCode::Class *) |
Discover as many functions as possible. More... | |
virtual SgAsmBlock * | buildAst (const std::vector< std::string > &fileNames=std::vector< std::string >()) override |
Obtain an abstract syntax tree. More... | |
const std::string & | isaName () const |
Property: Instruction set architecture name. More... | |
virtual void | isaName (const std::string &) |
Property: Instruction set architecture name. More... | |
const std::vector< rose_addr_t > & | functionStartingVas () const |
Property: Starting addresses for disassembly. More... | |
std::vector< rose_addr_t > & | functionStartingVas () |
Property: Starting addresses for disassembly. More... | |
![]() | |
SharedObject () | |
Default constructor. More... | |
SharedObject (const SharedObject &) | |
Copy constructor. More... | |
virtual | ~SharedObject () |
Virtual destructor. More... | |
SharedObject & | operator= (const SharedObject &) |
Assignment. More... | |
![]() | |
SharedPointer< Engine > | sharedFromThis () |
Create a shared pointer from this . More... | |
SharedPointer< const Engine > | sharedFromThis () const |
Create a shared pointer from this . More... | |
Static Public Member Functions | |
static Ptr | instance (const Settings &) |
Allocating constructor with settings. More... | |
static Ptr | factory () |
Allocate a factory. More... | |
Protected Member Functions | |
EngineJvm (const Settings &settings) | |
virtual SgProject * | roseFrontendReplacement (const std::vector< boost::filesystem::path > &fileNames) override |
![]() | |
Engine ()=delete | |
Default constructor. More... | |
Engine (const Engine &)=delete | |
Engine & | operator= (const Engine &)=delete |
Engine (const std::string &name, const Settings &settings) | |
Allocating instance constructors are implemented by the non-abstract subclasses. More... | |
Shared ownership pointer.
Definition at line 23 of file EngineJvm.h.
|
delete |
Default constructor.
Constructor is deleted and class noncopyable.
Allocating constructor with settings.
|
static |
Allocate a factory.
|
overridevirtual |
Most basic usage of the partitioner.
This method does everything from parsing the command-line to generating an abstract syntax tree. If all is successful, then an abstract syntax tree is returned. The return value is a SgAsmBlock node that contains all the detected functions. If the specimen consisted of an ELF or PE container then the parent nodes of the returned AST will lead eventually to an SgProject node.
The command-line can be provided as a typical argc
and argv
pair, or as a vector of arguments. In the latter case, the vector should not include argv[0]
or argv[argc]
(which is always a null pointer).
The command-line supports a "--help" (or "-h") switch to describe all other switches and arguments, essentially generating output like a Unix man(1) page.
The purpose
should be a single line string that will be shown in the title of the man page and should not start with an upper-case letter, a hyphen, white space, or the name of the command. E.g., a disassembler tool might specify the purpose as "disassembles a binary specimen".
The description
is a full, multi-line description written in the Sawyer markup language where "@" characters have special meaning.
If an std::runtime_exception
occurs and the exitOnError property is set, then the exception is caught, its text is emitted to the partitioner's fatal error stream, and exit(1)
is invoked.
|
overridevirtual |
Parse specimen binary containers.
Parses the ELF and PE binary containers to create an abstract syntax tree (AST). If fileNames
contains names that are recognized as raw data or other non-containers then they are skipped over at this stage but processed during the loadSpecimens stage.
This method tries to allocate a disassembler if none is set and an ISA name is specified in the settings, otherwise the disassembler is chosen later. It also resets the interpretation to be the return value (see below), and clears the memory map.
Returns a binary interpretation (perhaps one of many). ELF files have only one interpretation; PE files have a DOS and a PE interpretation and this method will return the PE interpretation. The user may, at this point, select a different interpretation. If the list of names has nothing suitable for ROSE's frontend
function (the thing that does the container parsing) then the null pointer is returned.
If an std::runtime_exception
occurs and the exitOnError property is set, then the exception is caught, its text is emitted to the partitioner's fatal error stream, and exit(1)
is invoked.
|
overridevirtual |
Determine whether a specimen name is a non-container.
Certain strings are recognized as special instructions for how to adjust a memory map and are not intended to be passed to ROSE's frontend
function. This predicate returns true for such strings.
|
overridevirtual |
Returns true if containers are parsed.
Specifically, returns true if the engine has a non-null interpretation. If it has a null interpretation then parseContainers might have already been called but no binary containers specified, in which case calling it again with the same file names will have no effect.
|
overridevirtual |
Returns true if specimens are loaded.
Specifically, returns true if the memory map is non-empty.
|
overridevirtual |
Load and/or link interpretation.
Loads and/or links the engine's interpretation according to the engine's binary loader with these steps:
Returns a reference to the engine's memory map.
If an std::runtime_exception
occurs and the exitOnError property is set, then the exception is caught, its text is emitted to the partitioner's fatal error stream, and exit(1)
is invoked.
|
overridevirtual |
Partition instructions into basic blocks and functions.
Disassembles and organizes instructions into basic blocks and functions with these steps:
Returns the partitioner that was used and which contains the results.
If an std::runtime_exception
occurs and the exitOnError property is set, then the exception is caught, its text is emitted to the partitioner's fatal error stream, and exit(1)
is invoked.
|
overridevirtual |
Check that we have everything necessary to create a partitioner.
PartitionerPtr Rose::BinaryAnalysis::Partitioner2::EngineJvm::createJvmTunedPartitioner | ( | ) |
Create a partitioner for JVM.
Returns a partitioner that is tuned to operate on a JVM instruction set architecture. The engine must have disassembler (if doDisassemble property is set) and memoryMap properties assigned already, either explicitly or as the result of earlier steps.
|
overridevirtual |
Create partitioner.
This is the method usually called to create a new partitioner. The base class just calls createTunedPartitioner.
|
overridevirtual |
Finds interesting things to work on initially.
Seeds the partitioner with addresses and functions where recursive disassembly should begin.
|
overridevirtual |
Runs the recursive part of partioning.
This is the long-running guts of the partitioner.
|
overridevirtual |
Runs the final parts of partitioning.
This does anything necessary after the main part of partitioning is finished. For instance, it might give names to some functions that don't have names yet.
|
virtual |
Discover as many basic blocks as possible.
Processes the "undiscovered" work list until the list becomes empty. This list is the list of basic block placeholders for which no attempt has been made to discover instructions. This method implements a recursive descent disassembler, although it does not process the control flow edges in any particular order. Subclasses are expected to override this to implement a more directed approach to discovering basic blocks.
|
virtual |
Discover as many functions as possible.
Discover as many functions as possible by discovering as many basic blocks as possible (discoverBasicBlocks), Each time we run out of basic blocks to try, we look for another function prologue pattern at the lowest possible address and then recursively discover more basic blocks. When this procedure is exhausted a call to attachBlocksToFunctions tries to attach each basic block to a function.
|
overridevirtual |
Obtain an abstract syntax tree.
Constructs a new abstract syntax tree (AST) from partitioner information with these steps:
If an std::runtime_exception
occurs and the exitOnError property is set, then the exception is caught, its text is emitted to the partitioner's fatal error stream, and exit(1)
is invoked.
const std::string& Rose::BinaryAnalysis::Partitioner2::EngineJvm::isaName | ( | ) | const |
Property: Instruction set architecture name.
The instruction set architecture name is used to obtain a disassembler and overrides the disassembler that would otherwise be found by examining the binary container.
|
virtual |
Property: Instruction set architecture name.
The instruction set architecture name is used to obtain a disassembler and overrides the disassembler that would otherwise be found by examining the binary container.
const std::vector<rose_addr_t>& Rose::BinaryAnalysis::Partitioner2::EngineJvm::functionStartingVas | ( | ) | const |
Property: Starting addresses for disassembly.
This is a list of addresses where functions will be created in addition to those functions discovered by examining the binary container.
std::vector<rose_addr_t>& Rose::BinaryAnalysis::Partitioner2::EngineJvm::functionStartingVas | ( | ) |
Property: Starting addresses for disassembly.
This is a list of addresses where functions will be created in addition to those functions discovered by examining the binary container.