lifting-bits/fcd

RFC: Recovery of parameters passed via stack

surovic opened this issue · 1 comments

Consider the following code and a calling convention that uses no registers to pass parameters into a function:

int f(int p1, int p2, int p3, int p4, int p5) {
  int v1 = 5;
  return (v1 + p1 + p5) % 2;
}

int main(void) {
  return f(1,0,0,0,1);  
}

In this hypothetical scenario, with the current approach, fcd will recover the above as roughly:

int f(int p1, p2) {
  int v1 = 5;
  return (v1 + p1 + p2) % 2;
}

int main(void) {
  return f(1,1);
}

My question here is if we want to analyze callsites and try to recover the original function prototype or leave it as is and give the user the option to provide a function prototype in a header file, similarly to how the original fcd version handles prototypes of external functions.

After some experiments and consideration I think that callsite analysis is definitely worth it. Stack parameters are already sorta handled in code introduced in PR #16