diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-04-08 17:02:45 +0200 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-04-08 17:02:45 +0200 |
commit | c3f5f3dbd088091e3fab9f357b01693932d148f8 (patch) | |
tree | fee361b1e1cc616a1b9c412ae5cec7c9467dcf32 /backend | |
parent | 96165dbec88ab4c951d99e64e51f5c55a1244137 (diff) | |
download | compcert-kvx-c3f5f3dbd088091e3fab9f357b01693932d148f8.tar.gz compcert-kvx-c3f5f3dbd088091e3fab9f357b01693932d148f8.zip |
reloading and exploiting seems to work
Diffstat (limited to 'backend')
-rw-r--r-- | backend/ProfilingExploit.v | 30 | ||||
-rw-r--r-- | backend/Profilingaux.ml | 8 |
2 files changed, 37 insertions, 1 deletions
diff --git a/backend/ProfilingExploit.v b/backend/ProfilingExploit.v new file mode 100644 index 00000000..cfca1a12 --- /dev/null +++ b/backend/ProfilingExploit.v @@ -0,0 +1,30 @@ +Require Import Coqlib Maps Errors Integers Floats Lattice Kildall. +Require Import AST Linking. +Require Import Memory Registers Op RTL. + +Local Open Scope positive. + +Parameter function_id : function -> AST.profiling_id. +Parameter branch_id : AST.profiling_id -> node -> AST.profiling_id. +Parameter condition_oracle : AST.profiling_id -> option bool. + +Definition transf_instr (f_id : AST.profiling_id) + (pc : node) (i : instruction) : instruction := + match i with + | Icond cond args ifso ifnot None => + Icond cond args ifso ifnot (condition_oracle (branch_id f_id pc)) + | _ => i + end. + +Definition transf_function (f : function) : function := + {| fn_sig := f.(fn_sig); + fn_params := f.(fn_params); + fn_stacksize := f.(fn_stacksize); + fn_code := PTree.map (transf_instr (function_id f)) f.(fn_code); + fn_entrypoint := f.(fn_entrypoint) |}. + +Definition transf_fundef (fd: fundef) : fundef := + AST.transf_fundef transf_function fd. + +Definition transf_program (p: program) : program := + transform_program transf_fundef p. diff --git a/backend/Profilingaux.ml b/backend/Profilingaux.ml index 0644e843..51718303 100644 --- a/backend/Profilingaux.ml +++ b/backend/Profilingaux.ml @@ -48,7 +48,13 @@ let load_profiling_info (filename : string) : unit = let id : identifier = really_input_string ic 16 in let counter0 = input_counter ic in let counter1 = input_counter ic in - Printf.fprintf stderr "%a : %Ld %Ld\n" pp_id id counter0 counter1; + (* Printf.fprintf stderr "%a : %Ld %Ld\n" pp_id id counter0 counter1; *) add_profiling_counts id counter0 counter1 done with End_of_file -> close_in ic;; + +let condition_oracle (id : identifier) : bool option = + let (count0, count1) = get_counts id in + Printf.fprintf stderr "%a : %Ld %Ld\n" pp_id id count0 count1; + if count0 = count1 then None + else Some(count1 > count0);; |