Skip to content
Snippets Groups Projects
Commit c8c254fe authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

[obfuscator] Renames parameters in function pointers

Fixes external issue 2433
parent 08f09ce2
No related branches found
No related tags found
No related merge requests found
......@@ -36,12 +36,27 @@ class visitor = object
val logic_vars_visited = Logic_var.Hashtbl.create 7
val id_pred_visited = Identified_predicate.Hashtbl.create 7
method! vtype = function
| TFun(t, args, variadic, attrs) ->
let args' =
match args with
| None -> None
| Some l ->
Some
(List.map
(fun (s,t,a) ->
(Dictionary.fresh Obfuscator_kind.Formal_in_type s, t, a)) l)
in
Cil.ChangeDoChildrenPost(TFun(t,args',variadic,attrs), Extlib.id)
| _ -> Cil.DoChildren
method! vglob_aux = function
| GType (ty,_) ->
if not (Cil.typeHasAttribute "fc_stdlib" ty.ttype) then
ty.tname <- Dictionary.fresh Obfuscator_kind.Type ty.tname;
Cil.DoChildren
| GVarDecl (v, _) | GVar (v, _, _) | GFun ({svar = v}, _) | GFunDecl (_, v, _)
| GVarDecl (v, _) | GVar (v, _, _)
| GFun ({svar = v}, _) | GFunDecl (_, v, _)
when Cil.is_unused_builtin v ->
Cil.SkipChildren
| _ ->
......
......@@ -25,6 +25,7 @@ type k =
| Enum
| Field
| Formal_var
| Formal_in_type
| Function
| Global_var
| Label
......@@ -41,6 +42,7 @@ let name_of_kind = function
| Enum -> "enum"
| Field -> "field"
| Formal_var -> "formal variable"
| Formal_in_type -> "formal variable in fun type"
| Function -> "function"
| Global_var -> "global variable"
| Label -> "label"
......@@ -57,6 +59,7 @@ let prefix = function
| Enum -> "E"
| Field -> "M"
| Formal_var -> "f"
| Formal_in_type -> "ft"
| Function -> "F"
| Global_var -> "G"
| Label -> "L"
......
......@@ -25,6 +25,7 @@ type k =
| Enum
| Field
| Formal_var
| Formal_in_type
| Function
| Global_var
| Label
......
......@@ -18,6 +18,10 @@
#define f1 q
#define f2 X_9999999999999999999999999999999999999999999999999999_0
#define f3 p
// formal variable in fun types
#define ft1 q
#define ft2 X_9999999999999999999999999999999999999999999999999999_0
#define ft3 p
/*********************************** */
/* end of dictionary for obfuscation */
/*********************************** */
......
......@@ -53,6 +53,15 @@
#define f4 c
#define f5 d
#define f6 s
// formal variable in fun types
#define ft1 x
#define ft2 y
#define ft3 p
#define ft4 f1
#define ft5 p
#define ft6 c
#define ft7 d
#define ft8 s
/*********************************** */
/* end of dictionary for obfuscation */
/*********************************** */
......@@ -74,7 +83,7 @@ enum T1 {
E3 = 4
};
struct T2 {
void (*M1)(int x, int y) ;
void (*M1)(int ft1, int ft2) ;
};
int G1 = 0;
/*@ global invariant LV1: G1 ≥ 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment