Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add comments to some APIs in SVFIRExtAPI.cpp #1185

Merged
merged 1 commit into from
Sep 5, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion svf-llvm/lib/SVFIRExtAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
}
else if (isMemcpyExtFun(svfCallee))
{
// Side-effects similar to void *memcpy(void *dest, const void * src, size_t n)
// which copies n characters from memory area 'src' to memory area 'dest'.
if(svfCallee->getName().find("iconv") != std::string::npos)
addComplexConsForExt(cs->getArgOperand(3), cs->getArgOperand(1), nullptr);
else if(svfCallee->getName().find("bcopy") != std::string::npos)
Expand All @@ -169,7 +171,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
}
else if(isMemsetExtFun(svfCallee))
{
// this is for memset(void *str, int c, size_t n)
// Side-effects similar to memset(void *str, int c, size_t n)
// which copies the character c (an unsigned char) to the first n characters of the string pointed to, by the argument str
std::vector<AccessPath> dstFields;
const Type *dtype = getBaseTypeAndFlattenedFields(cs->getArgOperand(0), dstFields, cs->getArgOperand(2));
Expand All @@ -187,6 +189,19 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
}
else if(svfCallee->getName().compare("dlsym") == 0)
{
/*
Side-effects of void* dlsym( void* handle, const char* funName),
Locate the function with the name "funName," then add a "copy" edge between the callsite and that function.
dlsym() example:
int main() {
// Open the shared library
void* handle = dlopen("./my_shared_library.so", RTLD_LAZY);
// Find the function address
void (*myFunctionPtr)() = (void (*)())dlsym(handle, "myFunction");
// Call the function
myFunctionPtr();
}
*/
const Value* src = cs->getArgOperand(1);
if(const GetElementPtrInst* gep = SVFUtil::dyn_cast<GetElementPtrInst>(src))
src = stripConstantCasts(gep->getPointerOperand());
Expand All @@ -212,6 +227,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
}
else if(svfCallee->getName().find("_ZSt29_Rb_tree_insert_and_rebalancebPSt18_Rb_tree_node_baseS0_RS_") != std::string::npos)
{
// The purpose of this function is to insert a new node into the red-black tree and then rebalance the tree to ensure that the red-black tree properties are maintained.
assert(svfCall->arg_size() == 4 && "_Rb_tree_insert_and_rebalance should have 4 arguments.\n");

// We have vArg3 points to the entry of _Rb_tree_node_base { color; parent; left; right; }.
Expand Down
Loading