My Project
coreaction.hh
Go to the documentation of this file.
1 /* ###
2  * IP: GHIDRA
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
22 
23 
24 #ifndef __CORE_ACTION__
25 #define __CORE_ACTION__
26 
27 #include "ruleaction.hh"
28 #include "blockaction.hh"
29 #include "funcdata.hh"
30 
32 class ActionStart : public Action {
33 public:
34  ActionStart(const string &g) : Action(0,"start",g) {}
35  virtual Action *clone(const ActionGroupList &grouplist) const {
36  if (!grouplist.contains(getGroup())) return (Action *)0;
37  return new ActionStart(getGroup());
38  }
39  virtual int4 apply(Funcdata &data) {
40  data.startProcessing(); return 0; }
41 };
42 
44 class ActionStop : public Action {
45 public:
46  ActionStop(const string &g) : Action(0,"stop",g) {}
47  virtual Action *clone(const ActionGroupList &grouplist) const {
48  if (!grouplist.contains(getGroup())) return (Action *)0;
49  return new ActionStop(getGroup());
50  }
51  virtual int4 apply(Funcdata &data) {
52  data.stopProcessing(); return 0; }
53 };
54 
56 class ActionStartCleanUp : public Action {
57 public:
58  ActionStartCleanUp(const string &g) : Action(0,"startcleanup",g) {}
59  virtual Action *clone(const ActionGroupList &grouplist) const {
60  if (!grouplist.contains(getGroup())) return (Action *)0;
61  return new ActionStartCleanUp(getGroup());
62  }
63  virtual int4 apply(Funcdata &data) {
64  data.startCleanUp(); return 0; }
65 };
66 
68 class ActionStartTypes : public Action {
69 public:
70  ActionStartTypes(const string &g) : Action(0,"starttypes",g) {}
71  virtual Action *clone(const ActionGroupList &grouplist) const {
72  if (!grouplist.contains(getGroup())) return (Action *)0;
73  return new ActionStartTypes(getGroup());
74  }
75  virtual int4 apply(Funcdata &data) {
76  if (data.startTypeRecovery()) count+=1;
77  return 0;
78  }
79 };
80 
82 class ActionStackPtrFlow : public Action {
83  AddrSpace *stackspace;
84  bool analysis_finished;
85  static void analyzeExtraPop(Funcdata &data,AddrSpace *stackspace,int4 spcbase);
86  static bool isStackRelative(Varnode *spcbasein,Varnode *vn,uintb &constval);
87  static bool adjustLoad(Funcdata &data,PcodeOp *loadop,PcodeOp *storeop);
88  static int4 repair(Funcdata &data,AddrSpace *id,Varnode *spcbasein,PcodeOp *loadop,uintb constz);
89  static int4 checkClog(Funcdata &data,AddrSpace *id,int4 spcbase);
90 public:
91  ActionStackPtrFlow(const string &g,AddrSpace *ss) : Action(0,"stackptrflow",g) { stackspace = ss; }
92  virtual void reset(Funcdata &data) { analysis_finished = false; }
93  virtual Action *clone(const ActionGroupList &grouplist) const {
94  if (!grouplist.contains(getGroup())) return (Action *)0;
95  return new ActionStackPtrFlow(getGroup(),stackspace);
96  }
97  virtual int4 apply(Funcdata &data);
98 };
99 
106 class ActionLaneDivide : public Action {
107  void collectLaneSizes(Varnode *vn,const LanedRegister &allowedLanes,LanedRegister &checkLanes);
108  bool processVarnode(Funcdata &data,Varnode *vn,const LanedRegister &lanedRegister,int4 mode);
109 public:
110  ActionLaneDivide(const string &g) : Action(rule_onceperfunc,"lanedivide",g) {}
111  virtual Action *clone(const ActionGroupList &grouplist) const {
112  if (!grouplist.contains(getGroup())) return (Action *)0;
113  return new ActionLaneDivide(getGroup());
114  }
115  virtual int4 apply(Funcdata &data);
116 };
117 
121 class ActionSegmentize : public Action {
122  int4 localcount;
123 public:
124  ActionSegmentize(const string &g) : Action(0,"segmentize",g) {}
125  virtual void reset(Funcdata &data) { localcount = 0; }
126  virtual Action *clone(const ActionGroupList &grouplist) const {
127  if (!grouplist.contains(getGroup())) return (Action *)0;
128  return new ActionSegmentize(getGroup());
129  }
130  virtual int4 apply(Funcdata &data);
131 };
132 
134 class ActionForceGoto : public Action {
135 public:
136  ActionForceGoto(const string &g) : Action(0,"forcegoto",g) {}
137  virtual Action *clone(const ActionGroupList &grouplist) const {
138  if (!grouplist.contains(getGroup())) return (Action *)0;
139  return new ActionForceGoto(getGroup());
140  }
141  virtual int4 apply(Funcdata &data);
142 };
143 
144 // \brief Perform common subexpression elimination
145 // class ActionCse : public Action {
146 // public:
147 // ActionCse(const string &g) : Action(0,"cse",g) {} ///< Constructor
148 // virtual Action *clone(const ActionGroupList &grouplist) const {
149 // if (!grouplist.contains(getGroup())) return (Action *)0;
150 // return new ActionCse(getGroup());
151 // }
152 // virtual int4 apply(Funcdata &data);
153 // };
154 
156 class ActionMultiCse : public Action {
157  static bool preferredOutput(Varnode *out1,Varnode *out2);
158  static PcodeOp *findMatch(BlockBasic *bl,PcodeOp *target,Varnode *in);
159  bool processBlock(Funcdata &data,BlockBasic *bl);
160 public:
161  ActionMultiCse(const string &g) : Action(0,"multicse",g) {}
162  virtual Action *clone(const ActionGroupList &grouplist) const {
163  if (!grouplist.contains(getGroup())) return (Action *)0;
164  return new ActionMultiCse(getGroup());
165  }
166  virtual int4 apply(Funcdata &data);
167 };
168 
170 class ActionShadowVar : public Action {
171 public:
172  ActionShadowVar(const string &g) : Action(0,"shadowvar",g) {}
173  virtual Action *clone(const ActionGroupList &grouplist) const {
174  if (!grouplist.contains(getGroup())) return (Action *)0;
175  return new ActionShadowVar(getGroup());
176  }
177  virtual int4 apply(Funcdata &data);
178 };
179 
181 class ActionConstantPtr : public Action {
182  int4 localcount;
183  static AddrSpace *searchForLoadStore(Varnode *vn,PcodeOp *op);
184  static AddrSpace *selectInferSpace(Varnode *vn,PcodeOp *op,const vector<AddrSpace *> &spaceList);
185  static SymbolEntry *isPointer(AddrSpace *spc,Varnode *vn,PcodeOp *op,int4 slot,
186  Address &rampoint,uintb &fullEncoding,Funcdata &data);
187 public:
188  ActionConstantPtr(const string &g) : Action(0,"constantptr",g) {}
189  virtual void reset(Funcdata &data) { localcount = 0; }
190  virtual Action *clone(const ActionGroupList &grouplist) const {
191  if (!grouplist.contains(getGroup())) return (Action *)0;
192  return new ActionConstantPtr(getGroup());
193  }
194  virtual int4 apply(Funcdata &data);
195 };
196 
198 class ActionDeindirect : public Action {
199 public:
200  ActionDeindirect(const string &g) : Action(0,"deindirect",g) {}
201  virtual Action *clone(const ActionGroupList &grouplist) const {
202  if (!grouplist.contains(getGroup())) return (Action *)0;
203  return new ActionDeindirect(getGroup());
204  }
205  virtual int4 apply(Funcdata &data);
206 };
207 
215 class ActionVarnodeProps : public Action {
216  void markLanedVarnode(Funcdata &data,Varnode *vn);
217 public:
218  ActionVarnodeProps(const string &g) : Action(0,"varnodeprops",g) {}
219  virtual Action *clone(const ActionGroupList &grouplist) const {
220  if (!grouplist.contains(getGroup())) return (Action *)0;
221  return new ActionVarnodeProps(getGroup());
222  }
223  virtual int4 apply(Funcdata &data);
224 };
225 
237 class ActionDirectWrite : public Action {
238  bool propagateIndirect;
239 public:
240  ActionDirectWrite(const string &g,bool prop) : Action(0,"directwrite",g) { propagateIndirect=prop; }
241  virtual Action *clone(const ActionGroupList &grouplist) const {
242  if (!grouplist.contains(getGroup())) return (Action *)0;
243  return new ActionDirectWrite(getGroup(),propagateIndirect);
244  }
245  virtual int4 apply(Funcdata &data);
246 };
247 
253 class ActionConstbase : public Action {
254 public:
255  ActionConstbase(const string &g) : Action(0,"constbase",g) {}
256  virtual Action *clone(const ActionGroupList &grouplist) const {
257  if (!grouplist.contains(getGroup())) return (Action *)0;
258  return new ActionConstbase(getGroup());
259  }
260  virtual int4 apply(Funcdata &data);
261 };
262 
264 class ActionSpacebase : public Action {
265 public:
266  ActionSpacebase(const string &g) : Action(0,"spacebase",g) {}
267  virtual Action *clone(const ActionGroupList &grouplist) const {
268  if (!grouplist.contains(getGroup())) return (Action *)0;
269  return new ActionSpacebase(getGroup());
270  }
271  virtual int4 apply(Funcdata &data) {
272  data.spacebase(); return 0; }
273 };
274 
276 class ActionHeritage : public Action {
277 public:
278  ActionHeritage(const string &g) : Action(0,"heritage",g) {}
279  virtual Action *clone(const ActionGroupList &grouplist) const {
280  if (!grouplist.contains(getGroup())) return (Action *)0;
281  return new ActionHeritage(getGroup());
282  }
283  virtual int4 apply(Funcdata &data) { data.opHeritage(); return 0; }
284 };
285 
287 class ActionNonzeroMask : public Action {
288 public:
289  ActionNonzeroMask(const string &g) : Action(0,"nonzeromask",g) {}
290  virtual Action *clone(const ActionGroupList &grouplist) const {
291  if (!grouplist.contains(getGroup())) return (Action *)0;
292  return new ActionNonzeroMask(getGroup());
293  }
294  virtual int4 apply(Funcdata &data) { data.calcNZMask(); return 0; }
295 };
296 
314 class ActionSetCasts : public Action {
315  static int4 castOutput(PcodeOp *op,Funcdata &data,CastStrategy *castStrategy);
316  static int4 castInput(PcodeOp *op,int4 slot,Funcdata &data,CastStrategy *castStrategy);
317 public:
318  ActionSetCasts(const string &g) : Action(rule_onceperfunc,"setcasts",g) {}
319  virtual Action *clone(const ActionGroupList &grouplist) const {
320  if (!grouplist.contains(getGroup())) return (Action *)0;
321  return new ActionSetCasts(getGroup());
322  }
323  virtual int4 apply(Funcdata &data);
324 };
325 
327 class ActionAssignHigh : public Action {
328 public:
329  ActionAssignHigh(const string &g) : Action(rule_onceperfunc,"assignhigh",g) {}
330  virtual Action *clone(const ActionGroupList &grouplist) const {
331  if (!grouplist.contains(getGroup())) return (Action *)0;
332  return new ActionAssignHigh(getGroup());
333  }
334  virtual int4 apply(Funcdata &data) { data.setHighLevel(); return 0; }
335 };
336 
339 public:
340  ActionMarkIndirectOnly(const string &g) : Action(rule_onceperfunc, "markindirectonly",g) {}
341  virtual Action *clone(const ActionGroupList &grouplist) const {
342  if (!grouplist.contains(getGroup())) return (Action *)0;
343  return new ActionMarkIndirectOnly(getGroup());
344  }
345  virtual int4 apply(Funcdata &data) {
346  data.markIndirectOnly(); return 0; }
347 };
348 
350 class ActionMergeRequired : public Action {
351 public:
352  ActionMergeRequired(const string &g) : Action(rule_onceperfunc,"mergerequired",g) {}
353  virtual Action *clone(const ActionGroupList &grouplist) const {
354  if (!grouplist.contains(getGroup())) return (Action *)0;
355  return new ActionMergeRequired(getGroup());
356  }
357  virtual int4 apply(Funcdata &data) {
358  data.getMerge().mergeAddrTied(); data.getMerge().mergeMarker(); return 0; }
359 };
360 
362 class ActionMergeAdjacent : public Action {
363 public:
364  ActionMergeAdjacent(const string &g) : Action(rule_onceperfunc,"mergeadjacent",g) {}
365  virtual Action *clone(const ActionGroupList &grouplist) const {
366  if (!grouplist.contains(getGroup())) return (Action *)0;
367  return new ActionMergeAdjacent(getGroup());
368  }
369  virtual int4 apply(Funcdata &data) { data.getMerge().mergeAdjacent(); return 0; }
370 };
371 
373 class ActionMergeCopy : public Action {
374 public:
375  ActionMergeCopy(const string &g) : Action(rule_onceperfunc,"mergecopy",g) {}
376  virtual Action *clone(const ActionGroupList &grouplist) const {
377  if (!grouplist.contains(getGroup())) return (Action *)0;
378  return new ActionMergeCopy(getGroup());
379  }
380  virtual int4 apply(Funcdata &data) { data.getMerge().mergeOpcode(CPUI_COPY); return 0; }
381 };
382 
385 public:
386  ActionMergeMultiEntry(const string &g) : Action(rule_onceperfunc,"mergemultientry",g) {}
387  virtual Action *clone(const ActionGroupList &grouplist) const {
388  if (!grouplist.contains(getGroup())) return (Action *)0;
389  return new ActionMergeMultiEntry(getGroup());
390  }
391  virtual int4 apply(Funcdata &data) { data.getMerge().mergeMultiEntry(); return 0; }
392 };
393 
395 class ActionMergeType : public Action {
396 public:
397  ActionMergeType(const string &g) : Action(rule_onceperfunc,"mergetype",g) {}
398  virtual Action *clone(const ActionGroupList &grouplist) const {
399  if (!grouplist.contains(getGroup())) return (Action *)0;
400  return new ActionMergeType(getGroup());
401  }
402  virtual int4 apply(Funcdata &data) {
403  data.getMerge().mergeByDatatype(data.beginLoc(),data.endLoc()); return 0; }
404 };
405 
415 class ActionMarkExplicit : public Action {
417  struct OpStackElement {
418  Varnode *vn;
419  int4 slot;
420  int4 slotback;
421  OpStackElement(Varnode *v);
422  };
423  static int4 baseExplicit(Varnode *vn,int4 maxref);
424  static int4 multipleInteraction(vector<Varnode *> &multlist);
425  static void processMultiplier(Varnode *vn,int4 max);
426  static void checkNewToConstructor(Funcdata &data,Varnode *vn);
427 public:
428  ActionMarkExplicit(const string &g) : Action(rule_onceperfunc,"markexplicit",g) {}
429  virtual Action *clone(const ActionGroupList &grouplist) const {
430  if (!grouplist.contains(getGroup())) return (Action *)0;
431  return new ActionMarkExplicit(getGroup());
432  }
433  virtual int4 apply(Funcdata &data);
434 };
435 
437 class ActionMarkImplied : public Action {
439  struct DescTreeElement {
440  Varnode *vn;
441  list<PcodeOp *>::const_iterator desciter;
442  DescTreeElement(Varnode *v) {
443  vn = v; desciter = v->beginDescend(); }
444  };
445  static bool isPossibleAliasStep(Varnode *vn1,Varnode *vn2);
446  static bool isPossibleAlias(Varnode *vn1,Varnode *vn2,int4 depth);
447  static bool checkImpliedCover(Funcdata &data,Varnode *vn);
448 public:
449  ActionMarkImplied(const string &g) : Action(rule_onceperfunc,"markimplied",g) {}
450  virtual Action *clone(const ActionGroupList &grouplist) const {
451  if (!grouplist.contains(getGroup())) return (Action *)0;
452  return new ActionMarkImplied(getGroup());
453  }
454  virtual int4 apply(Funcdata &data);
455 };
456 
458 class ActionNameVars : public Action {
460  struct OpRecommend {
461  Datatype *ct;
462  string namerec;
463  };
464  static void makeRec(ProtoParameter *param,Varnode *vn,map<HighVariable *,OpRecommend> &recmap);
465  static void lookForBadJumpTables(Funcdata &data);
466  static void lookForFuncParamNames(Funcdata &data,const vector<Varnode *> &varlist);
467  static void linkSpacebaseSymbol(Varnode *vn,Funcdata &data,vector<Varnode *> &namerec);
468  static void linkSymbols(Funcdata &data,vector<Varnode *> &namerec);
469 public:
470  ActionNameVars(const string &g) : Action(rule_onceperfunc,"namevars",g) {}
471  virtual Action *clone(const ActionGroupList &grouplist) const {
472  if (!grouplist.contains(getGroup())) return (Action *)0;
473  return new ActionNameVars(getGroup());
474  }
475  virtual int4 apply(Funcdata &data);
476 };
477 
479 class ActionUnreachable : public Action {
480 public:
481  ActionUnreachable(const string &g) : Action(0,"unreachable",g) {}
482  virtual Action *clone(const ActionGroupList &grouplist) const {
483  if (!grouplist.contains(getGroup())) return (Action *)0;
484  return new ActionUnreachable(getGroup());
485  }
486  virtual int4 apply(Funcdata &data);
487 };
488 
490 class ActionDoNothing : public Action {
491 public:
492  ActionDoNothing(const string &g) : Action(rule_repeatapply,"donothing",g) {}
493  virtual Action *clone(const ActionGroupList &grouplist) const {
494  if (!grouplist.contains(getGroup())) return (Action *)0;
495  return new ActionDoNothing(getGroup());
496  }
497  virtual int4 apply(Funcdata &data);
498 };
499 
501 class ActionRedundBranch : public Action {
502 public:
503  ActionRedundBranch(const string &g) : Action(0,"redundbranch",g) {}
504  virtual Action *clone(const ActionGroupList &grouplist) const {
505  if (!grouplist.contains(getGroup())) return (Action *)0;
506  return new ActionRedundBranch(getGroup());
507  }
508  virtual int4 apply(Funcdata &data);
509 };
510 
513 public:
514  ActionDeterminedBranch(const string &g) : Action(0,"determinedbranch",g) {}
515  virtual Action *clone(const ActionGroupList &grouplist) const {
516  if (!grouplist.contains(getGroup())) return (Action *)0;
517  return new ActionDeterminedBranch(getGroup());
518  }
519  virtual int4 apply(Funcdata &data);
520 };
521 
540 class ActionDeadCode : public Action {
541  static void pushConsumed(uintb val,Varnode *vn,vector<Varnode *> &worklist);
542  static void propagateConsumed(vector<Varnode *> &worklist);
543  static bool neverConsumed(Varnode *vn,Funcdata &data);
544  static void markConsumedParameters(FuncCallSpecs *fc,vector<Varnode *> &worklist);
545  static uintb gatherConsumedReturn(Funcdata &data);
546 public:
547  ActionDeadCode(const string &g) : Action(0,"deadcode",g) {}
548  virtual Action *clone(const ActionGroupList &grouplist) const {
549  if (!grouplist.contains(getGroup())) return (Action *)0;
550  return new ActionDeadCode(getGroup());
551  }
552  virtual int4 apply(Funcdata &data);
553 };
554 
557 public:
558  ActionConditionalConst(const string &g) : Action(0,"condconst",g) {}
559  virtual Action *clone(const ActionGroupList &grouplist) const {
560  if (!grouplist.contains(getGroup())) return (Action *)0;
561  return new ActionConditionalConst(getGroup());
562  }
563  virtual int4 apply(Funcdata &data);
564  void propagateConstant(Varnode *varVn,Varnode *constVn,FlowBlock *constBlock,Funcdata &data);
565 };
566 
571 class ActionSwitchNorm : public Action {
572 public:
573  ActionSwitchNorm(const string &g) : Action(0,"switchnorm",g) {}
574  virtual Action *clone(const ActionGroupList &grouplist) const {
575  if (!grouplist.contains(getGroup())) return (Action *)0;
576  return new ActionSwitchNorm(getGroup());
577  }
578  virtual int4 apply(Funcdata &data);
579 };
580 
592 class ActionNormalizeSetup : public Action {
593 public:
594  ActionNormalizeSetup(const string &g) : Action(rule_onceperfunc,"normalizesetup",g) {}
595  virtual Action *clone(const ActionGroupList &grouplist) const {
596  if (!grouplist.contains(getGroup())) return (Action *)0;
597  return new ActionNormalizeSetup(getGroup());
598  }
599  virtual int4 apply(Funcdata &data);
600 };
601 
608 public:
609  void extendInput(Funcdata &data,Varnode *invn,ProtoParameter *param,BlockBasic *topbl);
610  ActionPrototypeTypes(const string &g) : Action(rule_onceperfunc,"prototypetypes",g) {}
611  virtual Action *clone(const ActionGroupList &grouplist) const {
612  if (!grouplist.contains(getGroup())) return (Action *)0;
613  return new ActionPrototypeTypes(getGroup());
614  }
615  virtual int4 apply(Funcdata &data);
616 };
617 
623 class ActionDefaultParams : public Action {
624 public:
625  ActionDefaultParams(const string &g) : Action(rule_onceperfunc,"defaultparams",g) {}
626  virtual Action *clone(const ActionGroupList &grouplist) const {
627  if (!grouplist.contains(getGroup())) return (Action *)0;
628  return new ActionDefaultParams(getGroup());
629  }
630  virtual int4 apply(Funcdata &data);
631 };
632 
640 class ActionExtraPopSetup : public Action {
641  AddrSpace *stackspace;
642 public:
643  ActionExtraPopSetup(const string &g,AddrSpace *ss) : Action(rule_onceperfunc,"extrapopsetup",g) { stackspace = ss; }
644  virtual Action *clone(const ActionGroupList &grouplist) const {
645  if (!grouplist.contains(getGroup())) return (Action *)0;
646  return new ActionExtraPopSetup(getGroup(),stackspace);
647  }
648  virtual int4 apply(Funcdata &data);
649 };
650 
656 class ActionFuncLink : public Action {
657  friend class ActionFuncLinkOutOnly;
658  static void funcLinkInput(FuncCallSpecs *fc,Funcdata &data);
659  static void funcLinkOutput(FuncCallSpecs *fc,Funcdata &data);
660 public:
661  ActionFuncLink(const string &g) : Action(rule_onceperfunc,"funclink",g) {}
662  virtual Action *clone(const ActionGroupList &grouplist) const {
663  if (!grouplist.contains(getGroup())) return (Action *)0;
664  return new ActionFuncLink(getGroup());
665  }
666  virtual int4 apply(Funcdata &data);
667 };
668 
678 public:
679  ActionFuncLinkOutOnly(const string &g) : Action(rule_onceperfunc,"funclink_outonly",g) {}
680  virtual Action *clone(const ActionGroupList &grouplist) const {
681  if (!grouplist.contains(getGroup())) return (Action *)0;
682  return new ActionFuncLinkOutOnly(getGroup());
683  }
684  virtual int4 apply(Funcdata &data);
685 };
686 
694 class ActionParamDouble : public Action {
695 public:
696  ActionParamDouble(const string &g) : Action(0, "paramdouble",g) {}
697  virtual Action *clone(const ActionGroupList &grouplist) const {
698  if (!grouplist.contains(getGroup())) return (Action *)0;
699  return new ActionParamDouble(getGroup());
700  }
701  virtual int4 apply(Funcdata &data);
702 };
703 
712 class ActionActiveParam : public Action {
713 public:
714  ActionActiveParam(const string &g) : Action( 0, "activeparam",g) {}
715  virtual Action *clone(const ActionGroupList &grouplist) const {
716  if (!grouplist.contains(getGroup())) return (Action *)0;
717  return new ActionActiveParam(getGroup());
718  }
719  virtual int4 apply(Funcdata &data);
720 };
721 
725 class ActionActiveReturn : public Action {
726 public:
727  ActionActiveReturn(const string &g) : Action( 0, "activereturn",g) {}
728  virtual Action *clone(const ActionGroupList &grouplist) const {
729  if (!grouplist.contains(getGroup())) return (Action *)0;
730  return new ActionActiveReturn(getGroup());
731  }
732  virtual int4 apply(Funcdata &data);
733 };
734 
735 // \brief If there are any sub-function calls with \e paramshifts, add the shifted parameters.
736 // class ActionParamShiftStart : public Action {
737 // public:
738 // ActionParamShiftStart(const string &g) : Action( rule_onceperfunc, "paramshiftstart",g) {} ///< Constructor
739 // virtual Action *clone(const ActionGroupList &grouplist) const {
740 // if (!grouplist.contains(getGroup())) return (Action *)0;
741 // return new ActionParamShiftStart(getGroup());
742 // }
743 // virtual int4 apply(Funcdata &data);
744 // };
745 
746 // \brief If there are any sub-function calls with \e paramshifts, remove the shifted parameters.
747 // class ActionParamShiftStop : public Action {
748 // bool paramshiftsleft;
749 // public:
750 // ActionParamShiftStop(const string &g) : Action( 0, "paramshiftstop",g) {} ///< Constructor
751 // virtual void reset(Funcdata &data) { paramshiftsleft = true; }
752 // virtual Action *clone(const ActionGroupList &grouplist) const {
753 // if (!grouplist.contains(getGroup())) return (Action *)0;
754 // return new ActionParamShiftStop(getGroup());
755 // }
756 // virtual int4 apply(Funcdata &data);
757 // };
758 
760 class ActionReturnRecovery : public Action {
761  static void buildReturnOutput(ParamActive *active,PcodeOp *retop,Funcdata &data);
762 public:
763  ActionReturnRecovery(const string &g) : Action( 0, "returnrecovery",g) {}
764  virtual Action *clone(const ActionGroupList &grouplist) const {
765  if (!grouplist.contains(getGroup())) return (Action *)0;
766  return new ActionReturnRecovery(getGroup());
767  }
768  virtual int4 apply(Funcdata &data);
769 };
770 
775 class ActionRestrictLocal : public Action {
776 public:
777  ActionRestrictLocal(const string &g) : Action(0,"restrictlocal",g) {}
778  virtual Action *clone(const ActionGroupList &grouplist) const {
779  if (!grouplist.contains(getGroup())) return (Action *)0;
780  return new ActionRestrictLocal(getGroup());
781  }
782  virtual int4 apply(Funcdata &data);
783 };
784 
797 class ActionLikelyTrash : public Action {
798  static uint4 countMarks(PcodeOp *op);
799  static bool traceTrash(Varnode *vn,vector<PcodeOp *> &indlist);
800 public:
801  ActionLikelyTrash(const string &g) : Action(0,"likelytrash",g) {}
802  virtual Action *clone(const ActionGroupList &grouplist) const {
803  if (!grouplist.contains(getGroup())) return (Action *)0;
804  return new ActionLikelyTrash(getGroup());
805  }
806  virtual int4 apply(Funcdata &data);
807 };
808 
813  int4 numpass;
814 public:
815  ActionRestructureVarnode(const string &g) : Action(0,"restructure_varnode",g) {}
816  virtual void reset(Funcdata &data) { numpass = 0; }
817  virtual Action *clone(const ActionGroupList &grouplist) const {
818  if (!grouplist.contains(getGroup())) return (Action *)0;
819  return new ActionRestructureVarnode(getGroup());
820  }
821  virtual int4 apply(Funcdata &data);
822 };
823 
828 public:
829  ActionRestructureHigh(const string &g) : Action(0,"restructure_high",g) {}
830  virtual Action *clone(const ActionGroupList &grouplist) const {
831  if (!grouplist.contains(getGroup())) return (Action *)0;
832  return new ActionRestructureHigh(getGroup());
833  }
834  virtual int4 apply(Funcdata &data);
835 };
836 
838 class ActionMapGlobals : public Action {
839 public:
840  ActionMapGlobals(const string &g) : Action(rule_onceperfunc,"mapglobals",g) {}
841  virtual Action *clone(const ActionGroupList &grouplist) const {
842  if (!grouplist.contains(getGroup())) return (Action *)0;
843  return new ActionMapGlobals(getGroup());
844  }
845  virtual int4 apply(Funcdata &data) { data.mapGlobals(); return 0; }
846 };
847 
852 class ActionInputPrototype : public Action {
853 public:
854  ActionInputPrototype(const string &g) : Action(rule_onceperfunc,"inputprototype",g) {}
855  virtual Action *clone(const ActionGroupList &grouplist) const {
856  if (!grouplist.contains(getGroup())) return (Action *)0;
857  return new ActionInputPrototype(getGroup());
858  }
859  virtual int4 apply(Funcdata &data);
860 };
861 
864 public:
865  ActionOutputPrototype(const string &g) : Action(rule_onceperfunc,"outputprototype",g) {}
866  virtual Action *clone(const ActionGroupList &grouplist) const {
867  if (!grouplist.contains(getGroup())) return (Action *)0;
868  return new ActionOutputPrototype(getGroup());
869  }
870  virtual int4 apply(Funcdata &data);
871 };
872 
879 public:
880  ActionUnjustifiedParams(const string &g) : Action(0,"unjustparams",g) {}
881  virtual Action *clone(const ActionGroupList &grouplist) const {
882  if (!grouplist.contains(getGroup())) return (Action *)0;
883  return new ActionUnjustifiedParams(getGroup());
884  }
885  virtual int4 apply(Funcdata &data);
886 };
887 
920 class ActionInferTypes : public Action {
921 #ifdef TYPEPROP_DEBUG
922  static void propagationDebug(Architecture *glb,Varnode *vn,const Datatype *newtype,PcodeOp *op,int4 slot,Varnode *ptralias);
923 #endif
924  int4 localcount;
925  static void buildLocaltypes(Funcdata &data);
926  static bool writeBack(Funcdata &data);
927  static int4 propagateAddPointer(PcodeOp *op,int4 slot);
928  static Datatype *propagateAddIn2Out(TypeFactory *typegrp,PcodeOp *op,int4 inslot);
929  static bool propagateGoodEdge(PcodeOp *op,int4 inslot,int4 outslot,Varnode *invn);
930  static bool propagateTypeEdge(TypeFactory *typegrp,PcodeOp *op,int4 inslot,int4 outslot);
931  static void propagateOneType(TypeFactory *typegrp,Varnode *vn);
932  static void propagateRef(Funcdata &data,Varnode *vn,const Address &addr);
933  static void propagateSpacebaseRef(Funcdata &data,Varnode *spcvn);
934  static PcodeOp *canonicalReturnOp(Funcdata &data);
935  static void propagateAcrossReturns(Funcdata &data);
936 public:
937  ActionInferTypes(const string &g) : Action(0,"infertypes",g) {}
938  virtual void reset(Funcdata &data) { localcount = 0; }
939  virtual Action *clone(const ActionGroupList &grouplist) const {
940  if (!grouplist.contains(getGroup())) return (Action *)0;
941  return new ActionInferTypes(getGroup());
942  }
943  virtual int4 apply(Funcdata &data);
944 };
945 
953 class ActionHideShadow : public Action {
954 public:
955  ActionHideShadow(const string &g) : Action(rule_onceperfunc,"hideshadow",g) {}
956  virtual Action *clone(const ActionGroupList &grouplist) const {
957  if (!grouplist.contains(getGroup())) return (Action *)0;
958  return new ActionHideShadow(getGroup());
959  }
960  virtual int4 apply(Funcdata &data);
961 };
962 
964 class ActionDominantCopy : public Action {
965 public:
966  ActionDominantCopy(const string &g) : Action(rule_onceperfunc,"dominantcopy",g) {}
967  virtual Action *clone(const ActionGroupList &grouplist) const {
968  if (!grouplist.contains(getGroup())) return (Action *)0;
969  return new ActionDominantCopy(getGroup());
970  }
971  virtual int4 apply(Funcdata &data) { data.getMerge().processCopyTrims(); return 0; }
972 };
973 
975 class ActionCopyMarker : public Action {
976 public:
977  ActionCopyMarker(const string &g) : Action(rule_onceperfunc,"copymarker",g) {}
978  virtual Action *clone(const ActionGroupList &grouplist) const {
979  if (!grouplist.contains(getGroup())) return (Action *)0;
980  return new ActionCopyMarker(getGroup());
981  }
982  virtual int4 apply(Funcdata &data) { data.getMerge().markInternalCopies(); return 0; }
983 };
984 
986 class ActionDynamicMapping : public Action {
987 public:
988  ActionDynamicMapping(const string &g) : Action(0,"dynamicmapping",g) {}
989  virtual Action *clone(const ActionGroupList &grouplist) const {
990  if (!grouplist.contains(getGroup())) return (Action *)0;
991  return new ActionDynamicMapping(getGroup());
992  }
993  virtual int4 apply(Funcdata &data);
994 };
995 
997 class ActionDynamicSymbols : public Action {
998 public:
999  ActionDynamicSymbols(const string &g) : Action(rule_onceperfunc,"dynamicsymbols",g) {}
1000  virtual Action *clone(const ActionGroupList &grouplist) const {
1001  if (!grouplist.contains(getGroup())) return (Action *)0;
1002  return new ActionDynamicSymbols(getGroup());
1003  }
1004  virtual int4 apply(Funcdata &data);
1005 };
1006 
1009 public:
1010  ActionPrototypeWarnings(const string &g) : Action(rule_onceperfunc,"prototypewarnings",g) {}
1011  virtual Action *clone(const ActionGroupList &grouplist) const {
1012  if (!grouplist.contains(getGroup())) return (Action *)0;
1013  return new ActionPrototypeWarnings(getGroup());
1014  }
1015  virtual int4 apply(Funcdata &data);
1016 };
1017 
1018 extern void universal_action(Architecture *conf);
1019 extern void build_defaultactions(ActionDatabase &allacts);
1020 
1026 public:
1028  list<PcodeOp *>::const_iterator iter;
1030  int4 inslot;
1031  int4 slot;
1033  void step(void);
1034  bool valid(void) const { return (op != (PcodeOp *)0); }
1035 };
1036 
1039  PcodeOp *op;
1040  int4 slot;
1041  Varnode *vn;
1042  PcodeOp *mult;
1043 public:
1044  PcodeOpEdge(PcodeOp *o,int4 s,PcodeOp *m) { op = o; slot = s; vn = op->getIn(slot); mult=m; }
1045  PcodeOp *getMultiplier(void) const { return mult; }
1046  PcodeOp *getOp(void) const { return op; }
1047  int4 getSlot(void) const { return slot; }
1048  Varnode *getVarnode(void) const { return vn; }
1049 };
1050 
1056 class TermOrder {
1057  PcodeOp *root;
1058  vector<PcodeOpEdge> terms;
1059  vector<PcodeOpEdge *> sorter;
1060  static bool additiveCompare(const PcodeOpEdge *op1,const PcodeOpEdge *op2);
1061 public:
1062  TermOrder(PcodeOp *rt) { root = rt; }
1063  int4 getSize(void) const { return terms.size(); }
1064  void collect(void);
1065  void sortTerms(void);
1066  const vector<PcodeOpEdge *> &getSort(void) { return sorter; }
1067 };
1068 
1076 inline bool TermOrder::additiveCompare(const PcodeOpEdge *op1,const PcodeOpEdge *op2) {
1077  return (-1 == op1->getVarnode()->termOrder(op2->getVarnode())); }
1078 
1079 #endif
ActionRedundBranch(const string &g)
Constructor.
Definition: coreaction.hh:503
PcodeOp * op
The current descendant or the defining PcodeOp.
Definition: coreaction.hh:1029
void mergeAdjacent(void)
Speculatively merge Varnodes that are input/output to the same p-code op.
Definition: merge.cc:881
void stopProcessing(void)
Mark that processing has completed for this function.
Definition: funcdata.cc:144
A region where processor data is stored.
Definition: space.hh:73
A class for analyzing parameters to a sub-function call.
Definition: fspec.hh:1436
Make sure pointers into segmented spaces have the correct form.
Definition: coreaction.hh:121
Deal with situations that look like double precision parameters.
Definition: coreaction.hh:694
Description of a control-flow block containing PcodeOps.
Definition: block.hh:60
Search for input Varnodes that have been officially provided constant values.
Definition: coreaction.hh:253
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:319
Locate shadow Varnodes and adjust them so they are hidden.
Definition: coreaction.hh:953
Normalize jump-table construction.
Definition: coreaction.hh:571
The base datatype class for the decompiler.
Definition: type.hh:62
Check for constants, with pointer type, that correspond to global symbols.
Definition: coreaction.hh:181
ActionMapGlobals(const string &g)
Constructor.
Definition: coreaction.hh:840
void calcNZMask(void)
Calculate non-zero masks for all Varnodes.
Definition: funcdata_varnode.cc:720
Eliminate locally constant indirect calls.
Definition: coreaction.hh:198
Gather raw p-code for a function.
Definition: coreaction.hh:32
ActionForceGoto(const string &g)
Constructor.
Definition: coreaction.hh:136
A storage location for a particular Symbol.
Definition: database.hh:51
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:398
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:376
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:380
A class that holds a data-type traversal state during type propagation.
Definition: coreaction.hh:1025
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:256
Allow type recovery to start happening.
Definition: coreaction.hh:68
ActionDeindirect(const string &g)
Constructor.
Definition: coreaction.hh:200
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:173
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:728
ActionMergeCopy(const string &g)
Constructor.
Definition: coreaction.hh:375
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:845
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:971
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:353
const string & getGroup(void) const
Get the Action&#39;s group.
Definition: action.hh:106
The list of groups defining a root Action.
Definition: action.hh:29
ActionStartTypes(const string &g)
Constructor.
Definition: coreaction.hh:70
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:93
void markIndirectOnly(void)
Mark illegal input Varnodes used only in INDIRECTs.
Definition: funcdata_varnode.cc:679
Apply rule once per function.
Definition: action.hh:55
Container for data structures associated with a single function.
Definition: funcdata.hh:45
int4 getSlot(void) const
Get the slot reading the term.
Definition: coreaction.hh:1047
ActionDoNothing(const string &g)
Constructor.
Definition: coreaction.hh:492
ActionMarkImplied(const string &g)
Constructor.
Definition: coreaction.hh:449
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:189
ActionRestructureHigh(const string &g)
Constructor.
Definition: coreaction.hh:829
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:574
Choose names for all high-level variables (HighVariables)
Definition: coreaction.hh:458
void processCopyTrims(void)
Try to reduce/eliminate COPYs produced by the merge trimming process.
Definition: merge.cc:1265
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:967
VarnodeLocSet::const_iterator endLoc(void) const
End of all Varnodes sorted by storage.
Definition: funcdata.hh:301
Remove blocks that do nothing.
Definition: coreaction.hh:490
Prepare function prototypes for "normalize" simplification.
Definition: coreaction.hh:592
ActionDefaultParams(const string &g)
Constructor.
Definition: coreaction.hh:625
ActionInferTypes(const string &g)
Constructor.
Definition: coreaction.hh:937
ActionVarnodeProps(const string &g)
Constructor.
Definition: coreaction.hh:218
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:626
Make required Varnode merges as dictated by CPUI_MULTIEQUAL, CPUI_INDIRECT, and addrtied property...
Definition: coreaction.hh:350
void mapGlobals(void)
Make sure there is a Symbol entry for all global Varnodes.
Definition: funcdata_varnode.cc:1302
Do any post-processing after decompilation.
Definition: coreaction.hh:44
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:137
ActionSwitchNorm(const string &g)
Constructor.
Definition: coreaction.hh:573
void mergeByDatatype(VarnodeLocSet::const_iterator startiter, VarnodeLocSet::const_iterator enditer)
Try to merge all HighVariables in the given range that have the same data-type.
Definition: merge.cc:298
Analyze change to the stack pointer across sub-function calls.
Definition: coreaction.hh:82
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:402
Varnode * getIn(int4 slot)
Get a specific input Varnode to this op.
Definition: op.hh:147
Remove conditional branches if the condition is constant.
Definition: coreaction.hh:512
ActionActiveParam(const string &g)
Constructor.
Definition: coreaction.hh:714
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:989
int4 slot
Current edge relative to current PcodeOp.
Definition: coreaction.hh:1031
PcodeOpEdge(PcodeOp *o, int4 s, PcodeOp *m)
Constructor.
Definition: coreaction.hh:1044
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:778
Determine data-flow holding the return value of the function.
Definition: coreaction.hh:760
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:126
bool contains(const string &nm) const
Check if this ActionGroupList contains a given group.
Definition: action.hh:37
Lay down locked input and output data-type information.
Definition: coreaction.hh:607
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:39
ActionDirectWrite(const string &g, bool prop)
Constructor.
Definition: coreaction.hh:240
Build Static Single Assignment (SSA) representation for function.
Definition: coreaction.hh:276
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:294
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:387
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:162
Find explicit Varnodes: Varnodes that have an explicit token representing them in the output...
Definition: coreaction.hh:415
void startCleanUp(void)
Start clean-up phase.
Definition: funcdata.hh:161
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:279
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:938
Merge & getMerge(void)
Get the Merge object for this function.
Definition: funcdata.hh:395
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:75
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:855
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:471
ActionDominantCopy(const string &g)
Constructor.
Definition: coreaction.hh:966
Attach dynamically mapped symbols to Varnodes in time for data-type propagation.
Definition: coreaction.hh:986
ActionDynamicMapping(const string &g)
Constructor.
Definition: coreaction.hh:988
void mergeMultiEntry(void)
Merge together Varnodes mapped to SymbolEntrys from the same Symbol.
Definition: merge.cc:819
int4 inslot
Slot holding Varnode for descendant PcodeOp.
Definition: coreaction.hh:1030
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:290
TermOrder(PcodeOp *rt)
Construct given root PcodeOp.
Definition: coreaction.hh:1062
Create symbols that map out the local stack-frame for the function.
Definition: coreaction.hh:827
Calculate the prototype for the function.
Definition: coreaction.hh:852
Add warnings for prototypes that aren&#39;t modeled properly.
Definition: coreaction.hh:1008
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:201
Calculate the non-zero mask property on all Varnode objects.
Definition: coreaction.hh:287
Make final attachments of dynamically mapped symbols to Varnodes.
Definition: coreaction.hh:997
Actions and classes associated with transforming and structuring the control-flow graph...
PcodeOp * getOp(void) const
Get the component PcodeOp adding in the term.
Definition: coreaction.hh:1046
Mark COPY operations between Varnodes representing the object as non-printing.
Definition: coreaction.hh:975
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:881
Large scale transformations applied to the varnode/op graph.
Definition: action.hh:50
Propagate conditional constants.
Definition: coreaction.hh:556
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:341
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:267
Apply any overridden forced gotos.
Definition: coreaction.hh:134
Dead code removal. Eliminate dead p-code ops.
Definition: coreaction.hh:540
ActionActiveReturn(const string &g)
Constructor.
Definition: coreaction.hh:727
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:515
ActionShadowVar(const string &g)
Constructor.
Definition: coreaction.hh:172
ActionPrototypeTypes(const string &g)
Constructor.
Definition: coreaction.hh:610
ActionMarkExplicit(const string &g)
Constructor.
Definition: coreaction.hh:428
Try to merge an op&#39;s input Varnode to its output, if they are at the same storage location...
Definition: coreaction.hh:362
Mark all the implied Varnode objects, which will have no explicit token in the output.
Definition: coreaction.hh:437
ActionMergeType(const string &g)
Constructor.
Definition: coreaction.hh:397
Utilities for processing data structures associated with a single function.
PcodeOp * getMultiplier(void) const
Get the multiplier PcodeOp.
Definition: coreaction.hh:1045
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:482
A strategy for applying type casts.
Definition: cast.hh:40
void mergeMarker(void)
Force the merge of input and output Varnodes to MULTIEQUAL and INDIRECT ops.
Definition: merge.cc:800
void setHighLevel(void)
Turn on HighVariable objects for all Varnodes.
Definition: funcdata_varnode.cc:471
A class for ordering Varnode terms in an additive expression.
Definition: coreaction.hh:1056
Copy one operand to another.
Definition: opcodes.hh:36
ActionMarkIndirectOnly(const string &g)
Constructor.
Definition: coreaction.hh:340
ActionStop(const string &g)
Constructor.
Definition: coreaction.hh:46
bool valid(void) const
Return true if there are edges left to iterate.
Definition: coreaction.hh:1034
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:680
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:1000
Lowest level operation of the p-code language.
Definition: op.hh:58
Find Varnodes with a vectorized lane scheme and attempt to split the lanes.
Definition: coreaction.hh:106
ActionConstbase(const string &g)
Constructor.
Definition: coreaction.hh:255
VarnodeLocSet::const_iterator beginLoc(void) const
Start of all Varnodes sorted by storage.
Definition: funcdata.hh:298
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
ActionRestructureVarnode(const string &g)
Constructor.
Definition: coreaction.hh:815
Get rid of registers with trash values.
Definition: coreaction.hh:797
Create symbols for any discovered global variables in the function.
Definition: coreaction.hh:838
ActionAssignHigh(const string &g)
Constructor.
Definition: coreaction.hh:329
Find a prototype for each sub-function.
Definition: coreaction.hh:623
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:92
Try to merge Varnodes specified by Symbols with multiple SymbolEntrys.
Definition: coreaction.hh:384
Mark illegal Varnode inputs used only in CPUI_INDIRECT ops.
Definition: coreaction.hh:338
Mark Varnode objects that hold stack-pointer values and set-up special data-type. ...
Definition: coreaction.hh:264
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:429
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:111
ActionSetCasts(const string &g)
Constructor.
Definition: coreaction.hh:318
int4 termOrder(const Varnode *op) const
Compare two Varnodes based on their term order.
Definition: varnode.cc:791
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:715
Manager for all the major decompiler subsystems.
Definition: architecture.hh:117
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:369
Mark Varnodes built out of legal parameters.
Definition: coreaction.hh:237
ActionPrototypeWarnings(const string &g)
Constructor.
Definition: coreaction.hh:1010
Fill-in CPUI_CAST p-code ops as required by the casting strategy.
Definition: coreaction.hh:314
ActionConditionalConst(const string &g)
Constructor.
Definition: coreaction.hh:558
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:1011
Adjust improperly justified parameters.
Definition: coreaction.hh:878
Restrict possible range of local variables.
Definition: coreaction.hh:775
ActionMultiCse(const string &g)
Constructor.
Definition: coreaction.hh:161
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:939
Apply rule repeatedly until no change.
Definition: action.hh:54
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
ActionDeterminedBranch(const string &g)
Constructor.
Definition: coreaction.hh:514
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:219
A basic block for p-code operations.
Definition: block.hh:363
ActionSpacebase(const string &g)
Constructor.
Definition: coreaction.hh:266
ActionExtraPopSetup(const string &g, AddrSpace *ss)
Constructor.
Definition: coreaction.hh:643
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:841
ActionLikelyTrash(const string &g)
Constructor.
Definition: coreaction.hh:801
ActionUnjustifiedParams(const string &g)
Constructor.
Definition: coreaction.hh:880
ActionStackPtrFlow(const string &g, AddrSpace *ss)
Constructor.
Definition: coreaction.hh:91
Infer and propagate data-types.
Definition: coreaction.hh:920
void universal_action(Architecture *conf)
The generic decompilation action.
Definition: coreaction.cc:4769
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:365
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:71
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:283
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:548
ActionInputPrototype(const string &g)
Constructor.
Definition: coreaction.hh:854
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:978
Set the (already) recovered output data-type as a formal part of the prototype.
Definition: coreaction.hh:863
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:330
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:816
Define formal link between stack-pointer values before and after sub-function calls.
Definition: coreaction.hh:640
ActionLaneDivide(const string &g)
Constructor.
Definition: coreaction.hh:110
ActionOutputPrototype(const string &g)
Constructor.
Definition: coreaction.hh:865
Check for one CPUI_MULTIEQUAL input set defining more than one Varnode.
Definition: coreaction.hh:170
Assign initial high-level HighVariable objects to each Varnode.
Definition: coreaction.hh:327
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:357
Try to merge the input and output Varnodes of a CPUI_COPY op.
Definition: coreaction.hh:373
Varnode * getVarnode(void) const
Get the Varnode term.
Definition: coreaction.hh:1048
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:764
Class representing a term in an additive expression.
Definition: coreaction.hh:1038
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:345
Remove unreachable blocks.
Definition: coreaction.hh:479
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:644
ActionCopyMarker(const string &g)
Constructor.
Definition: coreaction.hh:977
int4 getSize(void) const
Get the number of terms in the expression.
Definition: coreaction.hh:1063
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:817
list< PcodeOp * >::const_iterator beginDescend(void) const
Get iterator to list of syntax tree descendants (reads)
Definition: varnode.hh:184
Transform based on Varnode properties, such as read-only and volatile.
Definition: coreaction.hh:215
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:595
void build_defaultactions(ActionDatabase &allacts)
Build the default actions.
Definition: coreaction.cc:4729
ActionDeadCode(const string &g)
Constructor.
Definition: coreaction.hh:547
void mergeOpcode(OpCode opc)
Try to force merges of input to output for all p-code ops of a given type.
Definition: merge.cc:265
ActionHeritage(const string &g)
Constructor.
Definition: coreaction.hh:278
list< PcodeOp * >::const_iterator iter
Iterator to current descendant being enumerated.
Definition: coreaction.hh:1028
Container class for all Datatype objects in an Architecture.
Definition: type.hh:380
Determine which sub-functions have active output Varnodes.
Definition: coreaction.hh:725
ActionStartCleanUp(const string &g)
Constructor.
Definition: coreaction.hh:58
ActionMergeAdjacent(const string &g)
Constructor.
Definition: coreaction.hh:364
void opHeritage(void)
Perform an entire heritage pass linking Varnode reads to writes.
Definition: funcdata.hh:415
Get rid of redundant branches: duplicate edges between the same input and output block.
Definition: coreaction.hh:501
ActionMergeRequired(const string &g)
Constructor.
Definition: coreaction.hh:352
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:59
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:493
ActionNormalizeSetup(const string &g)
Constructor.
Definition: coreaction.hh:594
Container class for ParamTrial objects.
Definition: fspec.hh:223
Database of root Action objects that can be used to transform a function.
Definition: action.hh:294
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:982
ActionHideShadow(const string &g)
Constructor.
Definition: coreaction.hh:955
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:51
ActionSegmentize(const string &g)
Constructor.
Definition: coreaction.hh:124
Try to merge Varnodes of the same type (if they don&#39;t hold different values at the same time) ...
Definition: coreaction.hh:395
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:450
Determine active parameters to sub-functions.
Definition: coreaction.hh:712
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:190
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:47
Prepare for data-flow analysis of function parameters, when recovery isn&#39;t required.
Definition: coreaction.hh:677
A function parameter viewed as a name, data-type, and storage address.
Definition: fspec.hh:903
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:271
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:125
Replace COPYs from the same source with a single dominant COPY.
Definition: coreaction.hh:964
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:956
Perform Common Sub-expression Elimination on CPUI_MULTIEQUAL ops.
Definition: coreaction.hh:156
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:611
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:697
bool startTypeRecovery(void)
Mark that data-type analysis has started.
Definition: funcdata.cc:154
ActionParamDouble(const string &g)
Constructor.
Definition: coreaction.hh:696
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:241
const vector< PcodeOpEdge * > & getSort(void)
Get the sorted list of references.
Definition: coreaction.hh:1066
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:866
ActionConstantPtr(const string &g)
Constructor.
Definition: coreaction.hh:188
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:802
void startProcessing(void)
Start processing for this function.
Definition: funcdata.cc:126
Create symbols that map out the local stack-frame for the function.
Definition: coreaction.hh:812
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:334
void spacebase(void)
Mark registers that map to a virtual address space.
Definition: funcdata.cc:202
ActionUnreachable(const string &g)
Constructor.
Definition: coreaction.hh:481
ActionDynamicSymbols(const string &g)
Constructor.
Definition: coreaction.hh:999
ActionRestrictLocal(const string &g)
Constructor.
Definition: coreaction.hh:777
void mergeAddrTied(void)
Force the merge of address tried Varnodes.
Definition: merge.cc:523
ActionNonzeroMask(const string &g)
Constructor.
Definition: coreaction.hh:289
This is the basic set of transformation Rule objects.
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:830
int4 count
Number of changes made by this action so far.
Definition: action.hh:79
void markInternalCopies(void)
Mark redundant/internal COPY PcodeOps.
Definition: merge.cc:1294
ActionMergeMultiEntry(const string &g)
Constructor.
Definition: coreaction.hh:386
ActionNameVars(const string &g)
Constructor.
Definition: coreaction.hh:470
ActionStart(const string &g)
Constructor.
Definition: coreaction.hh:34
Varnode * vn
The root Varnode.
Definition: coreaction.hh:1027
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:391
Describes a (register) storage location and the ways it might be split into lanes.
Definition: transform.hh:88
ActionFuncLinkOutOnly(const string &g)
Constructor.
Definition: coreaction.hh:679
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:63
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:35
ActionReturnRecovery(const string &g)
Constructor.
Definition: coreaction.hh:763
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:559
Start clean up after main transform phase.
Definition: coreaction.hh:56
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:504