aboutsummaryrefslogtreecommitdiffstats
path: root/driver
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-01-27 16:57:20 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2015-01-27 16:57:20 +0100
commite096fa7aa6161e1f5a74001185eb3873a684c48d (patch)
treeca928bcb3f7b6b2237a626fbb1dbc1ce62b2e5d1 /driver
parentf00b70b6a17fdfb4e8606df891f6becc8102ef12 (diff)
downloadcompcert-e096fa7aa6161e1f5a74001185eb3873a684c48d.tar.gz
compcert-e096fa7aa6161e1f5a74001185eb3873a684c48d.zip
ABI compatibility for struct/union function arguments passed by value.
The passing of struct/union arguments by value implemented in the verified part of CompCert is not compatible with the ARM, PowerPC and x86 ABI. Here we enrich the StructReturn source-to-source emulation pass so that it implements the calling conventions defined in these ABIs. Plus: for x86, implement the returning of struct/union results by value in a way compatible with the ABI.
Diffstat (limited to 'driver')
-rw-r--r--driver/Driver.ml5
-rw-r--r--driver/Interp.ml6
2 files changed, 10 insertions, 1 deletions
diff --git a/driver/Driver.ml b/driver/Driver.ml
index 5d4c2f9c..31d5096b 100644
--- a/driver/Driver.ml
+++ b/driver/Driver.ml
@@ -241,6 +241,7 @@ let process_c_file sourcename =
let preproname = Filename.temp_file "compcert" ".i" in
preprocess sourcename preproname;
if !option_interp then begin
+ Machine.config := Machine.compcert_interpreter !Machine.config;
let csyntax = parse_c_file sourcename preproname in
safe_remove preproname;
Interp.execute csyntax;
@@ -583,7 +584,9 @@ let _ =
begin match Configuration.arch with
| "powerpc" -> Machine.ppc_32_bigendian
| "arm" -> Machine.arm_littleendian
- | "ia32" -> Machine.x86_32
+ | "ia32" -> if Configuration.system = "macosx"
+ then Machine.x86_32_macosx
+ else Machine.x86_32
| _ -> assert false
end;
Builtins.set C2C.builtins;
diff --git a/driver/Interp.ml b/driver/Interp.ml
index ab22cebb..57f252b0 100644
--- a/driver/Interp.ml
+++ b/driver/Interp.ml
@@ -380,6 +380,7 @@ let do_printf m fmt args =
let (>>=) opt f = match opt with None -> None | Some arg -> f arg
+(*
(* Like eventval_of_val, but accepts static globals as well *)
let convert_external_arg ge v t =
@@ -399,6 +400,7 @@ let rec convert_external_args ge vl tl =
convert_external_arg ge v1 t1 >>= fun e1 ->
convert_external_args ge vl tl >>= fun el -> Some (e1 :: el)
| _, _ -> None
+*)
let do_external_function id sg ge w args m =
match extern_atom id, args with
@@ -406,8 +408,12 @@ let do_external_function id sg ge w args m =
extract_string m b ofs >>= fun fmt ->
print_string (do_printf m fmt args');
flush stdout;
+ Some(((w, [Event_syscall(id, [], EVint Int.zero)]), Vint Int.zero), m)
+(*
convert_external_args ge args sg.sig_args >>= fun eargs ->
Some(((w, [Event_syscall(id, eargs, EVint Int.zero)]), Vint Int.zero), m)
+*)
+
| _ ->
None