Fixed initialization of option tables
[libfirm] / ir / be / begnuas.c
index 5bb8185..c3798b6 100644 (file)
@@ -38,7 +38,6 @@
 #include "obst.h"
 #include "tv.h"
 #include "irnode.h"
-#include "entity.h"
 #include "irprog.h"
 #include "pdeq.h"
 #include "error.h"
@@ -436,7 +435,10 @@ static int ent_is_string_const(ir_entity *ent)
  */
 static void dump_string_cst(obstack_t *obst, ir_entity *ent)
 {
-       int i, n;
+       int      i, n;
+       ir_type *type;
+       int      type_size;
+       int      remaining_space;
 
        obstack_printf(obst, "\t.string \"");
        n = get_compound_ent_n_values(ent);
@@ -463,6 +465,14 @@ static void dump_string_cst(obstack_t *obst, ir_entity *ent)
                }
        }
        obstack_printf(obst, "\"\n");
+
+       type            = get_entity_type(ent);
+       type_size       = get_type_size_bytes(type);
+       remaining_space = type_size - n;
+       assert(remaining_space >= 0);
+       if(remaining_space > 0) {
+               obstack_printf(obst, "\t.skip\t%d\n", remaining_space);
+       }
 }
 
 static void dump_array_init(be_gas_decl_env_t *env, obstack_t *obst,
@@ -676,7 +686,11 @@ static void dump_global(be_gas_decl_env_t *env, ir_entity *ent, int emit_commons
 
        if (variability == variability_uninitialized) {
                if(emit_as_common) {
-                       obstack_printf(obst, "\t.comm %s,%d,%d\n",
+                       if (be_gas_flavour == GAS_FLAVOUR_NORMAL)
+                               obstack_printf(obst, "\t.comm %s,%d,%d\n",
+                                       ld_name, get_type_size_bytes(type), align);
+                       else
+                               obstack_printf(obst, "\t.comm %s,%d # %d\n",
                                        ld_name, get_type_size_bytes(type), align);
                } else {
                        obstack_printf(obst, "\t.zero %d\n", get_type_size_bytes(type));