Static Value-Flow Analysis
AbsExtAPI.h
Go to the documentation of this file.
1 //===- AbsExtAPI.h -- Abstract Interpretation External API handler-----//
2 //
3 // SVF: Static Value-Flow Analysis
4 //
5 // Copyright (C) <2013-> <Yulei Sui>
6 //
7 
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
17 
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //===----------------------------------------------------------------------===//
22 
23 
24 //
25 // Created by Jiawei Wang on 2024/9/9.
26 //
27 #pragma once
28 #include "AE/Core/AbstractState.h"
29 #include "AE/Core/ICFGWTO.h"
30 #include "AE/Svfexe/AEDetector.h"
31 #include "AE/Svfexe/AbsExtAPI.h"
32 #include "Util/SVFBugReport.h"
33 #include "WPA/Andersen.h"
34 
35 namespace SVF
36 {
37 
38 // Forward declaration of AbstractInterpretation class
39 class AbstractInterpretation;
40 
45 class AbsExtAPI
46 {
47 public:
53 
59 
63  void initExtFunMap();
64 
71  std::string strRead(AbstractState& as, const SVFVar* rhs);
72 
77  void handleExtAPI(const CallICFGNode *call);
78 
83  void handleStrcpy(const CallICFGNode *call);
84 
91  IntervalValue getStrlen(AbstractState& as, const SVF::SVFVar *strValue);
92 
97  void handleStrcat(const SVF::CallICFGNode *call);
98 
107  void handleMemcpy(AbstractState& as, const SVF::SVFVar *dst, const SVF::SVFVar *src, IntervalValue len, u32_t start_idx);
108 
116  void handleMemset(AbstractState& as, const SVFVar* dst, IntervalValue elem, IntervalValue len);
117 
124 
132 
138  const SVFVar* getSVFVar(const SVFValue* val);
139 
140 protected:
144  Map<std::string, std::function<void(const CallICFGNode*)>> func_map;
145 };
146 
147 } // namespace SVF
newitem type
Definition: cJSON.cpp:2739
const char *const string
Definition: cJSON.h:172
Handles external API calls and manages abstract states.
Definition: AbsExtAPI.h:46
std::string strRead(AbstractState &as, const SVFVar *rhs)
Reads a string from the abstract state.
Definition: AbsExtAPI.cpp:357
void handleMemset(AbstractState &as, const SVFVar *dst, IntervalValue elem, IntervalValue len)
Handles the memset API call.
Definition: AbsExtAPI.cpp:638
void initExtFunMap()
Initializes the external function map.
Definition: AbsExtAPI.cpp:38
IntervalValue getStrlen(AbstractState &as, const SVF::SVFVar *strValue)
Calculates the length of a string.
Definition: AbsExtAPI.cpp:469
Map< const ICFGNode *, AbstractState > & abstractTrace
Map of ICFG nodes to abstract states.
Definition: AbsExtAPI.h:143
void handleExtAPI(const CallICFGNode *call)
Handles an external API call.
Definition: AbsExtAPI.cpp:387
AbsExtAPI(Map< const ICFGNode *, AbstractState > &traces)
Constructor for AbsExtAPI.
Definition: AbsExtAPI.cpp:31
AbstractState & getAbsStateFromTrace(const ICFGNode *node)
Retrieves the abstract state from the trace for a given ICFG node.
Definition: AbsExtAPI.cpp:344
const SVFVar * getSVFVar(const SVFValue *val)
Retrieves the SVF variable from a given SVF value.
Definition: AbsExtAPI.cpp:763
void handleMemcpy(AbstractState &as, const SVF::SVFVar *dst, const SVF::SVFVar *src, IntervalValue len, u32_t start_idx)
Handles the memcpy API call.
Definition: AbsExtAPI.cpp:580
SVFIR * svfir
Pointer to the SVF intermediate representation.
Definition: AbsExtAPI.h:141
void handleStrcat(const SVF::CallICFGNode *call)
Handles the strcat API call.
Definition: AbsExtAPI.cpp:545
ExtAPIType
Enumeration of external API types.
Definition: AbsExtAPI.h:52
IntervalValue getRangeLimitFromType(const SVFType *type)
Gets the range limit from a type.
Definition: AbsExtAPI.cpp:701
ICFG * icfg
Pointer to the interprocedural control flow graph.
Definition: AbsExtAPI.h:142
void handleStrcpy(const CallICFGNode *call)
Handles the strcpy API call.
Definition: AbsExtAPI.cpp:457
Map< std::string, std::function< void(const CallICFGNode *)> > func_map
Map of function names to handlers.
Definition: AbsExtAPI.h:144
Definition: ICFG.h:48
for isBitcode
Definition: BasicTypes.h:68
std::unordered_map< Key, Value, Hash, KeyEqual, Allocator > Map
Definition: GeneralType.h:101
unsigned u32_t
Definition: GeneralType.h:46