secure-software-engineering / phasar

A LLVM-based static analysis framework.
Other
930 stars 140 forks source link

How to tell pointer-analysis in phasar not treat some pointers as alias #513

Closed Luweicai closed 2 years ago

Luweicai commented 2 years ago

Is your feature request related to a problem? Please describe. I want the point-analysis in phasar does not treat the pointer-type parameters as alias at the beginning of program. Some function might have several pointer-type parameters. Like function encrypt showed below:

void encrypt (uint32_t* v, uint32_t* k) {
  uint32_t v0=v[0], v1=v[1];           /* set up */
  uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3];   /* cache key */
  uint32_t vv = v[0];
  return ;
}

int main(){
  uint32_t a[2] = {1,2};
  uint32_t b[4] = {0};
  encrypt(a,b);
  return 0;
}

I find the pointer-analysis in phasar will just think v and k as alias, I have tried to modify the code (such as create two irrelevant array and let v and k point them), or add the previous point-analysis information to phasar ( the json file is like {"AnalyzedFunctions":["main"],"PointsToSets":[["36"],["37"]]}, which "36" and "37" are ID of a and b in main). It does not work.

Luweicai commented 2 years ago

Add the __restrict key word will works. Like void encrypt(uint32_t *__restrict v, uint32_t *__restrict k).