From 8f2e818c444363e29675d569ceaac48203f9d006 Mon Sep 17 00:00:00 2001 From: xleroy Date: Sat, 2 Feb 2013 11:32:47 +0000 Subject: Errors for excessively large global variables or stack frames. test/: update Makefiles so that "all" is the default target. git-svn-id: https://yquem.inria.fr/compcert/svn/compcert/trunk@2107 fca1b0fc-160b-0410-b1d3-a4f43f01ea2e --- cfrontend/C2C.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cfrontend') diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml index 3830ca7..4233af9 100644 --- a/cfrontend/C2C.ml +++ b/cfrontend/C2C.ml @@ -779,11 +779,12 @@ let convertInitializer env ty i = let convertGlobvar env (sto, id, ty, optinit) = let id' = intern_string id.name in let ty' = convertTyp env ty in + let sz = Ctypes.sizeof ty' in let attr = Cutil.attributes_of_type env ty in let init' = match optinit with | None -> - if sto = C.Storage_extern then [] else [Init_space(Ctypes.sizeof ty')] + if sto = C.Storage_extern then [] else [Init_space sz] | Some i -> convertInitializer env ty i in let align = @@ -792,6 +793,9 @@ let convertGlobvar env (sto, id, ty, optinit) = | _ -> Cutil.alignof env ty in let (section, near_access) = Sections.for_variable env id' ty (optinit <> None) in + if Z.gt sz (Z.of_uint64 0xFFFF_FFFFL) then + error (sprintf "Variable %s is too big (%s bytes)" + id.name (Z.to_string sz)); Hashtbl.add decl_atom id' { a_storage = sto; a_alignment = align; -- cgit v1.2.3