8000 refactor extapi by bjjwwang · Pull Request #1283 · SVF-tools/SVF · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

refactor extapi #1283

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

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
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
81 changes: 61 additions & 20 deletions svf-llvm/lib/extapi.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <stddef.h>
#define NULL ((void *)0)
#define STATIC_OBJECT malloc(10)

Expand Down Expand Up @@ -554,28 +555,28 @@ int XmbTextPropertyToTextList(void *a, void *b, char ***c, int *d)
return 0;
}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
void llvm_memcpy_p0i8_p0i8_i64(char* dst, char* src, int sz, int flag){}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
void llvm_memcpy_p0i8_p0i8_i32(char* dst, char* src, int sz, int flag){}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
void llvm_memcpy(char* dst, char* src, int sz, int flag){}

__attribute__((annotate("MEMCPY"))) 10000
__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
void llvm_memmove(char* dst, char* src, int sz, int flag){}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
void llvm_memmove_p0i8_p0i8_i64(char* dst, char* src, int sz, int flag){}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
void llvm_memmove_p0i8_p0i8_i32(char* dst, char* src, int sz, int flag){}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
void __memcpy_chk(char* dst, char* src, int sz, int flag){}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
void *memmove(void *str1, const void *str2, unsigned long n)
{
return NULL;
Expand All @@ -590,66 +591,106 @@ void *memccpy( void * restrict dest, const void * restrict src, int c, unsigned
return NULL;
}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
void __memmove_chk(char* dst, char* src, int sz){}

__attribute__((annotate("MEMSET")))
__attribute__((annotate("MEMSET"), annotate("BUF_CHECK:Arg0, Arg2")))
void llvm_memset(char* dst, char elem, int sz, int flag){}

__attribute__((annotate("MEMSET")))
__attribute__((annotate("MEMSET"), annotate("BUF_CHECK:Arg0, Arg2")))
void llvm_memset_p0i8_i32(char* dst, char elem, int sz, int flag){}

__attribute__((annotate("MEMSET")))
__attribute__((annotate("MEMSET"), annotate("BUF_CHECK:Arg0, Arg2")))
void llvm_memset_p0i8_i64(char* dst, char elem, int sz, int flag){}

__attribute__((annotate("MEMSET")))
__attribute__((annotate("MEMSET"), annotate("BUF_CHECK:Arg0, Arg2")))
char *__memset_chk(char * dest, int c, unsigned long destlen, int flag)
{
return NULL;
}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMSET"), annotate("BUF_CHECK:Arg0, Arg2")))
char *wmemset(wchar_t * dst, wchar_t elem, int sz, int flag) {
return NULL;
}


__attribute__((annotate("MEMCPY"), annotate("STRCPY")))
char * __strcpy_chk(char * dest, const char * src, unsigned long destlen)
{
return NULL;
}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("STRCAT")))
char *__strcat_chk(char * dest, const char * src, unsigned long destlen)
{
return NULL;
}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("STRCAT")))
wchar_t* __wcscat_chk(wchar_t * dest, const wchar_t * src)
{
return NULL;
}

__attribute__((annotate("MEMCPY"), annotate("STRCPY")))
char *stpcpy(char *restrict dst, const char *restrict src)
{
return NULL;
}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("STRCAT")))
char *strcat(char *dest, const char *src)
{
return NULL;
}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("STRCAT")))
char *wcscat(char *dest, const char *src)
{
return NULL;
}


__attribute__((annotate("MEMCPY"), annotate("STRCPY")))
char *strcpy(char *dest, const char *src)
{
return NULL;
}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("STRCAT")))
char *strncat(char *dest, const char *src, unsigned long n)
{
return NULL;
}

__attribute__((annotate("MEMCPY")))
__attribute__((annotate("MEMCPY"), annotate("STRCAT")))
wchar_t* wcsncat(wchar_t * dest, const wchar_t * src, int n) {
return NULL;
}

__attribute__((annotate("MEMCPY"), annotate("STRCAT")))
char *__strncat_chk(char *dest, const char *src, unsigned long n)
{
return NULL;
}

__attribute__((annotate("MEMCPY"), annotate("STRCAT")))
wchar_t* __wcsncat_chk(wchar_t * dest, const wchar_t * src, int n) {
return NULL;
}

__attribute__((annotate("MEMCPY"), annotate("BUF_CHECK:Arg0, Arg2"), annotate("BUF_CHECK:Arg1, Arg2")))
char *strncpy(char *dest, const char *src, unsigned long n)
{
return NULL;
}

__attribute__((annotate("MEMCPY"), annotate("STRCPY")))
char *wcscpy(wchar_t* dest, const wchar_t* src) {
return NULL;
}

__attribute__((annotate("MEMCPY")))
unsigned long iconv(void* cd, char **restrict inbuf, unsigned long *restrict inbytesleft, char **restrict outbuf, unsigned long *restrict outbytesleft)
{
Expand Down
3 changes: 3 additions & 0 deletions svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,9 @@ IntervalValue SVFIR2ItvExeState::getItvOfFlattenedElemIndex(const GepStmt *gep)
res = res + IntervalValue(idxLb, idxUb);
}
res.meet_with(IntervalValue((s64_t)0, (s64_t)Options::MaxFieldLimit()));
if (res.isBottom()) {
res = IntervalValue(0);
}
return res;
}

Expand Down
5 changes: 5 additions & 0 deletions svf/lib/MemoryModel/AccessPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ APOffset AccessPath::computeConstantOffset() const
assert(isConstantOffset() && "not a constant offset");

APOffset totalConstOffset = 0;
//After the model-const and model-array options are turned on,
// the gepstmt offset generated by the array on the global
// node will be saved in getConstantStructFldIdx
if (idxOperandPairs.size() == 0)
return getConstantStructFldIdx();
for(int i = idxOperandPairs.size() - 1; i >= 0; i--)
{
const SVFValue* value = idxOperandPairs[i].first->getValue();
Expand Down
0