ROSE  0.9.10.54
Engine.h
1 #ifndef ROSE_Partitioner2_Engine_H
2 #define ROSE_Partitioner2_Engine_H
3 
4 #include <BinaryLoader.h>
5 #include <boost/noncopyable.hpp>
6 #include <Disassembler.h>
7 #include <FileSystem.h>
8 #include <Partitioner2/Function.h>
9 #include <Partitioner2/Partitioner.h>
10 #include <Partitioner2/Utility.h>
11 #include <Progress.h>
12 #include <Sawyer/DistinctList.h>
13 
14 namespace Rose {
15 namespace BinaryAnalysis {
16 namespace Partitioner2 {
17 
101 class ROSE_DLL_API Engine: private boost::noncopyable {
102 public:
106  struct Settings {
113  private:
114  friend class boost::serialization::access;
115 
116  template<class S>
117  void serialize(S &s, unsigned version) {
118  s & loader & disassembler & partitioner & engine & astConstruction;
119  }
120  };
121 
123  // Internal data structures
125 private:
126  // Engine callback for handling instructions added to basic blocks. This is called when a basic block is discovered,
127  // before it's attached to a partitioner, so it shouldn't really be modifying any state in the engine, but rather only
128  // preparing the basic block to be processed.
129  class BasicBlockFinalizer: public BasicBlockCallback {
130  typedef Sawyer::Container::Map<rose_addr_t /*target*/, std::vector<rose_addr_t> /*sources*/> WorkList;
131  public:
132  static Ptr instance() { return Ptr(new BasicBlockFinalizer); }
133  virtual bool operator()(bool chain, const Args &args) ROSE_OVERRIDE;
134  private:
135  void fixFunctionReturnEdge(const Args&);
136  void fixFunctionCallEdges(const Args&);
137  void addPossibleIndeterminateEdge(const Args&);
138  };
139 
140  // Basic blocks that need to be worked on next. These lists are adjusted whenever a new basic block (or placeholder) is
141  // inserted or erased from the CFG.
142  class BasicBlockWorkList: public CfgAdjustmentCallback {
143  Sawyer::Container::DistinctList<rose_addr_t> pendingCallReturn_; // blocks that might need an E_CALL_RETURN edge
144  Sawyer::Container::DistinctList<rose_addr_t> processedCallReturn_; // call sites whose may-return was indeterminate
145  Sawyer::Container::DistinctList<rose_addr_t> finalCallReturn_; // indeterminate call sites awaiting final analysis
146  Sawyer::Container::DistinctList<rose_addr_t> undiscovered_; // undiscovered basic block list (last-in-first-out)
147  Engine *engine_; // engine to which this callback belongs
148  protected:
149  explicit BasicBlockWorkList(Engine *engine): engine_(engine) {}
150  public:
152  static Ptr instance(Engine *engine) { return Ptr(new BasicBlockWorkList(engine)); }
153  virtual bool operator()(bool chain, const AttachedBasicBlock &args) ROSE_OVERRIDE;
154  virtual bool operator()(bool chain, const DetachedBasicBlock &args) ROSE_OVERRIDE;
155  Sawyer::Container::DistinctList<rose_addr_t>& pendingCallReturn() { return pendingCallReturn_; }
156  Sawyer::Container::DistinctList<rose_addr_t>& processedCallReturn() { return processedCallReturn_; }
157  Sawyer::Container::DistinctList<rose_addr_t>& finalCallReturn() { return finalCallReturn_; }
158  Sawyer::Container::DistinctList<rose_addr_t>& undiscovered() { return undiscovered_; }
159  void moveAndSortCallReturn(const Partitioner&);
160  };
161 
162  // A work list providing constants from instructions that are part of the CFG.
163  class CodeConstants: public CfgAdjustmentCallback {
164  public:
166 
167  private:
168  std::set<rose_addr_t> toBeExamined_; // instructions waiting to be examined
169  std::set<rose_addr_t> wasExamined_; // instructions we've already examined
170  rose_addr_t inProgress_; // instruction that is currently in progress
171  std::vector<rose_addr_t> constants_; // constants for the instruction in progress
172 
173  protected:
174  CodeConstants(): inProgress_(0) {}
175 
176  public:
177  static Ptr instance() { return Ptr(new CodeConstants); }
178 
179  // Possibly insert more instructions into the work list when a basic block is added to the CFG
180  virtual bool operator()(bool chain, const AttachedBasicBlock &attached) ROSE_OVERRIDE;
181 
182  // Possibly remove instructions from the worklist when a basic block is removed from the CFG
183  virtual bool operator()(bool chain, const DetachedBasicBlock &detached) ROSE_OVERRIDE;
184 
185  // Return the next available constant if any.
186  Sawyer::Optional<rose_addr_t> nextConstant(const Partitioner &partitioner);
187  };
188 
190  // Data members
192 private:
193  Settings settings_; // Settings for the partitioner.
194  SgAsmInterpretation *interp_; // interpretation set by loadSpecimen
195  BinaryLoader *binaryLoader_; // how to remap, link, and fixup
196  Disassembler *disassembler_; // not ref-counted yet, but don't destroy it since user owns it
197  MemoryMap::Ptr map_; // memory map initialized by load()
198  BasicBlockWorkList::Ptr basicBlockWorkList_; // what blocks to work on next
199  CodeConstants::Ptr codeFunctionPointers_; // generates constants that are found in instruction ASTs
200  Progress::Ptr progress_; // optional progress reporting
201 
203  // Constructors
205 public:
208  : interp_(NULL), binaryLoader_(NULL), disassembler_(NULL), basicBlockWorkList_(BasicBlockWorkList::instance(this)),
209  progress_(Progress::instance()) {
210  init();
211  }
212 
214  explicit Engine(const Settings &settings)
215  : settings_(settings), interp_(NULL), binaryLoader_(NULL), disassembler_(NULL),
216  basicBlockWorkList_(BasicBlockWorkList::instance(this)), progress_(Progress::instance()) {
217  init();
218  }
219 
220  virtual ~Engine() {}
221 
223  // The very top-level use case
225 public:
250  SgAsmBlock* frontend(int argc, char *argv[],
251  const std::string &purpose, const std::string &description);
252  virtual SgAsmBlock* frontend(const std::vector<std::string> &args,
253  const std::string &purpose, const std::string &description);
256  // Basic top-level steps
259 public:
265  void reset();
266 
293  Sawyer::CommandLine::ParserResult parseCommandLine(int argc, char *argv[],
294  const std::string &purpose, const std::string &description) /*final*/;
295  virtual Sawyer::CommandLine::ParserResult parseCommandLine(const std::vector<std::string> &args,
296  const std::string &purpose, const std::string &description);
318  virtual SgAsmInterpretation* parseContainers(const std::vector<std::string> &fileNames);
319  SgAsmInterpretation* parseContainers(const std::string &fileName) /*final*/;
342  virtual MemoryMap::Ptr loadSpecimens(const std::vector<std::string> &fileNames = std::vector<std::string>());
343  MemoryMap::Ptr loadSpecimens(const std::string &fileName) /*final*/;
365  virtual Partitioner partition(const std::vector<std::string> &fileNames = std::vector<std::string>());
366  Partitioner partition(const std::string &fileName) /*final*/;
383  SgAsmBlock* buildAst(const std::vector<std::string> &fileNames = std::vector<std::string>()) /*final*/;
384  SgAsmBlock* buildAst(const std::string &fileName) /*final*/;
387  // Command-line parsing
389  //
390  // top-level: parseCommandLine
392 public:
394  virtual Sawyer::CommandLine::SwitchGroup loaderSwitches();
395 
397  virtual Sawyer::CommandLine::SwitchGroup disassemblerSwitches();
398 
400  virtual Sawyer::CommandLine::SwitchGroup partitionerSwitches();
401 
403  virtual Sawyer::CommandLine::SwitchGroup engineSwitches();
404 
406  virtual Sawyer::CommandLine::SwitchGroup astConstructionSwitches();
407 
409  static std::string specimenNameDocumentation();
410 
422  virtual Sawyer::CommandLine::Parser commandLineParser(const std::string &purpose, const std::string &description);
423 
430  virtual void checkSettings();
431 
433  // Container parsing
434  //
435  // top-level: parseContainers
437 public:
442  virtual bool isNonContainer(const std::string&);
443 
449  virtual bool areContainersParsed() const;
450 
452  // Load specimens
453  //
454  // top-level: loadSpecimens
456 public:
460  virtual bool areSpecimensLoaded() const;
461 
477  virtual BinaryLoader *obtainLoader(BinaryLoader *hint=NULL);
478 
484  virtual void loadContainers(const std::vector<std::string> &fileNames);
485 
490  virtual void loadNonContainers(const std::vector<std::string> &names);
491 
495  virtual void adjustMemoryMap();
496 
505  MemoryMap::Ptr memoryMap() const /*final*/ { return map_; }
506  virtual void memoryMap(const MemoryMap::Ptr &m) { map_ = m; }
510  // Disassembler
513 public:
530  virtual Disassembler* obtainDisassembler(Disassembler *hint=NULL);
534  // Partitioner high-level functions
536  //
537  // top-level: partition
539 public:
541  virtual void checkCreatePartitionerPrerequisites() const;
542 
549  virtual Partitioner createBarePartitioner();
550 
556  virtual Partitioner createGenericPartitioner();
557 
562  virtual Partitioner createTunedPartitioner();
563 
568  virtual Partitioner createPartitionerFromAst(SgAsmInterpretation*);
569 
574  virtual Partitioner createPartitioner();
575 
579  virtual void runPartitionerInit(Partitioner&);
580 
584  virtual void runPartitionerRecursive(Partitioner&);
585 
590  virtual void runPartitionerFinal(Partitioner&);
591 
597  virtual void runPartitioner(Partitioner&);
598 
599 
601  // Partitioner mid-level functions
602  //
603  // These are the functions called by the partitioner high-level stuff. These are sometimes overridden in subclasses,
604  // although it is more likely that the high-level stuff is overridden.
606 public:
611  virtual void labelAddresses(Partitioner&);
612 
616  virtual std::vector<DataBlock::Ptr> makeConfiguredDataBlocks(Partitioner&, const Configuration&);
617 
621  virtual std::vector<Function::Ptr> makeConfiguredFunctions(Partitioner&, const Configuration&);
622 
629  virtual std::vector<Function::Ptr> makeEntryFunctions(Partitioner&, SgAsmInterpretation*);
630 
637  virtual std::vector<Function::Ptr> makeErrorHandlingFunctions(Partitioner&, SgAsmInterpretation*);
638 
648  virtual std::vector<Function::Ptr> makeImportFunctions(Partitioner&, SgAsmInterpretation*);
649 
656  virtual std::vector<Function::Ptr> makeExportFunctions(Partitioner&, SgAsmInterpretation*);
657 
664  virtual std::vector<Function::Ptr> makeSymbolFunctions(Partitioner&, SgAsmInterpretation*);
665 
673  virtual std::vector<Function::Ptr> makeContainerFunctions(Partitioner&, SgAsmInterpretation*);
674 
681  virtual std::vector<Function::Ptr> makeInterruptVectorFunctions(Partitioner&, const AddressInterval &vector);
682 
687  virtual std::vector<Function::Ptr> makeUserFunctions(Partitioner&, const std::vector<rose_addr_t>&);
688 
695  virtual void discoverBasicBlocks(Partitioner&);
696 
706  virtual Function::Ptr makeNextDataReferencedFunction(const Partitioner&, rose_addr_t &startVa /*in,out*/);
707 
719  virtual Function::Ptr makeNextCodeReferencedFunction(const Partitioner&);
720 
727  virtual std::vector<Function::Ptr> makeCalledFunctions(Partitioner&);
728 
741  virtual std::vector<Function::Ptr> makeNextPrologueFunction(Partitioner&, rose_addr_t startVa);
742 
761  virtual std::vector<Function::Ptr>
762  makeFunctionFromInterFunctionCalls(Partitioner &partitioner, rose_addr_t &startVa /*in,out*/);
763 
770  virtual void discoverFunctions(Partitioner&);
771 
786  virtual std::set<rose_addr_t> attachDeadCodeToFunction(Partitioner&, const Function::Ptr&, size_t maxIterations=size_t(-1));
787 
795  virtual DataBlock::Ptr attachPaddingToFunction(Partitioner&, const Function::Ptr&);
796 
801  virtual std::vector<DataBlock::Ptr> attachPaddingToFunctions(Partitioner&);
802 
813  virtual size_t attachAllSurroundedCodeToFunctions(Partitioner&);
814 
822  virtual size_t attachSurroundedCodeToFunctions(Partitioner&);
823 
828  virtual void attachBlocksToFunctions(Partitioner&);
829 
836  virtual std::set<rose_addr_t> attachDeadCodeToFunctions(Partitioner&, size_t maxIterations=size_t(-1));
837 
847  virtual std::vector<DataBlock::Ptr> attachSurroundedDataToFunctions(Partitioner&);
848 
854  virtual void updateAnalysisResults(Partitioner&);
855 
856 
858  // Partitioner low-level functions
859  //
860  // These are functions that a subclass seldom overrides, and maybe even shouldn't override because of their complexity or
861  // the way the interact with one another.
863 public:
874  virtual bool makeNextCallReturnEdge(Partitioner&, boost::logic::tribool assumeCallReturns);
875 
881  virtual BasicBlock::Ptr makeNextBasicBlockFromPlaceholder(Partitioner&);
882 
897  virtual BasicBlock::Ptr makeNextBasicBlock(Partitioner&);
898 
899 
901  // Build AST
903 public:
904  // Used internally by ROSE's ::frontend disassemble instructions to build the AST that goes under each SgAsmInterpretation.
905  static void disassembleForRoseFrontend(SgAsmInterpretation*);
906 
907 
909  // Settings and properties
911 public:
918  const Settings& settings() const /*final*/ { return settings_; }
919  Settings& settings() /*final*/ { return settings_; }
930  bool exitOnError() const /*final*/ { return settings_.engine.exitOnError; }
931  virtual void exitOnError(bool b) { settings_.engine.exitOnError = b; }
939  Progress::Ptr progress() const /*final*/ { return progress_; }
940  virtual void progress(const Progress::Ptr &progress) { progress_ = progress; }
950  SgAsmInterpretation* interpretation() const /*final*/ { return interp_; }
951  virtual void interpretation(SgAsmInterpretation *interp) { interp_ = interp; }
960  BinaryLoader* binaryLoader() const /*final*/ { return binaryLoader_; }
961  virtual void binaryLoader(BinaryLoader *loader) { binaryLoader_ = loader; }
974  size_t deExecuteZerosThreshold() const /*final*/ { return settings_.loader.deExecuteZerosThreshold; }
975  virtual void deExecuteZerosThreshold(size_t n) { settings_.loader.deExecuteZerosThreshold = n; }
976  size_t deExecuteZerosLeaveAtFront() const /*final*/ { return settings_.loader.deExecuteZerosLeaveAtFront; }
977  virtual void deExecuteZerosLeaveAtFront(size_t n) { settings_.loader.deExecuteZerosLeaveAtFront = n; }
978  size_t deExecuteZerosLeaveAtBack() const /*final*/ { return settings_.loader.deExecuteZerosLeaveAtBack; }
979  virtual void deExecuteZerosLeaveAtBack(size_t n) { settings_.loader.deExecuteZerosLeaveAtBack = n; }
994  MemoryDataAdjustment memoryDataAdjustment() const /*final*/ { return settings_.loader.memoryDataAdjustment; }
995  virtual void memoryDataAdjustment(MemoryDataAdjustment x) { settings_.loader.memoryDataAdjustment = x; }
1005  bool memoryIsExecutable() const /*final*/ { return settings_.loader.memoryIsExecutable; }
1006  virtual void memoryIsExecutable(bool b) { settings_.loader.memoryIsExecutable = b; }
1018  bool linkObjectFiles() const /*final*/ { return settings_.loader.linkObjectFiles; }
1019  virtual void linkObjectFiles(bool b) { settings_.loader.linkObjectFiles = b; }
1031  bool linkStaticArchives() const /*final*/ { return settings_.loader.linkStaticArchives; }
1032  virtual void linkStaticArchives(bool b) { settings_.loader.linkStaticArchives = b; }
1043  const std::string& linkerCommand() const /*final*/ { return settings_.loader.linker; }
1044  virtual void linkerCommand(const std::string &cmd) { settings_.loader.linker = cmd; }
1053  Disassembler *disassembler() const /*final*/ { return disassembler_; }
1054  virtual void disassembler(Disassembler *d) { disassembler_ = d; }
1063  const std::string& isaName() const /*final*/ { return settings_.disassembler.isaName; }
1064  virtual void isaName(const std::string &s) { settings_.disassembler.isaName = s; }
1073  const std::vector<rose_addr_t>& startingVas() const /*final*/ { return settings_.partitioner.startingVas; }
1074  std::vector<rose_addr_t>& startingVas() /*final*/ { return settings_.partitioner.startingVas; }
1083  bool usingSemantics() const /*final*/ { return settings_.partitioner.base.usingSemantics; }
1084  virtual void usingSemantics(bool b) { settings_.partitioner.base.usingSemantics = b; }
1093  SemanticMemoryParadigm semanticMemoryParadigm() const /*final*/ { return settings_.partitioner.semanticMemoryParadigm; }
1094  virtual void semanticMemoryParadigm(SemanticMemoryParadigm p) { settings_.partitioner.semanticMemoryParadigm = p; }
1105  bool followingGhostEdges() const /*final*/ { return settings_.partitioner.followingGhostEdges; }
1106  virtual void followingGhostEdges(bool b) { settings_.partitioner.followingGhostEdges = b; }
1116  bool discontiguousBlocks() const /*final*/ { return settings_.partitioner.discontiguousBlocks; }
1117  virtual void discontiguousBlocks(bool b) { settings_.partitioner.discontiguousBlocks = b; }
1127  size_t maxBasicBlockSize() const /*final*/ { return settings_.partitioner.maxBasicBlockSize; }
1128  virtual void maxBasicBlockSize(size_t n) { settings_.partitioner.maxBasicBlockSize = n; }
1137  bool findingFunctionPadding() const /*final*/ { return settings_.partitioner.findingFunctionPadding; }
1138  virtual void findingFunctionPadding(bool b) { settings_.partitioner.findingFunctionPadding = b; }
1147  bool findingThunks() const /*final*/ { return settings_.partitioner.findingThunks; }
1148  virtual void findingThunks(bool b) { settings_.partitioner.findingThunks = b; }
1157  bool splittingThunks() const /*final*/ { return settings_.partitioner.splittingThunks; }
1158  virtual void splittingThunks(bool b) { settings_.partitioner.splittingThunks = b; }
1167  bool findingDeadCode() const /*final*/ { return settings_.partitioner.findingDeadCode; }
1168  virtual void findingDeadCode(bool b) { settings_.partitioner.findingDeadCode = b; }
1177  rose_addr_t peScramblerDispatcherVa() const /*final*/ { return settings_.partitioner.peScramblerDispatcherVa; }
1178  virtual void peScramblerDispatcherVa(rose_addr_t va) { settings_.partitioner.peScramblerDispatcherVa = va; }
1187  bool findingIntraFunctionCode() const /*final*/ { return settings_.partitioner.findingIntraFunctionCode; }
1188  virtual void findingIntraFunctionCode(bool b) { settings_.partitioner.findingIntraFunctionCode = b; }
1197  bool findingIntraFunctionData() const /*final*/ { return settings_.partitioner.findingIntraFunctionData; }
1198  virtual void findingIntraFunctionData(bool b) { settings_.partitioner.findingIntraFunctionData = b; }
1207  const AddressInterval& interruptVector() const /*final*/ { return settings_.partitioner.interruptVector; }
1208  virtual void interruptVector(const AddressInterval &i) { settings_.partitioner.interruptVector = i; }
1217  bool doingPostAnalysis() const /*final*/ { return settings_.partitioner.doingPostAnalysis; }
1218  virtual void doingPostAnalysis(bool b) { settings_.partitioner.doingPostAnalysis = b; }
1226  bool doingPostFunctionMayReturn() const /*final*/ { return settings_.partitioner.doingPostFunctionMayReturn; }
1227  virtual void doingPostFunctionMayReturn(bool b) { settings_.partitioner.doingPostFunctionMayReturn = b; }
1235  bool doingPostFunctionStackDelta() const /*final*/ { return settings_.partitioner.doingPostFunctionStackDelta; }
1236  virtual void doingPostFunctionStackDelta(bool b) { settings_.partitioner.doingPostFunctionStackDelta = b; }
1244  bool doingPostCallingConvention() const /*final*/ { return settings_.partitioner.doingPostCallingConvention; }
1245  virtual void doingPostCallingConvention(bool b) { settings_.partitioner.doingPostCallingConvention = b; }
1254  bool doingPostFunctionNoop() const /*final*/ { return settings_.partitioner.doingPostFunctionNoop; }
1255  virtual void doingPostFunctionNoop(bool b) { settings_.partitioner.doingPostFunctionNoop = b; }
1264  FunctionReturnAnalysis functionReturnAnalysis() const /*final*/ { return settings_.partitioner.functionReturnAnalysis; }
1265  virtual void functionReturnAnalysis(FunctionReturnAnalysis x) { settings_.partitioner.functionReturnAnalysis = x; }
1274  bool findingInterFunctionCalls() const /*final*/ { return settings_.partitioner.findingInterFunctionCalls; }
1275  virtual void findingInterFunctionCalls(bool b) { settings_.partitioner.findingInterFunctionCalls = b; }
1284  bool findingDataFunctionPointers() const /*final*/ { return settings_.partitioner.findingDataFunctionPointers; }
1285  virtual void findingDataFunctionPointers(bool b) { settings_.partitioner.findingDataFunctionPointers = b; }
1294  bool findingCodeFunctionPointers() const /*final*/ { return settings_.partitioner.findingCodeFunctionPointers; }
1295  virtual void findingCodeFunctionPointers(bool b) { settings_.partitioner.findingCodeFunctionPointers = b; }
1303  bool checkingCallBranch() const /*final*/ { return settings_.partitioner.base.checkingCallBranch; }
1304  virtual void checkingCallBranch(bool b) { settings_.partitioner.base.checkingCallBranch = b; }
1318  bool basicBlockSemanticsAutoDrop() const /*final*/ { return settings_.partitioner.base.basicBlockSemanticsAutoDrop; }
1319  void basicBlockSemanticsAutoDrop(bool b) { settings_.partitioner.base.basicBlockSemanticsAutoDrop = b; }
1327  const std::vector<std::string>& configurationNames() /*final*/ const { return settings_.engine.configurationNames; }
1328  std::vector<std::string>& configurationNames() /*final*/ { return settings_.engine.configurationNames; }
1336  bool namingConstants() const /*final*/ { return settings_.partitioner.namingConstants; }
1337  virtual void namingConstants(bool b) { settings_.partitioner.namingConstants = b; }
1345  bool namingStrings() const /*final*/ { return settings_.partitioner.namingStrings; }
1346  virtual void namingStrings(bool b) { settings_.partitioner.namingStrings = b; }
1355  bool demangleNames() const /*final*/ { return settings_.partitioner.demangleNames; }
1356  virtual void demangleNames(bool b) { settings_.partitioner.demangleNames = b; }
1365  bool astAllowEmptyGlobalBlock() const /*final*/ { return settings_.astConstruction.allowEmptyGlobalBlock; }
1366  virtual void astAllowEmptyGlobalBlock(bool b) { settings_.astConstruction.allowEmptyGlobalBlock = b; }
1375  bool astAllowFunctionWithNoBasicBlocks() const /*final*/ {
1376  return settings_.astConstruction.allowFunctionWithNoBasicBlocks;
1377  }
1378  virtual void astAllowFunctionWithNoBasicBlocks(bool b) {
1379  settings_.astConstruction.allowFunctionWithNoBasicBlocks = b;
1380  }
1389  bool astAllowEmptyBasicBlock() const /*final*/ { return settings_.astConstruction.allowEmptyBasicBlocks; }
1390  virtual void astAllowEmptyBasicBlock(bool b) { settings_.astConstruction.allowEmptyBasicBlocks = b; }
1402  bool astCopyAllInstructions() const /*final*/ { return settings_.astConstruction.copyAllInstructions; }
1403  virtual void astCopyAllInstructions(bool b) { settings_.astConstruction.copyAllInstructions = b; }
1406  // Internal stuff
1409 private:
1410  void init();
1411 };
1412 
1413 } // namespace
1414 } // namespace
1415 } // namespace
1416 
1417 #endif
size_t maxBasicBlockSize() const
Property: Maximum size for basic blocks.
Definition: Engine.h:1127
const Settings & settings() const
Property: All settings.
Definition: Engine.h:918
bool doingPostFunctionStackDelta() const
Property: Whether to run the function stack delta analysis.
Definition: Engine.h:1235
virtual void findingIntraFunctionCode(bool b)
Property: Whether to find intra-function code.
Definition: Engine.h:1188
virtual void linkObjectFiles(bool b)
Property: Link object files.
Definition: Engine.h:1019
virtual void memoryIsExecutable(bool b)
Property: Global adjustment to executability.
Definition: Engine.h:1006
virtual void disassembler(Disassembler *d)
Property: Disassembler.
Definition: Engine.h:1054
bool checkingCallBranch() const
Property: Whether to look for function calls used as branches.
Definition: Engine.h:1303
virtual void maxBasicBlockSize(size_t n)
Property: Maximum size for basic blocks.
Definition: Engine.h:1128
Settings for controling the engine behavior.
Definition: BasicTypes.h:367
virtual void namingStrings(bool b)
Property: Give names to string literal addresses.
Definition: Engine.h:1346
MemoryDataAdjustment
How the partitioner should globally treat memory.
Definition: BasicTypes.h:155
bool findingInterFunctionCalls() const
Property: Whether to search for function calls between exiting functions.
Definition: Engine.h:1274
Instruction basic block.
Progress::Ptr progress() const
Property: progress reporting.
Definition: Engine.h:939
Base class for adjusting basic blocks during discovery.
Definition: Modules.h:38
virtual void followingGhostEdges(bool b)
Property: Whether to follow ghost edges.
Definition: Engine.h:1106
virtual void interruptVector(const AddressInterval &i)
Property: Location of machine interrupt vector.
Definition: Engine.h:1208
virtual void astCopyAllInstructions(bool b)
Property: Whether to copy instructions when building the AST.
Definition: Engine.h:1403
bool namingStrings() const
Property: Give names to string literal addresses.
Definition: Engine.h:1345
bool findingDeadCode() const
Property: Whether to find dead code.
Definition: Engine.h:1167
virtual void findingCodeFunctionPointers(bool b)
Property: Whether to search existing instructions for function pointers.
Definition: Engine.h:1295
const std::vector< std::string > & configurationNames() const
Property: Configuration files.
Definition: Engine.h:1327
virtual void doingPostFunctionNoop(bool b)
Property: Whether to run no-op function analysis.
Definition: Engine.h:1255
Settings that control the disassembler.
Definition: BasicTypes.h:222
Base class for engines driving the partitioner.
Definition: Engine.h:101
Engine(const Settings &settings)
Construct engine with settings.
Definition: Engine.h:214
The result from parsing a command line.
bool namingConstants() const
Property: Give names to constants.
Definition: Engine.h:1336
Disassembler * disassembler() const
Property: Disassembler.
Definition: Engine.h:1053
virtual void exitOnError(bool b)
Property: Error handling.
Definition: Engine.h:931
virtual void peScramblerDispatcherVa(rose_addr_t va)
Property: PE-Scrambler dispatcher address.
Definition: Engine.h:1178
SemanticMemoryParadigm semanticMemoryParadigm() const
Property: Type of container for semantic memory.
Definition: Engine.h:1093
List of things to work on.
Definition: WorkLists.h:58
FunctionReturnAnalysis functionReturnAnalysis() const
Property: Whether to run the function may-return analysis.
Definition: Engine.h:1264
size_t deExecuteZerosLeaveAtBack() const
Property: when to remove execute permission from zero bytes.
Definition: Engine.h:978
const std::string & isaName() const
Property: Instruction set architecture name.
Definition: Engine.h:1063
virtual void findingIntraFunctionData(bool b)
Property: Whether to find intra-function data.
Definition: Engine.h:1198
Settings & settings()
Property: All settings.
Definition: Engine.h:919
A collection of related switch declarations.
MemoryDataAdjustment memoryDataAdjustment() const
Property: Global adjustments to memory map data access bits.
Definition: Engine.h:994
bool linkObjectFiles() const
Property: Link object files.
Definition: Engine.h:1018
virtual void findingDataFunctionPointers(bool b)
Property: Whether to search static data for function pointers.
Definition: Engine.h:1285
virtual void isaName(const std::string &s)
Property: Instruction set architecture name.
Definition: Engine.h:1064
virtual void memoryMap(const MemoryMap::Ptr &m)
Property: memory map.
Definition: Engine.h:506
Main namespace for the ROSE library.
Settings for loading specimens.
Definition: BasicTypes.h:170
Settings that control building the AST.
Definition: BasicTypes.h:69
bool followingGhostEdges() const
Property: Whether to follow ghost edges.
Definition: Engine.h:1105
bool demangleNames() const
Property: Demangle names.
Definition: Engine.h:1355
bool astAllowEmptyGlobalBlock() const
Property: Whether to allow empty global block in the AST.
Definition: Engine.h:1365
bool findingFunctionPadding() const
Property: Whether to find function padding.
Definition: Engine.h:1137
bool doingPostCallingConvention() const
Property: Whether to run calling-convention analysis.
Definition: Engine.h:1244
bool discontiguousBlocks() const
Property: Whether to allow discontiguous basic blocks.
Definition: Engine.h:1116
virtual void namingConstants(bool b)
Property: Give names to constants.
Definition: Engine.h:1337
bool findingIntraFunctionData() const
Property: Whether to find intra-function data.
Definition: Engine.h:1197
virtual void astAllowEmptyGlobalBlock(bool b)
Property: Whether to allow empty global block in the AST.
Definition: Engine.h:1366
bool memoryIsExecutable() const
Property: Global adjustment to executability.
Definition: Engine.h:1005
bool doingPostFunctionMayReturn() const
Property: Whether to run the function may-return analysis.
Definition: Engine.h:1226
virtual void doingPostFunctionStackDelta(bool b)
Property: Whether to run the function stack delta analysis.
Definition: Engine.h:1236
virtual void findingThunks(bool b)
Property: Whether to find thunk patterns.
Definition: Engine.h:1148
virtual void usingSemantics(bool b)
Property: Whether to use instruction semantics.
Definition: Engine.h:1084
virtual void findingFunctionPadding(bool b)
Property: Whether to find function padding.
Definition: Engine.h:1138
size_t deExecuteZerosLeaveAtFront() const
Property: when to remove execute permission from zero bytes.
Definition: Engine.h:976
bool astAllowFunctionWithNoBasicBlocks() const
Property: Whether to allow empty functions in the AST.
Definition: Engine.h:1375
virtual void astAllowEmptyBasicBlock(bool b)
Property: Whether to allow empty basic blocks in the AST.
Definition: Engine.h:1390
The parser for a program command line.
bool findingIntraFunctionCode() const
Property: Whether to find intra-function code.
Definition: Engine.h:1187
virtual void semanticMemoryParadigm(SemanticMemoryParadigm p)
Property: Type of container for semantic memory.
Definition: Engine.h:1094
virtual void interpretation(SgAsmInterpretation *interp)
Property: interpretation.
Definition: Engine.h:951
const AddressInterval & interruptVector() const
Property: Location of machine interrupt vector.
Definition: Engine.h:1207
Settings that control the engine partitioning.
Definition: BasicTypes.h:281
virtual void deExecuteZerosLeaveAtBack(size_t n)
Property: when to remove execute permission from zero bytes.
Definition: Engine.h:979
std::vector< std::string > & configurationNames()
Property: Configuration files.
Definition: Engine.h:1328
bool findingDataFunctionPointers() const
Property: Whether to search static data for function pointers.
Definition: Engine.h:1284
DisassemblerSettings disassembler
Settings for creating the disassembler.
Definition: Engine.h:108
SemanticMemoryParadigm
Organization of semantic memory.
Definition: BasicTypes.h:60
virtual void findingDeadCode(bool b)
Property: Whether to find dead code.
Definition: Engine.h:1168
bool findingCodeFunctionPointers() const
Property: Whether to search existing instructions for function pointers.
Definition: Engine.h:1294
virtual void deExecuteZerosThreshold(size_t n)
Property: when to remove execute permission from zero bytes.
Definition: Engine.h:975
FunctionReturnAnalysis
Controls whether the function may-return analysis runs.
Definition: BasicTypes.h:237
SgAsmInterpretation * interpretation() const
Property: interpretation.
Definition: Engine.h:950
virtual void checkingCallBranch(bool b)
Property: Whether to look for function calls used as branches.
Definition: Engine.h:1304
AstConstructionSettings astConstruction
Settings for constructing the AST.
Definition: Engine.h:111
bool astCopyAllInstructions() const
Property: Whether to copy instructions when building the AST.
Definition: Engine.h:1402
size_t deExecuteZerosThreshold() const
Property: when to remove execute permission from zero bytes.
Definition: Engine.h:974
virtual void demangleNames(bool b)
Property: Demangle names.
Definition: Engine.h:1356
bool doingPostAnalysis() const
Property: Whether to perform post-partitioning analysis steps.
Definition: Engine.h:1217
bool usingSemantics() const
Property: Whether to use instruction semantics.
Definition: Engine.h:1083
void basicBlockSemanticsAutoDrop(bool b)
Property: Automatically drop semantics for attached basic blocks.
Definition: Engine.h:1319
MemoryMap::Ptr memoryMap() const
Property: memory map.
Definition: Engine.h:505
bool exitOnError() const
Property: Error handling.
Definition: Engine.h:930
bool doingPostFunctionNoop() const
Property: Whether to run no-op function analysis.
Definition: Engine.h:1254
A general, thread-safe way to report progress made on some task.
Definition: Progress.h:164
virtual void splittingThunks(bool b)
Property: Whether to split thunk instructions into mini functions.
Definition: Engine.h:1158
virtual void astAllowFunctionWithNoBasicBlocks(bool b)
Property: Whether to allow empty functions in the AST.
Definition: Engine.h:1378
bool linkStaticArchives() const
Property: Link library archives.
Definition: Engine.h:1031
bool astAllowEmptyBasicBlock() const
Property: Whether to allow empty basic blocks in the AST.
Definition: Engine.h:1389
virtual void deExecuteZerosLeaveAtFront(size_t n)
Property: when to remove execute permission from zero bytes.
Definition: Engine.h:977
Base class for loading a static or dynamic object.
Definition: BinaryLoader.h:48
rose_addr_t peScramblerDispatcherVa() const
Property: PE-Scrambler dispatcher address.
Definition: Engine.h:1177
virtual void binaryLoader(BinaryLoader *loader)
Property: binary loader.
Definition: Engine.h:961
virtual void linkerCommand(const std::string &cmd)
Property: Linker command.
Definition: Engine.h:1044
virtual void findingInterFunctionCalls(bool b)
Property: Whether to search for function calls between exiting functions.
Definition: Engine.h:1275
PartitionerSettings partitioner
Settings for creating a partitioner.
Definition: Engine.h:109
LoaderSettings loader
Settings used during specimen loading.
Definition: Engine.h:107
virtual void doingPostCallingConvention(bool b)
Property: Whether to run calling-convention analysis.
Definition: Engine.h:1245
virtual void discontiguousBlocks(bool b)
Property: Whether to allow discontiguous basic blocks.
Definition: Engine.h:1117
bool findingThunks() const
Property: Whether to find thunk patterns.
Definition: Engine.h:1147
Partitions instructions into basic blocks and functions.
Definition: Partitioner.h:292
virtual void doingPostFunctionMayReturn(bool b)
Property: Whether to run the function may-return analysis.
Definition: Engine.h:1227
Virtual base class for instruction disassemblers.
Definition: Disassembler.h:41
Represents an interpretation of a binary container.
virtual void functionReturnAnalysis(FunctionReturnAnalysis x)
Property: Whether to run the function may-return analysis.
Definition: Engine.h:1265
EngineSettings engine
Settings that control engine behavior.
Definition: Engine.h:110
const std::vector< rose_addr_t > & startingVas() const
Property: Starting addresses for disassembly.
Definition: Engine.h:1073
bool basicBlockSemanticsAutoDrop() const
Property: Automatically drop semantics for attached basic blocks.
Definition: Engine.h:1318
virtual void linkStaticArchives(bool b)
Property: Link library archives.
Definition: Engine.h:1032
Container associating values with keys.
Definition: Sawyer/Map.h:64
std::vector< rose_addr_t > & startingVas()
Property: Starting addresses for disassembly.
Definition: Engine.h:1074
virtual void doingPostAnalysis(bool b)
Property: Whether to perform post-partitioning analysis steps.
Definition: Engine.h:1218
virtual void progress(const Progress::Ptr &progress)
Property: progress reporting.
Definition: Engine.h:940
BinaryLoader * binaryLoader() const
Property: binary loader.
Definition: Engine.h:960
Sawyer::SharedPointer< Progress > Ptr
Progress objects are reference counted.
Definition: Progress.h:167
virtual void memoryDataAdjustment(MemoryDataAdjustment x)
Property: Global adjustments to memory map data access bits.
Definition: Engine.h:995
Holds configuration information.
Definition: Config.h:210
const std::string & linkerCommand() const
Property: Linker command.
Definition: Engine.h:1043
bool splittingThunks() const
Property: Whether to split thunk instructions into mini functions.
Definition: Engine.h:1157