ROSE 0.11.145.147
Rose/BinaryAnalysis/Partitioner2/BasicTypes.h
1#ifndef ROSE_BinaryAnalysis_Partitioner2_BasicTypes_H
2#define ROSE_BinaryAnalysis_Partitioner2_BasicTypes_H
3#include <featureTests.h>
4#ifdef ROSE_ENABLE_BINARY_ANALYSIS
5
6#include <Rose/BinaryAnalysis/AddressInterval.h>
7
8#include <Sawyer/Graph.h>
9#include <Sawyer/Map.h>
10#include <Sawyer/Set.h>
11#include <Sawyer/SharedPointer.h>
12
13#include <boost/filesystem.hpp>
14#include <boost/regex.hpp>
15#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
16#include <boost/serialization/access.hpp>
17#endif
18
19#include <set>
20#include <string>
21#include <vector>
22
23// Define this as one if you want extra invariant checks that are quite expensive, or define as zero. This only makes a
24// difference if NDEBUG and SAWYER_NDEBUG are both undefined--if either one of them are defined then no expensive (or
25// inexpensive) checks are performed.
26#define ROSE_PARTITIONER_EXPENSIVE_CHECKS 0
27
28namespace Rose {
29namespace BinaryAnalysis {
30namespace Partitioner2 {
31
33namespace Precision {
34enum Level {
35 LOW,
37 HIGH
39};
40} // namespace
41
43namespace AllowParallelEdges {
44enum Type {
46 YES
47};
48} // namespace
49
60
63 E_NORMAL = 0x00000001,
64 E_FUNCTION_CALL = 0x00000002,
65 E_FUNCTION_RETURN = 0x00000004,
68 E_CALL_RETURN = 0x00000008,
74 E_FUNCTION_XFER = 0x00000010,
80 E_USER_DEFINED = 0x00000020,
83};
84
90
96
106
113
121
134
135#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
136private:
137 friend class boost::serialization::access;
138 template<class S> void serialize(S&, unsigned version);
139#endif
140
141public:
148 s.allowEmptyGlobalBlock = false;
150 s.allowEmptyBasicBlocks = false;
151 s.copyAllInstructions = true;
152 return s;
153 }
154
162 s.allowEmptyGlobalBlock = true;
164 s.allowEmptyBasicBlocks = true;
165 s.copyAllInstructions = true; // true keeps the AST a tree instead of a lattice
166 return s;
167 }
168};
169
171// Settings. All settings must act like properties, which means the following:
172// 1. Each setting must have a name that does not begin with a verb.
173// 2. Each setting must have a command-line switch to manipulate it.
174// 3. Each setting must have a method that queries the property (same name as the property and taking no arguments).
175// 4. Each setting must have a modifier method (same name as property but takes a value and returns void)
177
190
222
229 bool memoryIsExecutable = false;
230
238 bool linkObjectFiles = true;
239
248
259 std::string linker = "ld -o %o --unresolved-symbols=ignore-all --whole-archive %f";
260
265 std::vector<std::string> envEraseNames;
266
271 std::vector<boost::regex> envErasePatterns;
272
278 std::vector<std::string> envInsert;
279
280#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
281private:
282 friend class boost::serialization::access;
283 template<class S> void serialize(S&, unsigned version);
284#endif
285};
286
295 bool doDisassemble = true;
296
302 std::string isaName;
303
304#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
305private:
306 friend class boost::serialization::access;
307 template<class S> void serialize(S&, unsigned version);
308#endif
309};
310
322
331 bool usingSemantics = false;
332
336 bool checkingCallBranch = false;
337
348
356
357#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
358private:
359 friend class boost::serialization::access;
360 template<class S> void serialize(S&, unsigned version);
361#endif
362};
363
374
379 std::vector<rose_addr_t> functionStartingVas;
380
406
413
420
427 std::vector<rose_addr_t> ipRewrites;
428
434
441 bool findingDeadCode = true;
442
447 rose_addr_t peScramblerDispatcherVa = 0;
448
455
461
467
473
478
484
490
496
502
508
513 bool doingPostAnalysis = true;
514
519
524
529
535
541
553
559
565
571 bool findingThunks = true;
572
577 bool splittingThunks = false;
578
584
593
600
605 bool namingSyscalls = true;
606
613 boost::filesystem::path syscallHeader;
614
619 bool demangleNames = true;
620
621#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
622private:
623 friend class boost::serialization::access;
624 template<class S> void serialize(S&, unsigned version);
625#endif
626};
627
636 std::vector<std::string> configurationNames;
637
644 bool exitOnError = true;
645
646#ifdef ROSE_HAVE_BOOST_SERIALIZATION_LIB
647private:
648 friend class boost::serialization::access;
649 template<class S> void serialize(S&, unsigned version);
650#endif
651};
652
653// Additional declarations incomplete definitions.
654class AddressUser;
655class AddressUsers;
656class AddressUsageMap;
657
658class BasicBlock;
661class BasicBlockError;
662
667using BasicBlockSuccessors = std::vector<BasicBlockSuccessor>;
670
671class CfgEdge;
672
673class CfgVertex;
674
677class Configuration;
678
679class DataBlock;
682class DataBlockError;
683
684class Engine;
686
687class EngineBinary;
689
690class EngineJvm;
692
693class Exception;
694
695class Function;
701
710class FunctionError;
711
712class Partitioner;
716class PlaceholderError;
717
718class Reference;
719using ReferenceSet = std::set<Reference>;
722class ThunkPredicates;
725} // namespace
726} // namespace
727} // namespace
728
729#endif
730#endif
Base class for adjusting basic blocks during discovery.
Definition Modules.h:39
Engine for specimens containing machine instructions.
Engine for Java Virtual Machine (JVM) specimens.
Definition EngineJvm.h:21
Base class for engines driving the partitioner.
Base class for matching function padding.
Definition Modules.h:134
Base class for matching function prologues.
Definition Modules.h:108
Partitions instructions into basic blocks and functions.
Reference to a function, basic block, instruction, or address.
Definition Reference.h:25
static Interval hull(Address v1, Address v2)
Construct an interval from two endpoints.
Definition Interval.h:162
static Interval whole()
Construct an interval that covers the entire domain.
Definition Interval.h:191
MemoryDataAdjustment
How the partitioner should globally treat memory.
@ DATA_NO_CHANGE
Do not make any global changes to the memory map.
@ DATA_IS_INITIALIZED
Treat all memory as if it were initialized.
@ DATA_IS_CONSTANT
Treat all memory as if it were constant.
std::vector< BasicBlockSuccessor > BasicBlockSuccessors
All successors in no particular order.
@ E_CALL_RETURN
Edge is a function return from the call site.
@ E_NORMAL
Normal control flow edge, nothing special.
@ ASSUMED
The value is an assumption without any proof.
FunctionReturnAnalysis
Controls whether the function may-return analysis runs.
@ MAYRETURN_ALWAYS_NO
Assume that a function cannot return without ever running the may-return analysis.
@ MAYRETURN_DEFAULT_YES
Assume a function returns if the may-return analysis cannot decide whether it may return.
@ MAYRETURN_ALWAYS_YES
Assume that all functions return without ever running the may-return analysis.
@ MAYRETURN_DEFAULT_NO
Assume a function cannot return if the may-return analysis cannot decide whether it may return.
@ V_BASIC_BLOCK
A basic block or placeholder for a basic block.
@ V_INDETERMINATE
Special vertex destination for indeterminate edges.
@ V_NONEXISTING
Special vertex destination for non-existing basic blocks.
The ROSE library.
bool allowFunctionWithNoBasicBlocks
Whether to allow functions with no basic blocks.
static AstConstructionSettings permissive()
Default permissive settings.
bool checkingCallBranch
Whether to look for function calls used as branches.
bool basicBlockSemanticsAutoDrop
Whether to automatically drop semantics for attached basic blocks.
std::vector< std::string > configurationNames
Configuration files names.
std::vector< boost::regex > envErasePatterns
Patterns to erase from the environment.
bool memoryIsExecutable
Whether all of memory should be made executable.
MemoryDataAdjustment memoryDataAdjustment
How to globally adjust memory segment access bits for data areas.
size_t deExecuteZerosLeaveAtFront
When to remove execute permission from zero bytes.
std::vector< std::string > envInsert
Environment variables to insert.
bool linkStaticArchives
Whether to link library archives before parsing.
size_t deExecuteZerosThreshold
When to remove execute permission from zero bytes.
size_t deExecuteZerosLeaveAtBack
When to remove execute permission from zero bytes.
std::vector< std::string > envEraseNames
Names to erase from the environment.
bool findingSymbolFunctions
Whether to make functions according to symbol tables.
bool doingPostFunctionStackDelta
Whether to run the function stack delta analysis.
std::vector< rose_addr_t > functionStartingVas
Starting addresses for disassembly.
size_t functionReturnAnalysisMaxSorts
Maximum number of function may-return sorting operations.
bool splittingThunks
Whether to split thunk instructions into mini functions.
bool findingDataFunctionPointers
Whether to search static data for function pointers.
SemanticMemoryParadigm semanticMemoryParadigm
Type of container for semantic memory.
bool findingEntryFunctions
Whether to make functions at program entry points.
AddressInterval interruptVector
Property: Location of machine interrupt vector.
FunctionReturnAnalysis functionReturnAnalysis
How to run the function may-return analysis.
bool doingPostFunctionMayReturn
Whether to run the function may-return analysis.
bool doingPostAnalysis
Whether to perform any post-partitioning analysis steps.
bool findingInterFunctionCalls
Whether to search for function calls between exiting functions.
bool findingCodeFunctionPointers
Whether to search existing instructions for function pointers.
bool findingFunctionCallFunctions
Whether to turn function call targets into functions.
boost::filesystem::path syscallHeader
Header file in which system calls are defined.