diff --git a/svf-llvm/lib/extapi.c b/svf-llvm/lib/extapi.c index e263bb8e5..de9bd8d45 100644 --- a/svf-llvm/lib/extapi.c +++ b/svf-llvm/lib/extapi.c @@ -1,3 +1,4 @@ +#include #define NULL ((void *)0) #define STATIC_OBJECT malloc(10) @@ -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; @@ -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) { diff --git a/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp b/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp index 016920056..d7c29f466 100644 --- a/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp +++ b/svf/lib/AbstractExecution/SVFIR2ItvExeState.cpp @@ -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; } diff --git a/svf/lib/MemoryModel/AccessPath.cpp b/svf/lib/MemoryModel/AccessPath.cpp index fbf1314f8..a6bee2e81 100644 --- a/svf/lib/MemoryModel/AccessPath.cpp +++ b/svf/lib/MemoryModel/AccessPath.cpp @@ -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();