Skip to content

Commit

Permalink
Merge pull request SVF-tools#311 from pzieris/bugfix_3
Browse files Browse the repository at this point in the history
Fix handling of calls to memset
  • Loading branch information
yuleisui authored Sep 3, 2020
2 parents 8c0340d + 107f7e3 commit c9072d9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions include/Util/ExtAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class ExtAPI
EFT_L_A1,
EFT_L_A2,
EFT_L_A8,
EFT_L_A0__A0R_A1, //stores arg1 into *arg0 and returns arg0
EFT_L_A0__A0R_A1R, //copies the data that arg1 points to into the location
// arg0 points to; note that several fields may be
// copied at once if both point to structs.
Expand Down
7 changes: 7 additions & 0 deletions lib/SVF-FE/PAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,13 @@ void PAGBuilder::handleExtCall(CallSite cs, const SVFFunction *callee)
break;
break;
}
case ExtAPI::EFT_L_A0__A0R_A1:
{
addComplexConsForExt(cs.getArgument(0), cs.getArgument(1));
if(SVFUtil::isa<PointerType>(inst->getType()))
addCopyEdge(getValueNode(cs.getArgument(0)), getValueNode(inst));
break;
}
case ExtAPI::EFT_L_A0__A0R_A1R:
{
addComplexConsForExt(cs.getArgument(0), cs.getArgument(1));
Expand Down
10 changes: 6 additions & 4 deletions lib/Util/ExtAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ static const ei_pair ei_pairs[]=
{"keypad", ExtAPI::EFT_NOOP},
{"lchown", ExtAPI::EFT_NOOP},
{"link", ExtAPI::EFT_NOOP},
{"llvm.memset", ExtAPI::EFT_NOOP},
{"llvm.dbg", ExtAPI::EFT_NOOP},
{"llvm.stackrestore", ExtAPI::EFT_NOOP},
{"llvm.va_copy", ExtAPI::EFT_NOOP},
Expand Down Expand Up @@ -701,9 +700,6 @@ static const ei_pair ei_pairs[]=
{"fgets", ExtAPI::EFT_L_A0},
{"jpeg_std_error", ExtAPI::EFT_L_A0},
{"memchr", ExtAPI::EFT_L_A0},
//This will overwrite *arg0 with non-pointer data -
// assume that no valid pointer values are created.
{"memset", ExtAPI::EFT_L_A0},
//This may return a new ptr if the region was moved.
{"mremap", ExtAPI::EFT_L_A0},
{"strchr", ExtAPI::EFT_L_A0},
Expand All @@ -728,10 +724,16 @@ static const ei_pair ei_pairs[]=
{"inet_ntop", ExtAPI::EFT_L_A2},
{"XGetSubImage", ExtAPI::EFT_L_A8},

{"memset", ExtAPI::EFT_L_A0__A0R_A1},
{"llvm.memset", ExtAPI::EFT_L_A0__A0R_A1},
{"llvm.memset.p0i8.i32", ExtAPI::EFT_L_A0__A0R_A1},
{"llvm.memset.p0i8.i64", ExtAPI::EFT_L_A0__A0R_A1},
{"llvm.memcpy", ExtAPI::EFT_L_A0__A0R_A1R},
{"llvm.memcpy.p0i8.p0i8.i32", ExtAPI::EFT_L_A0__A0R_A1R},
{"llvm.memcpy.p0i8.p0i8.i64", ExtAPI::EFT_L_A0__A0R_A1R},
{"llvm.memmove", ExtAPI::EFT_L_A0__A0R_A1R},
{"llvm.memmove.p0i8.p0i8.i32", ExtAPI::EFT_L_A0__A0R_A1R},
{"llvm.memmove.p0i8.p0i8.i64", ExtAPI::EFT_L_A0__A0R_A1R},
{"memccpy", ExtAPI::EFT_L_A0__A0R_A1R},
{"memcpy", ExtAPI::EFT_L_A0__A0R_A1R},
{"memmove", ExtAPI::EFT_L_A0__A0R_A1R},
Expand Down

0 comments on commit c9072d9

Please sign in to comment.