This option prevents converting direct function calls into the
calls-by-pointers if the address of the function has been taken
somewhere. Calls from inside of structures are converted anyway.
(A small debug print fix has been also applied)
---
src/ext/simplify.ml | 14 +++++++++++---
1 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/ext/simplify.ml b/src/ext/simplify.ml
index 706e12d..0e3de67 100644
--- a/src/ext/simplify.ml
+++ b/src/ext/simplify.ml
@@ -85,6 +85,10 @@ let splitStructs = ref true
let simpleMem = ref true
let simplAddrOf = ref true
+(* Whether to convert function calls to calls-by-pointer when function address
+ * has been taken somewhere. *)
+let convertDirectCalls = ref true
+
let onlyVariableBasics = ref false
let noStringConstantsBasics = ref false
@@ -130,7 +134,7 @@ and makeBasic (setTemp: taExp -> bExp) (e: exp) : bExp =
(* Make it a three address expression first *)
let e' = makeThreeAddress setTemp e in
if dump then
- ignore (E.log " e'= %a\n" d_plainexp e);
+ ignore (E.log " e'= %a\n" d_plainexp e');
(* See if it is a basic one *)
match e' with
| Lval (Var _, _) -> e'
@@ -220,8 +224,9 @@ and simplifyLval
in
let a' = if !simpleMem then makeBasic setTemp a' else a' in
Mem (mkCast a' (typeForCast restoff)), restoff
-
- | Var v, off when v.vaddrof -> (* We are taking this variable's address *)
+ (* We are taking this variable's address; but suppress simplification if
it's a simple function
+ * call in no-convert mode*)
+ | Var v, off when v.vaddrof && (!convertDirectCalls || not (isFunctionType
(typeOfLval lv) )) ->
let offidx, restoff = offsetToInt v.vtype off in
(* We cannot call makeBasic recursively here, so we must do it
* ourselves *)
@@ -714,6 +719,9 @@ let feature : featureDescr =
fd_extraopt = [
("--no-split-structs", Arg.Clear splitStructs,
" do not split structured variables");
+ ("--no-convert-direct-calls", Arg.Clear convertDirectCalls,
+ " do not convert direct function calls to function pointer
\
+ calls if the address of the function was taken");
];
fd_doit = (function f -> iterGlobals f doGlobal);
fd_post_check = true;
--
1.7.0.2
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
CIL-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cil-users