1 #ifndef ROSE_Partitioner2_BasicTypes_H
2 #define ROSE_Partitioner2_BasicTypes_H
4 #include <boost/serialization/access.hpp>
5 #include <boost/serialization/nvp.hpp>
6 #include <string>
7 #include <vector>
9 // Define this as one if you want extra invariant checks that are quite expensive, or define as zero. This only makes a
10 // difference if NDEBUG and SAWYER_NDEBUG are both undefined--if either one of them are defined then no expensive (or
11 // inexpensive) checks are performed.
14 namespace Rose {
15 namespace BinaryAnalysis {
16 namespace Partitioner2 {
19 enum VertexType {
27 };
30 enum EdgeType {
51 };
54 enum Confidence {
57 };
63 };
104 private:
105  friend class boost::serialization::access;
107  template<class S>
108  void serialize(S &s, unsigned version) {
110  }
112 public:
116  copyAllInstructions(true) {}
124  s.allowEmptyGlobalBlock = false;
126  s.allowEmptyBasicBlocks = false;
127  s.copyAllInstructions = true;
128  return s;
129  }
138  s.allowEmptyGlobalBlock = true;
140  s.allowEmptyBasicBlocks = true;
141  s.copyAllInstructions = true; // true keeps the AST a tree instead of a lattice
142  return s;
143  }
144 };
147 // Settings. All settings must act like properties, which means the following:
148 // 1. Each setting must have a name that does not begin with a verb.
149 // 2. Each setting must have a command-line switch to manipulate it.
150 // 3. Each setting must have a method that queries the property (same name as the property and taking no arguments).
151 // 4. Each setting must have a modifier method (same name as property but takes a value and returns void)
165 };
197 private:
198  friend class boost::serialization::access;
200  template<class S>
201  void serialize(S &s, unsigned version) {
204  }
205 };
211  std::string isaName;
215 private:
216  friend class boost::serialization::access;
218  template<class S>
219  void serialize(S &s, unsigned version) {
220  s & isaName;
221  }
222 };
234 };
247 private:
248  friend class boost::serialization::access;
250  template<class S>
251  void serialize(S &s, const unsigned /*version*/) {
252  s & BOOST_SERIALIZATION_NVP(usingSemantics);
253  s & BOOST_SERIALIZATION_NVP(checkingCallBranch);
254  s & BOOST_SERIALIZATION_NVP(basicBlockSemanticsAutoDrop);
255  }
257 public:
260 };
271  std::vector<rose_addr_t> startingVas;
308 private:
309  friend class boost::serialization::access;
311  template<class S>
312  void serialize(S &s, unsigned version) {
313  s & base;
314  s & startingVas;
317  s & maxBasicBlockSize;
319  s & findingDeadCode;
324  s & interruptVector;
325  s & doingPostAnalysis;
333  s & findingThunks;
334  s & splittingThunks;
336  s & namingConstants;
337  s & namingStrings;
338  }
340 public:
348  namingStrings(true), demangleNames(true) {}
349 };
356  std::vector<std::string> configurationNames;
357  bool exitOnError;
360  : exitOnError(true) {}
362 private:
363  friend class boost::serialization::access;
365  template<class S>
366  void serialize(S &s, unsigned version) {
367  s & configurationNames;
368  s & exitOnError;
369  }
370 };
372 // Additional declarations w/out definitions yet.
373 class Partitioner;
374 class Function;
376 class BasicBlock;
378 class DataBlock;
381 } // namespace
382 } // namespace
383 } // namespace
385 #endif
bool findingInterFunctionCalls
Look for function calls between functions.
Definition: BasicTypes.h:291
Edge is a function call transfer.
Definition: BasicTypes.h:42
bool splittingThunks
Split thunks into their own separate functions.
Definition: BasicTypes.h:302
bool memoryIsExecutable
Determines whether all of memory should be made executable.
Definition: BasicTypes.h:186
Settings for controling the engine behavior.
Definition: BasicTypes.h:355
std::vector< rose_addr_t > startingVas
Addresses at which to start recursive disassembly.
Definition: BasicTypes.h:271
How the partitioner should globally treat memory.
Definition: BasicTypes.h:155
bool findingDataFunctionPointers
Look for function pointers in static data.
Definition: BasicTypes.h:299
Assume a function returns if the may-return analysis cannot decide whether it may return...
Definition: BasicTypes.h:226
std::string isaName
Name of the instruction set architecture.
Definition: BasicTypes.h:211
bool doingPostFunctionStackDelta
Run function-stack-delta analysis if doingPostAnalysis is set?
Definition: BasicTypes.h:295
Partitioner control flow edge types.
Definition: BasicTypes.h:30
rose_addr_t peScramblerDispatcherVa
Run the PeDescrambler module if non-zero.
Definition: BasicTypes.h:288
Settings that control the disassembler.
Definition: BasicTypes.h:210
Treat all memory as if it were initialized.
Definition: BasicTypes.h:158
size_t deExecuteZerosLeaveAtBack
Number of bytes at the end of each zero area to leave unaffected.
Definition: BasicTypes.h:180
bool copyAllInstructions
Whether to allow shared instructions in the AST.
Definition: BasicTypes.h:102
Special vertex destination for indeterminate edges.
Definition: BasicTypes.h:22
static AstConstructionSettings permissive()
Default permissive settings.
Definition: BasicTypes.h:136
Settings that directly control a partitioner.
Definition: BasicTypes.h:239
bool doingPostFunctionNoop
Find and name functions that are effectively no-ops.
Definition: BasicTypes.h:297
Assume that all functions return without ever running the may-return analysis.
Definition: BasicTypes.h:230
bool findingIntraFunctionCode
Suck up unused addresses as intra-function code.
Definition: BasicTypes.h:289
bool followingGhostEdges
Should ghost edges be followed during disassembly? A ghost edge is a CFG edge that is apparent from t...
Definition: BasicTypes.h:274
bool doingPostCallingConvention
Run calling-convention analysis if doingPostAnalysis is set?
Definition: BasicTypes.h:296
Settings for loading specimens.
Definition: BasicTypes.h:170
Partitioner control flow vertex types.
Definition: BasicTypes.h:19
Settings that control building the AST.
Definition: BasicTypes.h:69
static AstConstructionSettings strict()
Default strict settings.
Definition: BasicTypes.h:122
bool discontiguousBlocks
Should basic blocks be allowed to be discontiguous.
Definition: BasicTypes.h:281
bool allowEmptyGlobalBlock
Whether to allow an empty global block.
Definition: BasicTypes.h:74
bool namingStrings
Give labels to constants that are string literal addresses.
Definition: BasicTypes.h:305
Sawyer::SharedPointer< Function > FunctionPtr
Shared-ownership pointer for function.
Definition: BasicTypes.h:374
FunctionReturnAnalysis functionReturnAnalysis
How to run the function may-return analysis.
Definition: BasicTypes.h:298
bool demangleNames
Run all names through a demangling step.
Definition: BasicTypes.h:306
std::vector< std::string > configurationNames
List of configuration files and/or directories.
Definition: BasicTypes.h:356
bool doingPostFunctionMayReturn
Run function-may-return analysis if doingPostAnalysis is set?
Definition: BasicTypes.h:294
The special &quot;undiscovered&quot; vertex.
Definition: BasicTypes.h:21
The value is an assumption without any proof.
Definition: BasicTypes.h:55
Settings that control the engine partitioning.
Definition: BasicTypes.h:269
How sure are we of something.
Definition: BasicTypes.h:54
bool doingPostAnalysis
Perform enabled post-partitioning analyses?
Definition: BasicTypes.h:293
Do not make any global changes to the memory map.
Definition: BasicTypes.h:164
bool findingThunks
Look for common thunk patterns in undiscovered areas.
Definition: BasicTypes.h:301
A basic block or placeholder for a basic block.
Definition: BasicTypes.h:20
Organization of semantic memory.
Definition: BasicTypes.h:60
Edge is a function return from the call site.
Definition: BasicTypes.h:36
Normal control flow edge, nothing special.
Definition: BasicTypes.h:31
MemoryDataAdjustment memoryDataAdjustment
How to globally adjust memory segment access bits for data areas.
Definition: BasicTypes.h:182
Controls whether the function may-return analysis runs.
Definition: BasicTypes.h:225
size_t deExecuteZerosLeaveAtFront
Number of bytes at the beginning of each zero area to leave unaffected.
Definition: BasicTypes.h:178
The value was somehow proved.
Definition: BasicTypes.h:56
bool findingDeadCode
Look for unreachable basic blocks?
Definition: BasicTypes.h:287
SemanticMemoryParadigm semanticMemoryParadigm
Container used for semantic memory states.
Definition: BasicTypes.h:303
bool checkingCallBranch
Check for situations where CALL is used as a branch.
Definition: BasicTypes.h:244
bool allowEmptyBasicBlocks
Whether to allow a basic block to be empty.
Definition: BasicTypes.h:89
bool usingSemantics
Whether instruction semantics are used.
Definition: BasicTypes.h:240
Treat all memory as if it were constant.
Definition: BasicTypes.h:156
bool exitOnError
If true, emit error message and exit non-zero, else throw.
Definition: BasicTypes.h:357
bool basicBlockSemanticsAutoDrop
Conserve memory by dropping semantics for attached basic blocks.
Definition: BasicTypes.h:245
Assume a function cannot return if the may-return analysis cannot decide whether it may return...
Definition: BasicTypes.h:228
bool namingConstants
Give names to constants by calling Modules::nameConstants.
Definition: BasicTypes.h:304
size_t deExecuteZerosThreshold
Size threshold for removing execute permission from zero data.
Definition: BasicTypes.h:171
bool findingCodeFunctionPointers
Look for function pointers in instructions.
Definition: BasicTypes.h:300
Special vertex destination for non-existing basic blocks.
Definition: BasicTypes.h:23
bool findingIntraFunctionData
Suck up unused addresses as intra-function data.
Definition: BasicTypes.h:290
Assume that a function cannot return without ever running the may-return analysis.
Definition: BasicTypes.h:232
bool allowFunctionWithNoBasicBlocks
Whether to allow functions with no basic blocks.
Definition: BasicTypes.h:81
AddressInterval interruptVector
Table of interrupt handling functions.
Definition: BasicTypes.h:292
bool findingFunctionPadding
Look for padding before each function entry point?
Definition: BasicTypes.h:286
size_t maxBasicBlockSize
Maximum basic block size.
Definition: BasicTypes.h:285