-
Notifications
You must be signed in to change notification settings - Fork 150
/
Movement-analysis.h
169 lines (133 loc) · 5.38 KB
/
Movement-analysis.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* See the dyninst/COPYRIGHT file for copyright information.
*
* We provide the Paradyn Tools (below described as "Paradyn")
* on an AS IS basis, and do not warrant its validity or performance.
* We reserve the right to update, modify, or discontinue this
* software at any time. We shall have no obligation to supply such
* updates or modifications or any other form of support to you.
*
* By your use of Paradyn, you understand and agree that we (or any
* other person or entity with proprietary rights in Paradyn) are
* under no obligation to provide either maintenance services,
* update services, notices of latent defects, or correction of
* defects for Paradyn.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#if !defined(_R_T_MOVEMENT_ANALYSIS_H_)
#define _R_T_MOVEMENT_ANALYSIS_H_
#include "Transformer.h"
#include "dyninstAPI/src/LinearVariable.h"
#include "dataflowAPI/h/Absloc.h" // MemEmulator analysis
#include "dataflowAPI/h/AbslocInterface.h" // And more of the same
#include "common/h/Graph.h" // PC-sensitive transformer
#include "dataflowAPI/h/SymEval.h" // Variable class
#include "Movement-adhoc.h"
#include "../CodeMover.h"
class parse_block;
class parse_func;
namespace Dyninst {
// ROSE symeval AST types
namespace DataflowAPI {
class BottomAST;
class ConstantAST;
class AbsRegionAST;
class RoseAST;
};
class StackAST;
namespace Relocation {
class ExtPCSensVisitor : public ASTVisitor {
public:
ExtPCSensVisitor(const AbsRegion &a);
virtual AST::Ptr visit(AST *);
virtual AST::Ptr visit(DataflowAPI::BottomAST *);
virtual AST::Ptr visit(DataflowAPI::ConstantAST *);
virtual AST::Ptr visit(DataflowAPI::VariableAST *);
virtual AST::Ptr visit(DataflowAPI::RoseAST *);
virtual AST::Ptr visit(StackAST *);
virtual ASTVisitor::ASTPtr visit(InputVariableAST *x) { return ASTVisitor::visit(x); }
virtual ASTVisitor::ASTPtr visit(ReferenceAST *x) { return ASTVisitor::visit(x); }
virtual ASTVisitor::ASTPtr visit(StpAST *x) { return ASTVisitor::visit(x); }
virtual ASTVisitor::ASTPtr visit(YicesAST *x) { return ASTVisitor::visit(x); }
virtual ASTVisitor::ASTPtr visit(SemanticsAST *x) { return ASTVisitor::visit(x); }
virtual ~ExtPCSensVisitor() {};
bool isExtSens(AST::Ptr a);
private:
bool assignPC_;
bool isExtSens_;
typedef linVar<Dyninst::DataflowAPI::Variable> DiffVar;
std::stack<DiffVar > diffs_;
};
class PCSensitiveTransformer : public Transformer {
typedef boost::shared_ptr<RelocInsn> RelocInsnPtr;
typedef std::list<Assignment::Ptr> AssignList;
public:
virtual bool process(RelocBlock *, RelocGraph *);
PCSensitiveTransformer(AddressSpace *as, PriorityMap &p)
: aConverter(false, false), addrSpace(as), priMap(p),
Sens_(0), extSens_(0), intSens_(0), thunk_(0), overApprox_(0), adhoc(as) {};
virtual ~PCSensitiveTransformer() {};
static void invalidateCache(func_instance *);
static void invalidateCache(const block_instance *);
private:
bool analysisRequired(RelocBlock *);
bool isPCSensitive(InstructionAPI::Instruction::Ptr insn,
Address addr,
const func_instance *func,
const block_instance *block,
AssignList &sensitiveAssignment);
Graph::Ptr forwardSlice(Assignment::Ptr ptr,
parse_block *block,
parse_func *func);
bool determineSensitivity(Graph::Ptr slice,
bool &intSens,
bool &extSens);
bool insnIsThunkCall(InstructionAPI::Instruction::Ptr insn,
Address addr,
Absloc &destination);
void handleThunkCall(RelocBlock *b_iter,
RelocGraph *cfg,
WidgetList::iterator &iter,
Absloc &destination);
void recordIntSensitive(Address addr);
void emulateInsn(RelocBlock *b_iter,
RelocGraph *cfg,
WidgetList::iterator &iter,
InstructionAPI::Instruction::Ptr insn,
Address addr);
bool exceptionSensitive(Address addr, const block_instance *bbl);
bool isSyscall(InstructionAPI::Instruction::Ptr insn, Address addr);
static void cacheAnalysis(const block_instance *bbl, Address addr, bool intSens, bool extSens);
static bool queryCache(const block_instance *bbl, Address addr, bool &intSens, bool &extSens);
AssignmentConverter aConverter;
AddressSpace *addrSpace;
PriorityMap &priMap;
long Sens_;
long extSens_;
long intSens_;
long thunk_;
long overApprox_;
// And for times we don't want the overhead - if non-defensive or
// system libraries
adhocMovementTransformer adhoc;
typedef std::pair<bool, bool> CacheData;
typedef std::map<Address, CacheData> CacheEntry;
typedef std::map<const block_instance *, CacheEntry > AnalysisCache;
static AnalysisCache analysisCache_;
};
};
};
#endif