From 208929aeda1e129221d808af77528e5d8dfffff8 Mon Sep 17 00:00:00 2001
From: Yaelle Vincont <yaelle.vincont@cea.fr>
Date: Fri, 22 Feb 2019 16:10:28 +0100
Subject: [PATCH] [obfuscator] do not obfuscate stdlib and builtins

---
 src/plugins/obfuscator/obfuscate.ml | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/plugins/obfuscator/obfuscate.ml b/src/plugins/obfuscator/obfuscate.ml
index 213f983d1f4..41145d204d6 100644
--- a/src/plugins/obfuscator/obfuscate.ml
+++ b/src/plugins/obfuscator/obfuscate.ml
@@ -38,7 +38,8 @@ class visitor = object
 
   method! vglob_aux = function
   | GType (ty,_) ->
-    ty.tname <- Dictionary.fresh Obfuscator_kind.Type ty.tname; 
+    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, _)
       when Cil.is_unused_builtin v ->
@@ -83,10 +84,13 @@ class visitor = object
     if Varinfo.Hashtbl.mem varinfos_visited vi then
       Cil.SkipChildren
     else begin
-      if Cil.isFunctionType vi.vtype then begin
-	if vi.vname <> "main" then 
-	  vi.vname <- Dictionary.fresh Obfuscator_kind.Function vi.vname
-      end else begin
+      if Cil.isFunctionType vi.vtype then
+        try
+          if vi.vname <> "main"
+          && Kernel_function.is_definition (Globals.Functions.get vi) then
+            vi.vname <- Dictionary.fresh Obfuscator_kind.Function vi.vname
+        with Not_found -> assert false
+      else begin
 	let add =
           if vi.vglob then Dictionary.fresh Obfuscator_kind.Global_var
           else if vi.vformal then Dictionary.fresh Obfuscator_kind.Formal_var
-- 
GitLab