Skip to content

Commit

Permalink
Merge pull request #1283 from bjjwwang/1209
Browse files Browse the repository at this point in the history
refactor extapi
  • Loading branch information
yuleisui authored Dec 13, 2023
2 parents 7e2b3af + 8fe3974 commit 8122876
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 20 deletions.
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")))
__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 comments on commit 8122876

Please sign in to comment.