1 #ifndef ROSE_BinaryAnalysis_Partitioner2_BasicTypes_H
2 #define ROSE_BinaryAnalysis_Partitioner2_BasicTypes_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
6 #include <boost/filesystem.hpp>
7 #include <boost/regex.hpp>
8 #include <boost/serialization/access.hpp>
9 #include <boost/serialization/nvp.hpp>
10 #include <boost/serialization/version.hpp>
17 #define ROSE_PARTITIONER_EXPENSIVE_CHECKS 0
20 namespace BinaryAnalysis {
53 namespace Partitioner2 {
66 namespace AllowParallelEdges {
160 friend class boost::serialization::access;
163 void serialize(S &s,
unsigned version) {
164 s & BOOST_SERIALIZATION_NVP(allowEmptyGlobalBlock);
165 s & BOOST_SERIALIZATION_NVP(allowFunctionWithNoBasicBlocks);
166 s & BOOST_SERIALIZATION_NVP(allowEmptyBasicBlocks);
167 s & BOOST_SERIALIZATION_NVP(copyAllInstructions);
173 : allowEmptyGlobalBlock(false), allowFunctionWithNoBasicBlocks(false), allowEmptyBasicBlocks(false),
174 copyAllInstructions(true) {}
272 : deExecuteZerosThreshold(0), deExecuteZerosLeaveAtFront(16), deExecuteZerosLeaveAtBack(1),
273 memoryDataAdjustment(
DATA_IS_INITIALIZED), memoryIsExecutable(false), linkObjectFiles(true),
274 linkStaticArchives(true), linker(
"ld -o %o --unresolved-symbols=ignore-all --whole-archive %f") {}
277 friend class boost::serialization::access;
280 void serialize(S &s,
unsigned version) {
281 s & BOOST_SERIALIZATION_NVP(deExecuteZerosThreshold);
282 s & BOOST_SERIALIZATION_NVP(deExecuteZerosLeaveAtFront);
283 s & BOOST_SERIALIZATION_NVP(deExecuteZerosLeaveAtBack);
284 s & BOOST_SERIALIZATION_NVP(memoryDataAdjustment);
285 s & BOOST_SERIALIZATION_NVP(memoryIsExecutable);
287 s & BOOST_SERIALIZATION_NVP(envEraseNames);
288 s & BOOST_SERIALIZATION_NVP(envInsert);
291 std::vector<std::string> reStrings;
292 for (
const boost::regex &re: envErasePatterns)
293 reStrings.push_back(re.str());
294 s & BOOST_SERIALIZATION_NVP(reStrings);
295 if (envErasePatterns.empty()) {
296 for (
const std::string &reStr: reStrings)
297 envErasePatterns.push_back(boost::regex(reStr));
314 friend class boost::serialization::access;
317 void serialize(S &s,
unsigned version) {
319 s & BOOST_SERIALIZATION_NVP(doDisassemble);
320 s & BOOST_SERIALIZATION_NVP(isaName);
325 : doDisassemble(true) {}
353 friend class boost::serialization::access;
356 void serialize(S &s,
const unsigned version) {
357 s & BOOST_SERIALIZATION_NVP(usingSemantics);
358 s & BOOST_SERIALIZATION_NVP(checkingCallBranch);
359 s & BOOST_SERIALIZATION_NVP(basicBlockSemanticsAutoDrop);
361 s & BOOST_SERIALIZATION_NVP(ignoringUnknownInsns);
366 : usingSemantics(false), checkingCallBranch(false), basicBlockSemanticsAutoDrop(true), ignoringUnknownInsns(false) {}
426 friend class boost::serialization::access;
429 void serialize(S &s,
unsigned version) {
430 s & BOOST_SERIALIZATION_NVP(base);
431 s & BOOST_SERIALIZATION_NVP(functionStartingVas);
432 s & BOOST_SERIALIZATION_NVP(followingGhostEdges);
433 s & BOOST_SERIALIZATION_NVP(discontiguousBlocks);
434 s & BOOST_SERIALIZATION_NVP(maxBasicBlockSize);
436 s & BOOST_SERIALIZATION_NVP(ipRewrites);
437 s & BOOST_SERIALIZATION_NVP(findingFunctionPadding);
438 s & BOOST_SERIALIZATION_NVP(findingDeadCode);
439 s & BOOST_SERIALIZATION_NVP(peScramblerDispatcherVa);
441 s & BOOST_SERIALIZATION_NVP(findingIntraFunctionCode);
444 if (S::is_saving::value)
445 temp = findingIntraFunctionCode > 0;
446 s & boost::serialization::make_nvp(
"findingIntraFunctionCode", temp);
447 if (S::is_loading::value)
448 findingIntraFunctionCode = temp ? 10 : 0;
450 s & BOOST_SERIALIZATION_NVP(findingIntraFunctionData);
451 s & BOOST_SERIALIZATION_NVP(findingInterFunctionCalls);
453 s & BOOST_SERIALIZATION_NVP(findingFunctionCallFunctions);
455 s & BOOST_SERIALIZATION_NVP(findingEntryFunctions);
456 s & BOOST_SERIALIZATION_NVP(findingErrorFunctions);
457 s & BOOST_SERIALIZATION_NVP(findingImportFunctions);
458 s & BOOST_SERIALIZATION_NVP(findingExportFunctions);
459 s & BOOST_SERIALIZATION_NVP(findingSymbolFunctions);
461 s & BOOST_SERIALIZATION_NVP(interruptVector);
462 s & BOOST_SERIALIZATION_NVP(doingPostAnalysis);
463 s & BOOST_SERIALIZATION_NVP(doingPostFunctionMayReturn);
464 s & BOOST_SERIALIZATION_NVP(doingPostFunctionStackDelta);
465 s & BOOST_SERIALIZATION_NVP(doingPostCallingConvention);
466 s & BOOST_SERIALIZATION_NVP(doingPostFunctionNoop);
467 s & BOOST_SERIALIZATION_NVP(functionReturnAnalysis);
469 s & BOOST_SERIALIZATION_NVP(functionReturnAnalysisMaxSorts);
470 s & BOOST_SERIALIZATION_NVP(findingDataFunctionPointers);
471 s & BOOST_SERIALIZATION_NVP(findingCodeFunctionPointers);
472 s & BOOST_SERIALIZATION_NVP(findingThunks);
473 s & BOOST_SERIALIZATION_NVP(splittingThunks);
474 s & BOOST_SERIALIZATION_NVP(semanticMemoryParadigm);
476 s & BOOST_SERIALIZATION_NVP(namingConstants);
477 }
else if (S::is_loading()) {
479 s & boost::serialization::make_nvp(
"namingConstants", b);
487 s & BOOST_SERIALIZATION_NVP(namingStrings);
488 }
else if (S::is_loading()) {
490 s & boost::serialization::make_nvp(
"namingStrings", b);
497 s & BOOST_SERIALIZATION_NVP(demangleNames);
499 s & BOOST_SERIALIZATION_NVP(namingSyscalls);
504 if (S::is_saving::value)
505 temp = syscallHeader.string();
506 s & boost::serialization::make_nvp(
"syscallHeader", temp);
507 if (S::is_loading::value)
508 syscallHeader = temp;
513 PartitionerSettings()
514 : followingGhostEdges(false), discontiguousBlocks(true), maxBasicBlockSize(0), findingFunctionPadding(true),
515 findingDeadCode(true), peScramblerDispatcherVa(0), findingIntraFunctionCode(10), findingIntraFunctionData(true),
516 findingInterFunctionCalls(true), findingFunctionCallFunctions(true), findingEntryFunctions(true),
517 findingErrorFunctions(true), findingImportFunctions(true), findingExportFunctions(true), findingSymbolFunctions(true),
518 doingPostAnalysis(true), doingPostFunctionMayReturn(true), doingPostFunctionStackDelta(true),
519 doingPostCallingConvention(false), doingPostFunctionNoop(false), functionReturnAnalysis(
MAYRETURN_DEFAULT_YES),
520 functionReturnAnalysisMaxSorts(50), findingDataFunctionPointers(false), findingCodeFunctionPointers(false),
521 findingThunks(true), splittingThunks(false), semanticMemoryParadigm(
LIST_BASED_MEMORY),
524 namingSyscalls(true), demangleNames(true) {}
538 : exitOnError(true) {}
541 friend class boost::serialization::access;
544 void serialize(S &s,
unsigned version) {
545 s & BOOST_SERIALIZATION_NVP(configurationNames);
546 s & BOOST_SERIALIZATION_NVP(exitOnError);
bool findingInterFunctionCalls
Look for function calls between functions.
Edge is a function call transfer.
bool splittingThunks
Split thunks into their own separate functions.
bool memoryIsExecutable
Determines whether all of memory should be made executable.
bool linkStaticArchives
Link static libraries before parsing.
Settings for controling the engine behavior.
bool findingExportFunctions
Create functions at export addresses.
MemoryDataAdjustment
How the partitioner should globally treat memory.
bool findingDataFunctionPointers
Look for function pointers in static data.
Edge is a function return.
Assume a function returns if the may-return analysis cannot decide whether it may return...
Allow parallel edges, so each edge has a unit count.
std::string isaName
Name of the instruction set architecture.
bool doingPostFunctionStackDelta
Run function-stack-delta analysis if doingPostAnalysis is set?
EdgeType
Partitioner control flow edge types.
rose_addr_t peScramblerDispatcherVa
Run the PeDescrambler module if non-zero.
Settings that control the disassembler.
Treat all memory as if it were initialized.
size_t deExecuteZerosLeaveAtBack
Number of bytes at the end of each zero area to leave unaffected.
AddressInterval namingStrings
Addresses that might be string literals for commenting integers.
bool copyAllInstructions
Whether to allow shared instructions in the AST.
AddressInterval namingConstants
Give possible names to constants if they're in this range.
Special vertex destination for indeterminate edges.
static AstConstructionSettings permissive()
Default permissive settings.
Enum type for allowing parallel edges.
Settings that directly control a partitioner.
High precision, but slow.
bool doingPostFunctionNoop
Find and name functions that are effectively no-ops.
Assume that all functions return without ever running the may-return analysis.
bool namingSyscalls
Give names (comments) to system calls if possible.
bool followingGhostEdges
Should ghost edges be followed during disassembly? A ghost edge is a CFG edge that is apparent from t...
Main namespace for the ROSE library.
bool doingPostCallingConvention
Run calling-convention analysis if doingPostAnalysis is set?
Settings for loading specimens.
std::vector< rose_addr_t > functionStartingVas
Addresses at which to start recursive disassembly.
bool linkObjectFiles
Link object files before parsing.
VertexType
Partitioner control flow vertex types.
Settings that control building the AST.
static AstConstructionSettings strict()
Default strict settings.
bool discontiguousBlocks
Should basic blocks be allowed to be discontiguous.
bool allowEmptyGlobalBlock
Whether to allow an empty global block.
size_t functionReturnAnalysisMaxSorts
Number of times functions are sorted before using unsorted lists.
Sawyer::SharedPointer< Function > FunctionPtr
Shared-ownership pointer for function.
FunctionReturnAnalysis functionReturnAnalysis
How to run the function may-return analysis.
bool demangleNames
Run all names through a demangling step.
std::vector< std::string > configurationNames
List of configuration files and/or directories.
std::vector< rose_addr_t > ipRewrites
Pairs of addresses for rewriting CFG edges.
bool doingPostFunctionMayReturn
Run function-may-return analysis if doingPostAnalysis is set?
bool ignoringUnknownInsns
Whether to ignore unkonwn insns when extending basic blocks.
The special "undiscovered" vertex.
bool findingErrorFunctions
Create functions from error handling and exception information.
std::vector< std::string > envInsert
List of environment variable names and values to be inserted before launching a "run:" specimen...
The value is an assumption without any proof.
Settings that control the engine partitioning.
Confidence
How sure are we of something.
bool doingPostAnalysis
Perform enabled post-partitioning analyses?
size_t findingIntraFunctionCode
Suck up unused addresses as intra-function code (number of passes).
Do not make any global changes to the memory map.
bool findingThunks
Look for common thunk patterns in undiscovered areas.
static Interval whole()
Construct an interval that covers the entire domain.
bool findingImportFunctions
Create functions at import addresses.
A basic block or placeholder for a basic block.
SemanticMemoryParadigm
Organization of semantic memory.
Edge is a function return from the call site.
Normal control flow edge, nothing special.
MemoryDataAdjustment memoryDataAdjustment
How to globally adjust memory segment access bits for data areas.
FunctionReturnAnalysis
Controls whether the function may-return analysis runs.
size_t deExecuteZerosLeaveAtFront
Number of bytes at the beginning of each zero area to leave unaffected.
The value was somehow proved.
bool findingEntryFunctions
Create functions at the program entry point(s).
bool findingDeadCode
Look for unreachable basic blocks?
SemanticMemoryParadigm semanticMemoryParadigm
Container used for semantic memory states.
bool doDisassemble
Perform disassembly.
bool checkingCallBranch
Check for situations where CALL is used as a branch.
bool allowEmptyBasicBlocks
Whether to allow a basic block to be empty.
bool usingSemantics
Whether instruction semantics are used.
Treat all memory as if it were constant.
bool findingSymbolFunctions
Create functions according to symbol tables.
bool exitOnError
If true, emit error message and exit non-zero, else throw.
std::vector< boost::regex > envErasePatterns
List of regular expressions for removing environment variables before launching a "run:" specimen...
bool basicBlockSemanticsAutoDrop
Conserve memory by dropping semantics for attached basic blocks.
Assume a function cannot return if the may-return analysis cannot decide whether it may return...
size_t deExecuteZerosThreshold
Size threshold for removing execute permission from zero data.
std::vector< std::string > envEraseNames
List of environment variable names that should be removed before launching a "run:" specimen...
bool findingCodeFunctionPointers
Look for function pointers in instructions.
Special vertex destination for non-existing basic blocks.
bool findingIntraFunctionData
Suck up unused addresses as intra-function data.
List of thunk predicates.
Assume that a function cannot return without ever running the may-return analysis.
bool allowFunctionWithNoBasicBlocks
Whether to allow functions with no basic blocks.
AddressInterval interruptVector
Table of interrupt handling functions.
bool findingFunctionPadding
Look for padding before each function entry point?
std::string linker
Command to run to link object and archives.
bool findingFunctionCallFunctions
Create functions from function calls.
size_t maxBasicBlockSize
Maximum basic block size.
boost::filesystem::path syscallHeader
Name of header file containing system call numbers.
AstConstructionSettings()
Default constructor.