summaryrefslogtreecommitdiff
path: root/driver
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-12-28 08:47:43 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-12-28 08:47:43 +0000
commit8d7c806e16b98781a3762b5680b4dc64764da1b8 (patch)
tree82fb3ecd34e451e4e96f57e2103a694c9acc0830 /driver
parentad12162ff1f0d50c43afefc45e1593f27f197402 (diff)
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')
-rw-r--r--driver/Clflags.ml1
-rw-r--r--driver/Driver.ml2
-rw-r--r--driver/Interp.ml13
3 files changed, 6 insertions, 10 deletions
diff --git a/driver/Clflags.ml b/driver/Clflags.ml
index 442ca68..4f41bf6 100644
--- a/driver/Clflags.ml
+++ b/driver/Clflags.ml
@@ -48,6 +48,7 @@ let option_E = ref false
let option_S = ref false
let option_c = ref false
let option_v = ref false
+let option_interp = ref false
let option_small_data =
ref (if Configuration.arch = "powerpc"
&& Configuration.variant = "eabi"
diff --git a/driver/Driver.ml b/driver/Driver.ml
index bb9ac7c..44037b2 100644
--- a/driver/Driver.ml
+++ b/driver/Driver.ml
@@ -234,8 +234,6 @@ let linker exe_name files =
(* Processing of a .c file *)
-let option_interp = ref false
-
let process_c_file sourcename =
if !option_E then begin
preprocess sourcename (output_filename_default "-");
diff --git a/driver/Interp.ml b/driver/Interp.ml
index 5fcca0b..4f9debd 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";