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

Remove "STATIC" annotation in extapi.bc #1188

Merged
merged 4 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions svf-llvm/include/SVF-LLVM/LLVMUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ inline const PointerType *getRefTypeOfHeapAllocOrStatic(const CallBase* cs)
if (const PointerType *argType = SVFUtil::dyn_cast<PointerType>(arg->getType()))
refType = SVFUtil::dyn_cast<PointerType>(getPtrElementType(argType));
}
// Case 2: heap/static object held by return value.
// Case 2: heap object held by return value.
else
{
assert((SVFUtil::isStaticExtCall(svfcs) || SVFUtil::isHeapAllocExtCallViaRet(svfcs))
assert(SVFUtil::isHeapAllocExtCallViaRet(svfcs)
&& "Must be heap alloc via ret, or static allocation site");
refType = SVFUtil::dyn_cast<PointerType>(cs->getType());
}
Expand Down
2 changes: 0 additions & 2 deletions svf-llvm/lib/LLVMUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ const std::string structName = "struct.";
*/
bool LLVMUtil::isObject(const Value* ref)
{
if (SVFUtil::isa<Instruction>(ref) && SVFUtil::isStaticExtCall(LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(SVFUtil::cast<Instruction>(ref))) )
return true;
if (SVFUtil::isa<Instruction>(ref) && SVFUtil::isHeapAllocExtCallViaRet(LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(SVFUtil::cast<Instruction>(ref))))
return true;
if (SVFUtil::isa<GlobalVariable>(ref))
Expand Down
2 changes: 1 addition & 1 deletion svf-llvm/lib/SVFIRExtAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void SVFIRBuilder::handleExtCall(const CallBase* cs, const SVFFunction* svfCalle
const SVFInstruction* svfInst = LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(cs);
const SVFCallInst* svfCall = SVFUtil::cast<SVFCallInst>(svfInst);

if (isHeapAllocExtCallViaRet(svfCall) || isStaticExtCall(svfCall))
if (isHeapAllocExtCallViaRet(svfCall))
{
NodeID val = pag->getValueNode(svfInst);
NodeID obj = pag->getObjectNode(svfInst);
Expand Down
9 changes: 0 additions & 9 deletions svf-llvm/lib/SymbolTableBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,15 +750,6 @@ void SymbolTableBuilder::initTypeInfo(ObjTypeInfo* typeinfo, const Value* val,
// Heap object, label its field as infinite here
objSize = typeinfo->getMaxFieldOffsetLimit();
}
else if (SVFUtil::isa<Instruction>(val) &&
isStaticExtCall(
LLVMModuleSet::getLLVMModuleSet()->getSVFInstruction(
SVFUtil::cast<Instruction>(val))))
{
analyzeStaticObjType(typeinfo,val);
// static object allocated before main, label its field as infinite here
objSize = typeinfo->getMaxFieldOffsetLimit();
}
else if(ArgInProgEntryFunction(val))
{
analyzeStaticObjType(typeinfo,val);
Expand Down
165 changes: 41 additions & 124 deletions svf-llvm/lib/extapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
ALLOC_RET, // returns a ptr to a newly allocated object
ALLOC_ARGi // stores a pointer to an allocated object in *argi
REALLOC_RET,
STATIC, // retval points to an unknown static var X
MEMSET, // memcpy() operations
MEMCPY, // memset() operations
OVERWRITE, // svf function overwrite app function
Expand All @@ -23,291 +22,209 @@ void *SyGetmem(unsigned long size)
return NULL;
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
const unsigned short **__ctype_b_loc(void)
{
return NULL;
return malloc(10);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why malloc(10)? better to have a macro rather than a concrete number.

If you remove all STATIC functions, how about static functions mentioned here:
#1186

}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
int **__ctype_tolower_loc(void)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
int **__ctype_toupper_loc(void)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
int *__errno_location(void)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
int * __h_errno_location(void)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
void* __res_state(void)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char *asctime(const void *timeptr)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char * bindtextdomain(const char * domainname, const char * dirname)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char * bind_textdomain_codeset(const char * domainname, const char * codeset)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char *ctermid(char *s)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char * dcgettext(const char * domainname, const char * msgid, int category)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char * dgettext(const char * domainname, const char * msgid)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char * dngettext(const char * domainname, const char * msgid, const char * msgid_plural, unsigned long int n)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
void *fdopen(int fd, const char *mode)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct group *getgrgid(unsigned int gid)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct group *getgrnam(const char *name)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct hostent *gethostbyaddr(const void *addr, unsigned int len, int type)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct hostent *gethostbyname(const char *name)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct hostent *gethostbyname2(const char *name, int af)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct mntent *getmntent(void *stream)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct protoent *getprotobyname(const char *name)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct protoent *getprotobynumber(int proto)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct passwd *getpwent(void)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct passwd *getpwnam(const char *name)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct passwd *getpwuid(unsigned int uid)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct servent *getservbyname(const char *name, const char *proto)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct servent *getservbyport(int port, const char *proto)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct spwd *getspnam(const char *name)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char * gettext(const char * msgid)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct tm *gmtime(const void *timer)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
const char *gnu_get_libc_version(void)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
const char * gnutls_check_version(const char * req_version)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct lconv *localeconv(void)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
struct tm *localtime(const void *timer)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char * ngettext(const char * msgid, const char * msgid_plural, unsigned long int n)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
void *pango_cairo_font_map_get_default(void)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char *re_comp(const char *regex)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char *setlocale(int category, const char *locale)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char *tgoto(const char *cap, int col, int row)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
char *tparm(char *str, ...)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
__attribute__((annotate("STATIC")))
const char *zError(int a)
{
return NULL;
return malloc(10);
}

__attribute__((annotate("ALLOC_RET")))
Expand Down
Loading