aboutsummaryrefslogtreecommitdiffstats
path: root/driver/Interp.ml
diff options
context:
space:
mode:
authorxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-12-28 08:47:43 +0000
committerxleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-12-28 08:47:43 +0000
commit8d7c806e16b98781a3762b5680b4dc64764da1b8 (patch)
tree82fb3ecd34e451e4e96f57e2103a694c9acc0830 /driver/Interp.ml
parentad12162ff1f0d50c43afefc45e1593f27f197402 (diff)
downloadcompcert-kvx-8d7c806e16b98781a3762b5680b4dc64764da1b8.tar.gz
compcert-kvx-8d7c806e16b98781a3762b5680b4dc64764da1b8.zip
Simpler, more robust emulation of calls to variadic functions:
- C function types and Cminor signatures annotated by calling conventions. esp. vararg / not vararg - Cshmgen: generate correct code for function call where there are more arguments than listed in the function prototype. This is still undefined behavior according to the formal semantics, but correct code is generated. - C2C, */PrintAsm.ml: remove "printf$iif" hack. - powerpc/, checklink/: don't generate stubs for variadic functions. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2386 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e
Diffstat (limited to 'driver/Interp.ml')
-rw-r--r--driver/Interp.ml13
1 files changed, 5 insertions, 8 deletions
diff --git a/driver/Interp.ml b/driver/Interp.ml
index 5fcca0b1..4f9debd4 100644
--- a/driver/Interp.ml
+++ b/driver/Interp.ml
@@ -361,14 +361,10 @@ let do_printf m fmt args =
(* Implementation of external functions *)
-let re_stub = Str.regexp "\\$[ifl]*$"
-
-let chop_stub name = Str.replace_first re_stub "" name
-
let (>>=) opt f = match opt with None -> None | Some arg -> f arg
let do_external_function id sg ge w args m =
- match chop_stub(extern_atom id), args with
+ match extern_atom id, args with
| "printf", Vptr(b, ofs) :: args' ->
extract_string m b ofs >>= fun fmt ->
print_string (do_printf m fmt args');
@@ -594,7 +590,8 @@ let change_main_function p old_main old_main_ty =
let body =
Sreturn(Some(Ecall(old_main, Econs(arg1, Econs(arg2, Enil)), type_int32s))) in
let new_main_fn =
- { fn_return = type_int32s; fn_params = []; fn_vars = []; fn_body = body } in
+ { fn_return = type_int32s; fn_callconv = cc_default;
+ fn_params = []; fn_vars = []; fn_body = body } in
let new_main_id = intern_string "___main" in
{ prog_main = new_main_id;
prog_defs = (new_main_id, Gfun(Internal new_main_fn)) :: p.prog_defs }
@@ -611,10 +608,10 @@ let fixup_main p =
None
| Some main_fd ->
match type_of_fundef main_fd with
- | Tfunction(Tnil, Tint(I32, Signed, _)) ->
+ | Tfunction(Tnil, Tint(I32, Signed, _), _) ->
Some p
| Tfunction(Tcons(Tint _, Tcons(Tpointer(Tpointer(Tint(I8,_,_),_),_), Tnil)),
- Tint _) as ty ->
+ Tint _, _) as ty ->
Some (change_main_function p p.prog_main ty)
| _ ->
fprintf err_formatter "ERROR: wrong type for main() function";