Ghidra Decompiler Analysis Engine
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 
214 class ActionVarnodeProps : public Action {
215 public:
216  ActionVarnodeProps(const string &g) : Action(0,"varnodeprops",g) {}
217  virtual Action *clone(const ActionGroupList &grouplist) const {
218  if (!grouplist.contains(getGroup())) return (Action *)0;
219  return new ActionVarnodeProps(getGroup());
220  }
221  virtual int4 apply(Funcdata &data);
222 };
223 
235 class ActionDirectWrite : public Action {
236  bool propagateIndirect;
237 public:
238  ActionDirectWrite(const string &g,bool prop) : Action(0,"directwrite",g) { propagateIndirect=prop; }
239  virtual Action *clone(const ActionGroupList &grouplist) const {
240  if (!grouplist.contains(getGroup())) return (Action *)0;
241  return new ActionDirectWrite(getGroup(),propagateIndirect);
242  }
243  virtual int4 apply(Funcdata &data);
244 };
245 
251 class ActionConstbase : public Action {
252 public:
253  ActionConstbase(const string &g) : Action(0,"constbase",g) {}
254  virtual Action *clone(const ActionGroupList &grouplist) const {
255  if (!grouplist.contains(getGroup())) return (Action *)0;
256  return new ActionConstbase(getGroup());
257  }
258  virtual int4 apply(Funcdata &data);
259 };
260 
262 class ActionSpacebase : public Action {
263 public:
264  ActionSpacebase(const string &g) : Action(0,"spacebase",g) {}
265  virtual Action *clone(const ActionGroupList &grouplist) const {
266  if (!grouplist.contains(getGroup())) return (Action *)0;
267  return new ActionSpacebase(getGroup());
268  }
269  virtual int4 apply(Funcdata &data) {
270  data.spacebase(); return 0; }
271 };
272 
274 class ActionHeritage : public Action {
275 public:
276  ActionHeritage(const string &g) : Action(0,"heritage",g) {}
277  virtual Action *clone(const ActionGroupList &grouplist) const {
278  if (!grouplist.contains(getGroup())) return (Action *)0;
279  return new ActionHeritage(getGroup());
280  }
281  virtual int4 apply(Funcdata &data) { data.opHeritage(); return 0; }
282 };
283 
285 class ActionNonzeroMask : public Action {
286 public:
287  ActionNonzeroMask(const string &g) : Action(0,"nonzeromask",g) {}
288  virtual Action *clone(const ActionGroupList &grouplist) const {
289  if (!grouplist.contains(getGroup())) return (Action *)0;
290  return new ActionNonzeroMask(getGroup());
291  }
292  virtual int4 apply(Funcdata &data) { data.calcNZMask(); return 0; }
293 };
294 
312 class ActionSetCasts : public Action {
313  static int4 castOutput(PcodeOp *op,Funcdata &data,CastStrategy *castStrategy);
314  static int4 castInput(PcodeOp *op,int4 slot,Funcdata &data,CastStrategy *castStrategy);
315 public:
316  ActionSetCasts(const string &g) : Action(rule_onceperfunc,"setcasts",g) {}
317  virtual Action *clone(const ActionGroupList &grouplist) const {
318  if (!grouplist.contains(getGroup())) return (Action *)0;
319  return new ActionSetCasts(getGroup());
320  }
321  virtual int4 apply(Funcdata &data);
322 };
323 
325 class ActionAssignHigh : public Action {
326 public:
327  ActionAssignHigh(const string &g) : Action(rule_onceperfunc,"assignhigh",g) {}
328  virtual Action *clone(const ActionGroupList &grouplist) const {
329  if (!grouplist.contains(getGroup())) return (Action *)0;
330  return new ActionAssignHigh(getGroup());
331  }
332  virtual int4 apply(Funcdata &data) { data.setHighLevel(); return 0; }
333 };
334 
337 public:
338  ActionMarkIndirectOnly(const string &g) : Action(rule_onceperfunc, "markindirectonly",g) {}
339  virtual Action *clone(const ActionGroupList &grouplist) const {
340  if (!grouplist.contains(getGroup())) return (Action *)0;
341  return new ActionMarkIndirectOnly(getGroup());
342  }
343  virtual int4 apply(Funcdata &data) {
344  data.markIndirectOnly(); return 0; }
345 };
346 
348 class ActionMergeRequired : public Action {
349 public:
350  ActionMergeRequired(const string &g) : Action(rule_onceperfunc,"mergerequired",g) {}
351  virtual Action *clone(const ActionGroupList &grouplist) const {
352  if (!grouplist.contains(getGroup())) return (Action *)0;
353  return new ActionMergeRequired(getGroup());
354  }
355  virtual int4 apply(Funcdata &data) {
356  data.getMerge().mergeAddrTied(); data.getMerge().mergeMarker(); return 0; }
357 };
358 
360 class ActionMergeAdjacent : public Action {
361 public:
362  ActionMergeAdjacent(const string &g) : Action(rule_onceperfunc,"mergeadjacent",g) {}
363  virtual Action *clone(const ActionGroupList &grouplist) const {
364  if (!grouplist.contains(getGroup())) return (Action *)0;
365  return new ActionMergeAdjacent(getGroup());
366  }
367  virtual int4 apply(Funcdata &data) { data.getMerge().mergeAdjacent(); return 0; }
368 };
369 
371 class ActionMergeCopy : public Action {
372 public:
373  ActionMergeCopy(const string &g) : Action(rule_onceperfunc,"mergecopy",g) {}
374  virtual Action *clone(const ActionGroupList &grouplist) const {
375  if (!grouplist.contains(getGroup())) return (Action *)0;
376  return new ActionMergeCopy(getGroup());
377  }
378  virtual int4 apply(Funcdata &data) { data.getMerge().mergeOpcode(CPUI_COPY); return 0; }
379 };
380 
383 public:
384  ActionMergeMultiEntry(const string &g) : Action(rule_onceperfunc,"mergemultientry",g) {}
385  virtual Action *clone(const ActionGroupList &grouplist) const {
386  if (!grouplist.contains(getGroup())) return (Action *)0;
387  return new ActionMergeMultiEntry(getGroup());
388  }
389  virtual int4 apply(Funcdata &data) { data.getMerge().mergeMultiEntry(); return 0; }
390 };
391 
393 class ActionMergeType : public Action {
394 public:
395  ActionMergeType(const string &g) : Action(rule_onceperfunc,"mergetype",g) {}
396  virtual Action *clone(const ActionGroupList &grouplist) const {
397  if (!grouplist.contains(getGroup())) return (Action *)0;
398  return new ActionMergeType(getGroup());
399  }
400  virtual int4 apply(Funcdata &data) {
401  data.getMerge().mergeByDatatype(data.beginLoc(),data.endLoc()); return 0; }
402 };
403 
413 class ActionMarkExplicit : public Action {
415  struct OpStackElement {
416  Varnode *vn;
417  int4 slot;
418  int4 slotback;
419  OpStackElement(Varnode *v);
420  };
421  static int4 baseExplicit(Varnode *vn,int4 maxref);
422  static int4 multipleInteraction(vector<Varnode *> &multlist);
423  static void processMultiplier(Varnode *vn,int4 max);
424  static void checkNewToConstructor(Funcdata &data,Varnode *vn);
425 public:
426  ActionMarkExplicit(const string &g) : Action(rule_onceperfunc,"markexplicit",g) {}
427  virtual Action *clone(const ActionGroupList &grouplist) const {
428  if (!grouplist.contains(getGroup())) return (Action *)0;
429  return new ActionMarkExplicit(getGroup());
430  }
431  virtual int4 apply(Funcdata &data);
432 };
433 
435 class ActionMarkImplied : public Action {
437  struct DescTreeElement {
438  Varnode *vn;
439  list<PcodeOp *>::const_iterator desciter;
440  DescTreeElement(Varnode *v) {
441  vn = v; desciter = v->beginDescend(); }
442  };
443  static bool isPossibleAliasStep(Varnode *vn1,Varnode *vn2);
444  static bool isPossibleAlias(Varnode *vn1,Varnode *vn2,int4 depth);
445  static bool checkImpliedCover(Funcdata &data,Varnode *vn);
446 public:
447  ActionMarkImplied(const string &g) : Action(rule_onceperfunc,"markimplied",g) {}
448  virtual Action *clone(const ActionGroupList &grouplist) const {
449  if (!grouplist.contains(getGroup())) return (Action *)0;
450  return new ActionMarkImplied(getGroup());
451  }
452  virtual int4 apply(Funcdata &data);
453 };
454 
456 class ActionNameVars : public Action {
458  struct OpRecommend {
459  Datatype *ct;
460  string namerec;
461  };
462  static void makeRec(ProtoParameter *param,Varnode *vn,map<HighVariable *,OpRecommend> &recmap);
463  static void lookForBadJumpTables(Funcdata &data);
464  static void lookForFuncParamNames(Funcdata &data,const vector<Varnode *> &varlist);
465  static void linkSpacebaseSymbol(Varnode *vn,Funcdata &data,vector<Varnode *> &namerec);
466  static void linkSymbols(Funcdata &data,vector<Varnode *> &namerec);
467 public:
468  ActionNameVars(const string &g) : Action(rule_onceperfunc,"namevars",g) {}
469  virtual Action *clone(const ActionGroupList &grouplist) const {
470  if (!grouplist.contains(getGroup())) return (Action *)0;
471  return new ActionNameVars(getGroup());
472  }
473  virtual int4 apply(Funcdata &data);
474 };
475 
477 class ActionUnreachable : public Action {
478 public:
479  ActionUnreachable(const string &g) : Action(0,"unreachable",g) {}
480  virtual Action *clone(const ActionGroupList &grouplist) const {
481  if (!grouplist.contains(getGroup())) return (Action *)0;
482  return new ActionUnreachable(getGroup());
483  }
484  virtual int4 apply(Funcdata &data);
485 };
486 
488 class ActionDoNothing : public Action {
489 public:
490  ActionDoNothing(const string &g) : Action(rule_repeatapply,"donothing",g) {}
491  virtual Action *clone(const ActionGroupList &grouplist) const {
492  if (!grouplist.contains(getGroup())) return (Action *)0;
493  return new ActionDoNothing(getGroup());
494  }
495  virtual int4 apply(Funcdata &data);
496 };
497 
499 class ActionRedundBranch : public Action {
500 public:
501  ActionRedundBranch(const string &g) : Action(0,"redundbranch",g) {}
502  virtual Action *clone(const ActionGroupList &grouplist) const {
503  if (!grouplist.contains(getGroup())) return (Action *)0;
504  return new ActionRedundBranch(getGroup());
505  }
506  virtual int4 apply(Funcdata &data);
507 };
508 
511 public:
512  ActionDeterminedBranch(const string &g) : Action(0,"determinedbranch",g) {}
513  virtual Action *clone(const ActionGroupList &grouplist) const {
514  if (!grouplist.contains(getGroup())) return (Action *)0;
515  return new ActionDeterminedBranch(getGroup());
516  }
517  virtual int4 apply(Funcdata &data);
518 };
519 
538 class ActionDeadCode : public Action {
539  static void pushConsumed(uintb val,Varnode *vn,vector<Varnode *> &worklist);
540  static void propagateConsumed(vector<Varnode *> &worklist);
541  static bool neverConsumed(Varnode *vn,Funcdata &data);
542  static void markConsumedParameters(FuncCallSpecs *fc,vector<Varnode *> &worklist);
543  static uintb gatherConsumedReturn(Funcdata &data);
544  static bool isEventualConstant(Varnode *vn,int4 addCount,int4 loadCount);
545  static bool lastChanceLoad(Funcdata &data,vector<Varnode *> &worklist);
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 
1023 public:
1025  list<PcodeOp *>::const_iterator iter;
1027  int4 inslot;
1028  int4 slot;
1030  void step(void);
1031  bool valid(void) const { return (op != (PcodeOp *)0); }
1032 };
1033 
1036  PcodeOp *op;
1037  int4 slot;
1038  Varnode *vn;
1039  PcodeOp *mult;
1040 public:
1041  PcodeOpEdge(PcodeOp *o,int4 s,PcodeOp *m) { op = o; slot = s; vn = op->getIn(slot); mult=m; }
1042  PcodeOp *getMultiplier(void) const { return mult; }
1043  PcodeOp *getOp(void) const { return op; }
1044  int4 getSlot(void) const { return slot; }
1045  Varnode *getVarnode(void) const { return vn; }
1046 };
1047 
1053 class TermOrder {
1054  PcodeOp *root;
1055  vector<PcodeOpEdge> terms;
1056  vector<PcodeOpEdge *> sorter;
1057  static bool additiveCompare(const PcodeOpEdge *op1,const PcodeOpEdge *op2);
1058 public:
1059  TermOrder(PcodeOp *rt) { root = rt; }
1060  int4 getSize(void) const { return terms.size(); }
1061  void collect(void);
1062  void sortTerms(void);
1063  const vector<PcodeOpEdge *> &getSort(void) { return sorter; }
1064 };
1065 
1073 inline bool TermOrder::additiveCompare(const PcodeOpEdge *op1,const PcodeOpEdge *op2) {
1074  return (-1 == op1->getVarnode()->termOrder(op2->getVarnode())); }
1075 
1076 #endif
Funcdata::spacebase
void spacebase(void)
Mark registers that map to a virtual address space.
Definition: funcdata.cc:214
ActionCopyMarker::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:978
ActionMarkIndirectOnly::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:339
ActionFuncLinkOutOnly::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1512
ActionAssignHigh::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:328
Action::Action
Action(uint4 f, const string &nm, const string &g)
Base constructor for an Action.
Definition: action.cc:25
ActionOutputPrototype::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3954
ActionExtraPopSetup::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1377
ActionSegmentize::reset
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:125
ActionDirectWrite::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1291
ActionLaneDivide::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:111
ActionActiveReturn::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1697
ActionConstbase::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:668
ActionDirectWrite::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:239
AddrSpace
A region where processor data is stored.
Definition: space.hh:73
ActionConstantPtr::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1107
ActionNormalizeSetup::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3758
ActionMergeAdjacent::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:367
FlowBlock
Description of a control-flow block containing PcodeOps.
Definition: block.hh:60
ActionPrototypeWarnings::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:1011
ActionReturnRecovery::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1832
ActionStackPtrFlow::reset
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:92
ActionNameVars::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:469
ActionAssignHigh
Assign initial high-level HighVariable objects to each Varnode.
Definition: coreaction.hh:325
PropagationState::iter
list< PcodeOp * >::const_iterator iter
Iterator to current descendant being enumerated.
Definition: coreaction.hh:1025
ActionSpacebase::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:269
ActionExtraPopSetup::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:644
ActionStartCleanUp::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:63
ActionCopyMarker::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:982
ActionConstbase::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:254
ActionVarnodeProps::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:217
ActionDynamicSymbols
Make final attachments of dynamically mapped symbols to Varnodes.
Definition: coreaction.hh:997
ActionForceGoto::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:137
ActionSetCasts::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:317
ActionStartTypes::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:71
ActionDoNothing::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3007
Funcdata::endLoc
VarnodeLocSet::const_iterator endLoc(void) const
End of all Varnodes sorted by storage.
Definition: funcdata.hh:307
ActionActiveParam::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1649
ActionCopyMarker
Mark COPY operations between Varnodes representing the object as non-printing.
Definition: coreaction.hh:975
ActionSwitchNorm::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:574
Funcdata::markIndirectOnly
void markIndirectOnly(void)
Mark illegal input Varnodes used only in INDIRECTs.
Definition: funcdata_varnode.cc:690
ActionStop::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:47
ActionConditionalConst::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3689
ActionConstantPtr::reset
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:189
ActionStart::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:39
ActionMarkExplicit::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:2770
ActionPrototypeTypes::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3800
ActionNonzeroMask::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:292
ActionMarkExplicit::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:427
ActionUnreachable
Remove unreachable blocks.
Definition: coreaction.hh:477
ActionLaneDivide
Find Varnodes with a vectorized lane scheme and attempt to split the lanes.
Definition: coreaction.hh:106
ActionStackPtrFlow::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:478
ActionMarkIndirectOnly::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:343
ActionRestrictLocal
Restrict possible range of local variables.
Definition: coreaction.hh:775
ActionHideShadow
Locate shadow Varnodes and adjust them so they are hidden.
Definition: coreaction.hh:953
ActionGroupList
The list of groups defining a root Action.
Definition: action.hh:29
ActionDynamicSymbols::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:4058
Funcdata::stopProcessing
void stopProcessing(void)
Mark that processing has completed for this function.
Definition: funcdata.cc:156
ActionStop::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:51
ActionRestructureHigh::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:830
Action::rule_repeatapply
@ rule_repeatapply
Apply rule repeatedly until no change.
Definition: action.hh:54
Funcdata::calcNZMask
void calcNZMask(void)
Calculate non-zero masks for all Varnodes.
Definition: funcdata_varnode.cc:731
ActionUnjustifiedParams::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3973
ActionHideShadow::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:4020
ActionActiveReturn::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:728
ActionDominantCopy::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:971
ProtoParameter
A function parameter viewed as a name, data-type, and storage address.
Definition: fspec.hh:912
ActionMarkImplied::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:2949
ActionNameVars::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:2528
ActionFuncLinkOutOnly::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:680
ActionStartTypes
Allow type recovery to start happening.
Definition: coreaction.hh:68
ActionDefaultParams::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:626
ActionDoNothing
Remove blocks that do nothing.
Definition: coreaction.hh:488
ActionOutputPrototype::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:866
Action
Large scale transformations applied to the varnode/op graph.
Definition: action.hh:50
FuncCallSpecs
A class for analyzing parameters to a sub-function call.
Definition: fspec.hh:1449
ActionSpacebase
Mark Varnode objects that hold stack-pointer values and set-up special data-type.
Definition: coreaction.hh:262
PropagationState::vn
Varnode * vn
The root Varnode.
Definition: coreaction.hh:1024
ActionDefaultParams
Find a prototype for each sub-function.
Definition: coreaction.hh:623
ActionMapGlobals::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:845
ActionPrototypeTypes::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:611
BlockBasic
A basic block for p-code operations.
Definition: block.hh:365
PcodeOp
Lowest level operation of the p-code language.
Definition: op.hh:58
ActionRestructureHigh
Create symbols that map out the local stack-frame for the function.
Definition: coreaction.hh:827
Architecture
Manager for all the major decompiler subsystems.
Definition: architecture.hh:119
SymbolEntry
A storage location for a particular Symbol.
Definition: database.hh:51
ActionRestructureVarnode
Create symbols that map out the local stack-frame for the function.
Definition: coreaction.hh:812
ActionNonzeroMask::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:288
PcodeOpEdge
Class representing a term in an additive expression.
Definition: coreaction.hh:1035
ActionAssignHigh::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:332
ActionSwitchNorm::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3735
ActionRestrictLocal::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1881
ActionShadowVar::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:173
Funcdata::beginLoc
VarnodeLocSet::const_iterator beginLoc(void) const
Start of all Varnodes sorted by storage.
Definition: funcdata.hh:304
ActionForceGoto::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:661
ActionSetCasts::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:2270
Action::count
int4 count
Number of changes made by this action so far.
Definition: action.hh:79
TermOrder::collect
void collect(void)
Collect all the terms in the expression.
Definition: coreaction.cc:4776
ActionUnjustifiedParams::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:881
ActionMapGlobals
Create symbols for any discovered global variables in the function.
Definition: coreaction.hh:838
ActionForceGoto
Apply any overridden forced gotos.
Definition: coreaction.hh:134
ActionLikelyTrash
Get rid of registers with trash values.
Definition: coreaction.hh:797
ActionHideShadow::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:956
ActionDeadCode::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3508
ActionInferTypes::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:939
ActionMultiCse
Perform Common Sub-expression Elimination on CPUI_MULTIEQUAL ops.
Definition: coreaction.hh:156
ActionUnreachable::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:2998
Funcdata::setHighLevel
void setHighLevel(void)
Turn on HighVariable objects for all Varnodes.
Definition: funcdata_varnode.cc:482
PropagationState::op
PcodeOp * op
The current descendant or the defining PcodeOp.
Definition: coreaction.hh:1026
ActionDeindirect::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1159
ActionUnreachable::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:480
Varnode
A low-level variable or contiguous set of bytes described by an Address and a size.
Definition: varnode.hh:65
TermOrder
A class for ordering Varnode terms in an additive expression.
Definition: coreaction.hh:1053
PropagationState::PropagationState
PropagationState(Varnode *v)
Constructor.
Definition: coreaction.cc:4473
ActionMultiCse::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:162
LanedRegister
Describes a (register) storage location and the ways it might be split into lanes.
Definition: transform.hh:88
ActionSpacebase::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:265
ParamActive
Container class for ParamTrial objects.
Definition: fspec.hh:222
ActionMergeRequired
Make required Varnode merges as dictated by CPUI_MULTIEQUAL, CPUI_INDIRECT, and addrtied property.
Definition: coreaction.hh:348
ActionHeritage::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:281
ActionConditionalConst::propagateConstant
void propagateConstant(Varnode *varVn, Varnode *constVn, FlowBlock *constBlock, Funcdata &data)
Replace reads of a given Varnode with a constant.
Definition: coreaction.cc:3655
ActionMultiCse::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:869
blockaction.hh
Actions and classes associated with transforming and structuring the control-flow graph.
ActionSegmentize::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:126
ActionMarkExplicit
Find explicit Varnodes: Varnodes that have an explicit token representing them in the output.
Definition: coreaction.hh:413
PropagationState
A class that holds a data-type traversal state during type propagation.
Definition: coreaction.hh:1022
ActionVarnodeProps::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1222
ActionPrototypeWarnings::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:4075
funcdata.hh
Utilities for processing data structures associated with a single function.
ActionMergeMultiEntry
Try to merge Varnodes specified by Symbols with multiple SymbolEntrys.
Definition: coreaction.hh:382
ActionConstantPtr
Check for constants, with pointer type, that correspond to global symbols.
Definition: coreaction.hh:181
CastStrategy
A strategy for applying type casts.
Definition: cast.hh:40
ActionParamDouble
Deal with situations that look like double precision parameters.
Definition: coreaction.hh:694
ActionExtraPopSetup
Define formal link between stack-pointer values before and after sub-function calls.
Definition: coreaction.hh:640
ActionSegmentize::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:614
ActionActiveParam
Determine active parameters to sub-functions.
Definition: coreaction.hh:712
ActionDeadCode::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:548
ActionGroupList::contains
bool contains(const string &nm) const
Check if this ActionGroupList contains a given group.
Definition: action.hh:37
ActionRedundBranch::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:502
ActionVarnodeProps
Transform based on Varnode properties, such as read-only and volatile.
Definition: coreaction.hh:214
ActionActiveParam::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:715
ActionMergeType
Try to merge Varnodes of the same type (if they don't hold different values at the same time)
Definition: coreaction.hh:393
Address
A low-level machine address for labelling bytes and data.
Definition: address.hh:46
ActionDoNothing::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:491
ActionShadowVar::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:882
Funcdata
Container for data structures associated with a single function.
Definition: funcdata.hh:45
Datatype
The base datatype class for the decompiler.
Definition: type.hh:62
ActionOutputPrototype
Set the (already) recovered output data-type as a formal part of the prototype.
Definition: coreaction.hh:863
ActionNormalizeSetup::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:595
ActionDirectWrite
Mark Varnodes built out of legal parameters.
Definition: coreaction.hh:235
ActionLikelyTrash::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:2064
TypeFactory
Container class for all Datatype objects in an Architecture.
Definition: type.hh:396
ActionPrototypeTypes::extendInput
void extendInput(Funcdata &data, Varnode *invn, ProtoParameter *param, BlockBasic *topbl)
Extend Varnode inputs to match prototype model.
Definition: coreaction.cc:3781
ActionNormalizeSetup
Prepare function prototypes for "normalize" simplification.
Definition: coreaction.hh:592
ActionActiveReturn
Determine which sub-functions have active output Varnodes.
Definition: coreaction.hh:725
ActionDynamicMapping::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:989
ActionRestructureHigh::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:2115
ActionDeterminedBranch
Remove conditional branches if the condition is constant.
Definition: coreaction.hh:510
Funcdata::startTypeRecovery
bool startTypeRecovery(void)
Mark that data-type analysis has started.
Definition: funcdata.cc:166
ActionInferTypes::reset
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:938
PropagationState::inslot
int4 inslot
Slot holding Varnode for descendant PcodeOp.
Definition: coreaction.hh:1027
PropagationState::step
void step(void)
Advance to the next propagation edge.
Definition: coreaction.cc:4497
PropagationState::slot
int4 slot
Current edge relative to current PcodeOp.
Definition: coreaction.hh:1028
ActionInferTypes::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:4733
ActionSegmentize
Make sure pointers into segmented spaces have the correct form.
Definition: coreaction.hh:121
ActionNameVars
Choose names for all high-level variables (HighVariables)
Definition: coreaction.hh:456
ActionShadowVar
Check for one CPUI_MULTIEQUAL input set defining more than one Varnode.
Definition: coreaction.hh:170
ActionInputPrototype::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:855
ActionDynamicSymbols::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:1000
ActionStackPtrFlow::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:93
ActionInputPrototype::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3899
ActionRestructureVarnode::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:817
ActionConditionalConst::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:559
ActionRestructureVarnode::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:2094
ActionMergeAdjacent::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:363
ActionParamDouble::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:697
ActionMergeType::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:396
ActionLaneDivide::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:579
ActionDominantCopy
Replace COPYs from the same source with a single dominant COPY.
Definition: coreaction.hh:964
ActionStart
Gather raw p-code for a function.
Definition: coreaction.hh:32
Funcdata::startProcessing
void startProcessing(void)
Start processing for this function.
Definition: funcdata.cc:138
ActionDynamicMapping
Attach dynamically mapped symbols to Varnodes in time for data-type propagation.
Definition: coreaction.hh:986
ActionMergeRequired::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:351
ActionMarkImplied::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:448
ActionPrototypeTypes
Lay down locked input and output data-type information.
Definition: coreaction.hh:607
ActionReturnRecovery
Determine data-flow holding the return value of the function.
Definition: coreaction.hh:760
ActionFuncLinkOutOnly
Prepare for data-flow analysis of function parameters, when recovery isn't required.
Definition: coreaction.hh:677
ActionReturnRecovery::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:764
ActionHeritage
Build Static Single Assignment (SSA) representation for function.
Definition: coreaction.hh:274
ActionDeadCode
Dead code removal. Eliminate dead p-code ops.
Definition: coreaction.hh:538
ActionNonzeroMask
Calculate the non-zero mask property on all Varnode objects.
Definition: coreaction.hh:285
Action::rule_onceperfunc
@ rule_onceperfunc
Apply rule once per function.
Definition: action.hh:55
CPUI_COPY
@ CPUI_COPY
Copy one operand to another.
Definition: opcodes.hh:36
ruleaction.hh
This is the basic set of transformation Rule objects.
ActionHeritage::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:277
ActionDefaultParams::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:2140
ActionPrototypeWarnings
Add warnings for prototypes that aren't modeled properly.
Definition: coreaction.hh:1008
ActionMergeAdjacent
Try to merge an op's input Varnode to its output, if they are at the same storage location.
Definition: coreaction.hh:360
ActionDeindirect
Eliminate locally constant indirect calls.
Definition: coreaction.hh:198
ActionDeterminedBranch::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3071
ActionDominantCopy::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:967
ActionStartTypes::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:75
ActionMergeCopy::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:374
ActionSwitchNorm
Normalize jump-table construction.
Definition: coreaction.hh:571
ActionUnjustifiedParams
Adjust improperly justified parameters.
Definition: coreaction.hh:878
ActionInputPrototype
Calculate the prototype for the function.
Definition: coreaction.hh:852
ActionDeindirect::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:201
ActionParamDouble::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:1521
ActionConstbase
Search for input Varnodes that have been officially provided constant values.
Definition: coreaction.hh:251
ActionMergeType::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:400
ActionMarkImplied
Mark all the implied Varnode objects, which will have no explicit token in the output.
Definition: coreaction.hh:435
ActionMergeRequired::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:355
ActionConstantPtr::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:190
ActionMergeMultiEntry::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:389
ActionRestructureVarnode::reset
virtual void reset(Funcdata &data)
Reset the Action for a new function.
Definition: coreaction.hh:816
ActionRedundBranch
Get rid of redundant branches: duplicate edges between the same input and output block.
Definition: coreaction.hh:499
Funcdata::mapGlobals
void mapGlobals(void)
Make sure there is a Symbol entry for all global Varnodes.
Definition: funcdata_varnode.cc:1407
ActionInferTypes
Infer and propagate data-types.
Definition: coreaction.hh:920
ActionDeterminedBranch::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:513
ActionMergeCopy
Try to merge the input and output Varnodes of a CPUI_COPY op.
Definition: coreaction.hh:371
ActionDynamicMapping::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:4041
TermOrder::sortTerms
void sortTerms(void)
Sort the terms using additiveCompare()
Definition: coreaction.cc:4825
ActionConditionalConst
Propagate conditional constants.
Definition: coreaction.hh:556
ActionStart::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:35
ActionStackPtrFlow
Analyze change to the stack pointer across sub-function calls.
Definition: coreaction.hh:82
ActionMapGlobals::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:841
ActionMarkIndirectOnly
Mark illegal Varnode inputs used only in CPUI_INDIRECT ops.
Definition: coreaction.hh:336
ActionLikelyTrash::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:802
ActionStop
Do any post-processing after decompilation.
Definition: coreaction.hh:44
ActionRedundBranch::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.cc:3033
ActionMergeMultiEntry::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:385
ActionStartCleanUp
Start clean up after main transform phase.
Definition: coreaction.hh:56
ActionMergeCopy::apply
virtual int4 apply(Funcdata &data)
Make a single attempt to apply this Action.
Definition: coreaction.hh:378
ActionStartCleanUp::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:59
ActionSetCasts
Fill-in CPUI_CAST p-code ops as required by the casting strategy.
Definition: coreaction.hh:312
ActionRestrictLocal::clone
virtual Action * clone(const ActionGroupList &grouplist) const
Clone the Action.
Definition: coreaction.hh:778