summaryrefslogtreecommitdiff
path: root/cfrontend
diff options
context:
space:
mode:
authorGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-02-02 11:32:47 +0000
committerGravatar xleroy <xleroy@fca1b0fc-160b-0410-b1d3-a4f43f01ea2e>2013-02-02 11:32:47 +0000
commit8f2e818c444363e29675d569ceaac48203f9d006 (patch)
tree290e1b86688466b686dad14d644c3d57839c5ba9 /cfrontend
parentd2cf6277ac179c9e8432d4c11a79e9f906a19bbc (diff)
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
Diffstat (limited to 'cfrontend')
-rw-r--r--cfrontend/C2C.ml6
1 files changed, 5 insertions, 1 deletions
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;